{ "info": { "author": "edX", "author_email": "oscm@edx.org", "bugtrack_url": null, "classifiers": [ "Framework :: Django :: 1.11", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython" ], "description": "xblock-utils: Various utilities for XBlocks\n===========================================\n\nThese are a collection of useful utility functions,\ntest base classes and documentation shared by many XBlocks.\n(Especially those of `edx-solutions`_.)\n\n.. _edx-solutions: https://github.com/edx-solutions\n\n\nTo test the utilities, run::\n\n make test\n\nTo get a coverage report, use::\n\n tox -- --cover-html\n\n\nStudioEditableXBlockMixin\n-------------------------\n\n.. code:: python\n\n from xblockutils.studio_editable import StudioEditableXBlockMixin\n\nThis mixin will automatically generate a working ``studio_view`` form\nthat allows content authors to edit the fields of your XBlock. To use,\nsimply add the class to your base class list, and add a new class field\ncalled ``editable_fields``, set to a tuple of the names of the fields\nyou want your user to be able to edit.\n\n.. code:: python\n\n @XBlock.needs(\"i18n\")\n class ExampleBlock(StudioEditableXBlockMixin, XBlock):\n ...\n mode = String(\n display_name=\"Mode\",\n help=\"Determines the behaviour of this component. Standard is recommended.\",\n default='standard',\n scope=Scope.content,\n values=('standard', 'crazy')\n )\n editable_fields = ('mode', 'display_name')\n\nThat's all you need to do. The mixin will read the optional\n``display_name``, ``help``, ``default``, and ``values`` settings from\nthe fields you mention and build the editor form as well as an AJAX save\nhandler.\n\nIf you want to validate the data, you can override\n``validate_field_data(self, validation, data)`` and/or\n``clean_studio_edits(self, data)`` - see the source code for details.\n\nSupported field types:\n\n* Boolean:\n ``field_name = Boolean(display_name=\"Field Name\")``\n* Float:\n ``field_name = Float(display_name=\"Field Name\")`` \n* Integer:\n ``field_name = Integer(display_name=\"Field Name\")`` \n* String:\n ``field_name = String(display_name=\"Field Name\")`` \n* String (multiline):\n ``field_name = String(multiline_editor=True, resettable_editor=False)``\n* String (html):\n ``field_name = String(multiline_editor='html', resettable_editor=False)``\n\nAny of the above will use a dropdown menu if they have a pre-defined\nlist of possible values.\n\n* List of unordered unique values (i.e. sets) drawn from a small set of\n possible values:\n ``field_name = List(list_style='set', list_values_provider=some_method)``\n\n - The ``List`` declaration must include the property ``list_style='set'`` to\n indicate that the ``List`` field is being used with set semantics.\n - The ``List`` declaration must also define a ``list_values_provider`` method\n which will be called with the block as its only parameter and which must\n return a list of possible values.\n* Rudimentary support for Dict, ordered List, and any other JSONField-derived field types\n\n - ``list_field = List(display_name=\"Ordered List\", default=[])``\n - ``dict_field = Dict(display_name=\"Normal Dict\", default={})``\n\nSupported field options (all field types):\n\n* ``values`` can define a list of possible options, changing the UI element\n to a select box. Values can be set to any of the formats `defined in the\n XBlock source code `__:\n\n - A finite set of elements: ``[1, 2, 3]``\n - A finite set of elements where the display names differ from the values::\n\n [\n {\"display_name\": \"Always\", \"value\": \"always\"},\n {\"display_name\": \"Past Due\", \"value\": \"past_due\"},\n ]\n - A range for floating point numbers with specific increments:\n ``{\"min\": 0 , \"max\": 10, \"step\": .1}``\n - A callable that returns one of the above. (Note: the callable does\n *not* get passed the XBlock instance or runtime, so it cannot be a\n normal member function)\n* ``values_provider`` can define a callable that accepts the XBlock\n instance as an argument, and returns a list of possible values in one\n of the formats listed above.\n* ``resettable_editor`` - defaults to ``True``. Set ``False`` to hide the\n \"Reset\" button used to return a field to its default value by removing\n the field's value from the XBlock instance.\n\nBasic screenshot: |Screenshot 1|\n\nStudioContainerXBlockMixin\n--------------------------\n\n.. code:: python\n\n from xblockutils.studio_editable import StudioContainerXBlockMixin\n\nThis mixin helps to create XBlocks that allow content authors to add,\nremove, or reorder child blocks. By removing any existing\n``author_view`` and adding this mixin, you'll get editable,\nre-orderable, and deletable child support in Studio. To enable authors to\nadd arbitrary blocks as children, simply override ``author_edit_view`` \nand set ``can_add=True`` when calling ``render_children`` - see the \nsource code. To restrict authors so they can add only specific types of\nchild blocks or a limited number of children requires custom HTML.\n\nAn example is the mentoring XBlock: |Screenshot 2|\n\nSeleniumXBlockTest\n------------------\n\n.. code:: python\n\n from xblockutils.base_test import SeleniumXBlockTest\n\nThis is a base class that you can use for writing Selenium integration\ntests that are hosted in the XBlock SDK (Workbench).\n\nHere is an example:\n\n.. code:: python\n\n class TestStudentView(SeleniumXBlockTest):\n \"\"\"\n Test the Student View of MyCoolXBlock\n \"\"\"\n def setUp(self):\n super(TestStudentView, self).setUp()\n self.set_scenario_xml('')\n self.element = self.go_to_view(\"student_view\")\n\n def test_shows_field_2(self):\n \"\"\"\n The xblock should display the text value of field2.\n \"\"\"\n self.assertIn(\"hello\", self.element.text)\n\nStudioEditableBaseTest\n----------------------\n\n.. code:: python\n\n from xblockutils.studio_editable_test import StudioEditableBaseTest\n\nThis is a subclass of ``SeleniumXBlockTest`` that adds a few helper\nmethods useful for testing the ``studio_view`` of any XBlock using\n``StudioEditableXBlockMixin``.\n\nchild\\_isinstance\n-----------------\n\n.. code:: python\n\n from xblockutils.helpers import child_isinstance\n\nIf your XBlock needs to find children/descendants of a particular\nclass/mixin, you should use\n\n.. code:: python\n\n child_isinstance(self, child_usage_id, SomeXBlockClassOrMixin)\n\nrather than calling\n\n.. code:: python\n\n ``isinstance(self.runtime.get_block(child_usage_id), SomeXBlockClassOrMixin)``.\n\nOn runtimes such as those in edx-platform, ``child_isinstance`` is\norders of magnitude faster.\n\n.. |Screenshot 1| image:: https://cloud.githubusercontent.com/assets/945577/6341782/7d237966-bb83-11e4-9344-faa647056999.png\n.. |Screenshot 2| image:: https://cloud.githubusercontent.com/assets/945577/6341803/d0195ec4-bb83-11e4-82f6-8052c9f70690.png\n\nXBlockWithSettingsMixin\n-----------------------\n\nThis mixin provides access to instance-wide XBlock-specific configuration settings.\nSee [wiki page](https://github.com/edx/xblock-utils/wiki/Settings-and-theme-support#accessing-xblock-specific-settings) for details\n\nThemableXBlockMixin\n-------------------\n\nThis mixin provides XBlock theming capabilities built on top of XBlock-specific settings.\nSee [wiki page](https://github.com/edx/xblock-utils/wiki/Settings-and-theme-support#theming-support) for details\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/edx/xblock-utils", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "xblock-utils", "package_url": "https://pypi.org/project/xblock-utils/", "platform": "", "project_url": "https://pypi.org/project/xblock-utils/", "project_urls": { "Homepage": "https://github.com/edx/xblock-utils" }, "release_url": "https://pypi.org/project/xblock-utils/1.2.2/", "requires_dist": [ "mako", "XBlock", "futures ; python_version == \"2.7\"" ], "requires_python": "", "summary": "Various utilities for XBlocks", "version": "1.2.2" }, "last_serial": 5640761, "releases": { "1.2.0": [ { "comment_text": "", "digests": { "md5": "2ddb2e856378ea10bac187a305d686c2", "sha256": "fd42effb227a4d2f2f385e2ea6e2880a2342d631e58f35d990d8a603ca32606e" }, "downloads": -1, "filename": "xblock_utils-1.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2ddb2e856378ea10bac187a305d686c2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 32171, "upload_time": "2018-07-27T19:29:22", "url": "https://files.pythonhosted.org/packages/89/84/4f92626ef1e0df13b43b7e73d03d9e3a5e6e62001775331f922e7ef09531/xblock_utils-1.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7c1428d03a814c314987ae8b6534cdb", "sha256": "c006282cd3fcde9ac175b8659568832dfa32f1537e60223c633c0c2cfe9e41b2" }, "downloads": -1, "filename": "xblock-utils-1.2.0.tar.gz", "has_sig": false, "md5_digest": "a7c1428d03a814c314987ae8b6534cdb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27052, "upload_time": "2018-07-27T19:29:23", "url": "https://files.pythonhosted.org/packages/71/60/8618c9b6a9e537ea7eaabf6be095d295da45e7bd9c2b91eb493ecc5a6bdf/xblock-utils-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "5873be9709f4aaf1092d1e7a783279f5", "sha256": "80782a2239b898601b5a9f1d0a9796898b5d0c505b04ea9e341df6c70ce97555" }, "downloads": -1, "filename": "xblock_utils-1.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "5873be9709f4aaf1092d1e7a783279f5", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 39370, "upload_time": "2019-04-03T19:30:58", "url": "https://files.pythonhosted.org/packages/8d/84/55a5ce0b2addf4ae67314c6a6fb24751be4389b4c4f8b542b68cf23498ab/xblock_utils-1.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f91bc679d78ca2f093131197d308e68e", "sha256": "2c56100e8b312f5bdb8e4bbcb58ffd27911b9f89f0507cf39d3b94713b10823c" }, "downloads": -1, "filename": "xblock_utils-1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f91bc679d78ca2f093131197d308e68e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 39368, "upload_time": "2019-04-03T19:31:18", "url": "https://files.pythonhosted.org/packages/7f/5f/a5b9e7d4a63c99119c5813eaef5cc1e2274d18577323943702b169c0e8e9/xblock_utils-1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a3234c1bee04efb94349aa376d6d1b97", "sha256": "3bc9c853dc3e5a8a5c63f7d09f889db7f89fbf9d6234ba84a068503760390fa1" }, "downloads": -1, "filename": "xblock-utils-1.2.1.tar.gz", "has_sig": false, "md5_digest": "a3234c1bee04efb94349aa376d6d1b97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22883, "upload_time": "2019-04-03T19:31:00", "url": "https://files.pythonhosted.org/packages/e1/55/4e0c4a6a46dc56a1b54105533d2a6a6704bdd57e061605443c844e6c9c2f/xblock-utils-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "9aff12b770c09dae37ce9064f0be22a1", "sha256": "721ea8294432fccae5024c12cd1b19854c99fc54925e11c5975f2cb43a616f46" }, "downloads": -1, "filename": "xblock_utils-1.2.2-py2-none-any.whl", "has_sig": false, "md5_digest": "9aff12b770c09dae37ce9064f0be22a1", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 39400, "upload_time": "2019-08-06T16:53:04", "url": "https://files.pythonhosted.org/packages/44/98/c020c8d17aabb18de8091ffd34b5993ec517741efc6f7d7fd1d811eca62a/xblock_utils-1.2.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5134f6697dddaf230703c09a21515f1f", "sha256": "570d1f519772ccf06d438a446b19193f271de16267b345eafd15ea93ef947a54" }, "downloads": -1, "filename": "xblock_utils-1.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "5134f6697dddaf230703c09a21515f1f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 39401, "upload_time": "2019-08-06T16:53:16", "url": "https://files.pythonhosted.org/packages/54/0a/5e16e8698e69a014b4743887e12118da38cd93947ee0037a6fdac3d8fc89/xblock_utils-1.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b2acc5771c73a3f6937b25bb532c37f1", "sha256": "accbacbb73c919fb473992c4cebe40b3468e73679487830a79770b8b0b744236" }, "downloads": -1, "filename": "xblock-utils-1.2.2.tar.gz", "has_sig": false, "md5_digest": "b2acc5771c73a3f6937b25bb532c37f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22903, "upload_time": "2019-08-06T16:53:06", "url": "https://files.pythonhosted.org/packages/88/69/2f131861ba0986efec3616e87849705aa538d124e012eee802bf944fe91c/xblock-utils-1.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9aff12b770c09dae37ce9064f0be22a1", "sha256": "721ea8294432fccae5024c12cd1b19854c99fc54925e11c5975f2cb43a616f46" }, "downloads": -1, "filename": "xblock_utils-1.2.2-py2-none-any.whl", "has_sig": false, "md5_digest": "9aff12b770c09dae37ce9064f0be22a1", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 39400, "upload_time": "2019-08-06T16:53:04", "url": "https://files.pythonhosted.org/packages/44/98/c020c8d17aabb18de8091ffd34b5993ec517741efc6f7d7fd1d811eca62a/xblock_utils-1.2.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5134f6697dddaf230703c09a21515f1f", "sha256": "570d1f519772ccf06d438a446b19193f271de16267b345eafd15ea93ef947a54" }, "downloads": -1, "filename": "xblock_utils-1.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "5134f6697dddaf230703c09a21515f1f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 39401, "upload_time": "2019-08-06T16:53:16", "url": "https://files.pythonhosted.org/packages/54/0a/5e16e8698e69a014b4743887e12118da38cd93947ee0037a6fdac3d8fc89/xblock_utils-1.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b2acc5771c73a3f6937b25bb532c37f1", "sha256": "accbacbb73c919fb473992c4cebe40b3468e73679487830a79770b8b0b744236" }, "downloads": -1, "filename": "xblock-utils-1.2.2.tar.gz", "has_sig": false, "md5_digest": "b2acc5771c73a3f6937b25bb532c37f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22903, "upload_time": "2019-08-06T16:53:06", "url": "https://files.pythonhosted.org/packages/88/69/2f131861ba0986efec3616e87849705aa538d124e012eee802bf944fe91c/xblock-utils-1.2.2.tar.gz" } ] }