InvalidScopeError when using custom Scope in Field
还没有人认领这个 Issue。
评估
调研方向
在 student_view 中重现 Table-XBlock/table/table.py 的自定义 Scope 失败,然后通过 xblock/fields.py::get 和 xblock/field_data.py::_field_data 跟踪字段访问。确定为什么自定义 Scope 会引发 InvalidScopeError,而预定义的 scope 可以正常工作;当字段能够在 student_view 中读取且不会引发该异常时即视为完成,如果 repository 提供了合适的测试位置,还应添加回归测试覆盖。
由索引模型根据 Issue 内容生成。
描述
This is the code I'm currently using to try to do this:
tableStructure = Dict(default={}, scope=Scope(UserScope.NONE, BlockScope.TYPE), help="Help Text")
Whenever I attempt to read the value of the Field, an InvalidScopeError is raised. This doesn't seem to happen with the other predefined Scopes (e.g Scope.content). Furthermore, the error only seems to happen if I attempt to access the value of the Field from within the student_view.
Here is a stack trace:
2014-09-10 10:15:13,883 WARNING 2366 [contentstore.views.preview] preview.py:223 - Unable to render student_view for <TableXBlockWithMixins @4644 rerandomize='never', graded=False, annotation_token_secret='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', giturl=None, source_file=None, course_edit_method='Studio', default_tab=None, showanswer='finished', display_name='Table XBlock', video_speed_optimizations=True, chrome=None, showColumns=[], due=None, start=datetime.datetime(2030, 1, 1, 0, 0, tzinfo=<UTC>), tags=[], days_early_for_beta=None, max_attempts=None, text_customization={}, userRows={}, parent=None, format=None, matlab_api_key=None, xqa_key=None, annotation_storage_url='http://your_annotation_storage.com', use_latex_compiler=False, extended_due=None, static_asset_path='', hide_from_toc=False, count=0, name=None, ispublic=None, user_partitions=[], graceperiod=None, visible_to_staff_only=False, tableStructure=???>
Traceback (most recent call last):
File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/preview.py", line 221, in get_preview_fragment
fragment = module.render(preview_view, context)
File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/core.py", line 289, in render
return self.runtime.render(self, view, context)
File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1166, in render
return block.xmodule_runtime.render(to_render, view_name, context)
File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1029, in render
return super(MetricsMixin, self).render(block, view_name, context=context)
File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/runtime.py", line 586, in render
frag = view_fn(context)
File "/edx/app/edxapp/edx-platform/Table-XBlock/table/table.py", line 68, in student_view
tab = self.tableStructure
File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/fields.py", line 369, in __get__
if xblock._field_data.has(xblock, self.name):
File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/field_data.py", line 174, in has
return self._field_data(block, name).has(block, name)
File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/field_data.py", line 153, in _field_data
raise InvalidScopeError(scope)
InvalidScopeError: ScopeBase(user=UserScope.NONE, block=BlockScope.TYPE, name=u'UserScope.NONE_BlockScope.TYPE')
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/handlers.py", line 810, in emit
self.socket.sendto(msg, self.address)
TypeError: getsockaddrarg: AF_INET address must be tuple, not NoneType
Logged from file preview.py, line 223
[10/Sep/2014 10:15:13] "GET /xblock/i4x://ADL/ADL101/table/ac25938d0f7941878430fbf40c501747/student_view?_=1410358513743 HTTP/1.1" 200 1686
- 主要语言
- Python
- 星标
- 470
- 派生
- 231
- 平均合并
- 2 天 14 小时
- 30 天内合并 PR
- 7
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openedx/XBlock 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
-
performance
难度 5/5 一周以上 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
[DEPR]: Support for XBlock Runtimes with raw string scope IDs可能已有人在做 @salman2013 于 211 天前认领。 未关闭depr
相似的 Issue
-
documentation
难度 1/5 1 小时以内 新手友好度 65/100
ansys/pydpf-core#3547 ·
维护者通常 1 天内回复
-
core
难度 2/5 1-3 小时 新手友好度 70/100
vectorize-io/hindsight#5457 ·
维护者通常 1 天内回复
-
[Bug]: LangChain drops OpenAI Responses text blocks from session recording可能已有人在做 @ktz03 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
volcengine/OpenViking#5806 ·
维护者通常 1 天内回复
-
HTML: <template> content is extracted as document text可能已有人在做 @ryanmeowy 今天认领。 未关闭bug html
难度 1/5 1 小时以内 新手友好度 82/100
docling-project/docling#4714 · 2 条评论 ·
维护者通常 1 天内回复
-
APIv2 event data accepts a non-string reply and a NaN upper_bound可能已有人在做 @awss1i 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
freedomofpress/securedrop#7946 · 1 条评论 ·
维护者通常 2 天内回复