{ "info": { "author": "Dieter Maurer", "author_email": "dieter@handshake.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Zope", "Framework :: Zope2", "Framework :: Zope :: 4", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "This package contains extensions for ``zope.schema``.\n\n=======\nModules\n=======\n\nverify\n======\n\nA companion to ``zope.interface.verify`` for the schema part of\ninterfaces.\n\nIt contains the function\n``verify_schema(``\\ *iface*, *obj*, *context*\\ ``=None``, *check_declaration*\\ ``=True)``\nwhich verifies that *obj* satisfies the schema part of interface *iface*.\nSchema fields need to get bound to a context before they can be validated.\n*context* specifies this context and defaults to *obj*.\n*check_declaration* checks that *obj* declares to provide *iface*.\n\nschema\n======\n\nThe main content is the mixin class ``SchemaConfigured``. It supports\nconfiguration according the schema part of the interfaces implemented\nby the ``SchemaConfigured`` derived class. If you want to\ncontrol from which interfaces the schema is derived,\nyou can use the class attribute ``SC_SCHEMAS``: its value should be\n``None`` (derive schema automatically from the implemented interfaces),\na single interface or a tuple of interfaces. Taking explicit control\nover the interfaces used to determine the schema is especially important\nfor Zope 2 schema configured content classes (as their base\nclass ``OFS.SimpleItem.SimpleItem`` implements a huge number of\ninterfaces whose fields you likely do not want in your schema).\n\nThe mixin class ``SchemaConfiguredEvolution`` provides support\nfor schema evolution for (ZODB) persistent objects. Its ``__setstate__``\nadds missing attributes to the object such that you can add new fields\nto your schema and still find all corresponding attributes on the\nrespective objects even when those have been created before the extension.\nNote: in order for ``SchemaConfiguredEvolution`` to be effective, it must\ncome early in the method resolution order (``mro``)\n(before ``persistent.Persistent``).\nThat's why is is a separate class and its feature not included\nin ``SchemaConfigured`` itself (there may be good reasons\nto have ``SchemaConfigured`` late in the ``mro``).\nAs an alternative to the use of ``SchemaConfiguredEvolution``,\nyou can use default values defined on class level for new fields.\n\nOccasionally, functions ``schemaitems`` and ``schemadict`` might be usefull.\nThey extract\nthe schema part of an interface or interface specification as\na list of id, field pairs or a dictionary, respectively.\n\nThe field ``Object`` is a replacement for ``zope.schema.Object``.\nIn former ``zope.schema`` versions, its ``Object``\nlacked field information in validation errors\n(https://bugs.launchpad.net/zope.schema/+bug/620324) which made identification\nof the affected fields unnecessarily difficult; this package's ``Object``\nwas designed to work around this bug.\nModern ``zope.schema`` versions have fixed the bug and\nthis package's ``Object`` now behaves almost as that of ``zope.schema``.\nHowever, it allows to suppress the check that the validated\nobject explicitely declares to provide the interface.\n``Object`` has the additional\nproperty ``check_declaration`` to control this (defaults to ``True``).\n\n\npropertymanager\n===============\n\nThis module implements a schema based ``OFS.PropertyManager.PropertyManager``\nsubclass. The ``_properties`` attribute describing the properties is\nnot maintained on the class or its instances but derived from\nthe provided (respectively implemented) schemas. For the moment,\nproperties cannot be extended on an instance based level (other than by\nproviding another schema).\n\n``zope.schema`` uses unicode to represent text. ``PropertyManager``\ncan in principle support unicode properties. However, due to a\nbug/weakness, the property management page handles them correctly\nonly, when ``management_page_charset`` is not defined or has\nvalue ``UTF-8`` (note the upper case spelling!). We use unicode\nproperties by default unless ``management_page_charset.upper()`` yields\na value different from ``UTF-8``. We also provide a mixin class\n``WorkaroundSpelling_management_page_charset`` to work around Zope's\nstupid insistence on upper case spelling for ``management_page_charset``.\n\nFor the moment, the following field types are supported:\n``Text``, ``TextLine``, ``Bytes``, ``BytesLine``, ``Bool``, ``Int``,\n``Float`` and ``List`` with a value type of ``TextLine`` or ``BytesLine``.\nOther types will raise ``NotImplementedError``.\n\nThe module has been implemented to leverage ``dm.zope.generate``.\nAn alternative would have been the implementation of the generation facilities\nbased on \"zope.formlib\" and the use of so called add forms. Depending\non experience, I may switch to this alternative.\n\n\nform\n====\n\nThe module defines default edit (``SchemaConfiguredEditForm``)\nand display (``SchemaConfiguredDisplayForm``) forms for\n``dm.zope.schema.schema.SchemaConfigured``.\n\nIt depends on ``zope.formlib``.\n\n\nwidget\n======\n\nProvides display and edit widgets for ``Timedelta`` fields,\na decent display widget for ``Password`` fields (the default\ndisplays passwords in cleartext) and an input widget for ``Password``\nthat does not force you to provide the password value whenever you edit the form.\n\nIt depends on ``zope.app.form`` in older Zope versions and on\n``zope.formlib`` in newer ones.\n\n\ntag\n===\n\nOften you would like to provide additional information for your fields -\nusually with effects to presentation. Unfortunately, ``zope.schema`` has\nforgotten this use case: it is really hard to give existing fields\nadditional properties.\n\nFortunately, `zope.schema` is build on top of `zope.interface` and it\nsupports so called \"tagged values\" to add additional information to\nits elements. This module uses this feature to provide additional information\nfor schema elements. As a matter of fact, it works for all schema elements,\nnot just fields.\n\nNote: If your schemas are used across different packages, ensure the\ntag names are sufficiently specific to avoid name clashes, e.g.\nby using an appropriate prefix.\n\n\ndataschema\n==========\n\n``zope.schema`` is nice to describe objects with attributes. But sometimes,\nyou would like to work with mappings whose keys are described by\na schema. This module contains auxiliary classes to bridge the gap\nbetween (schema controlled) objects and (schema controlled) mappings.\n\n``SchemaDict`` is a dictionary with keys described by a schema\nand ``MappingBySchema`` is a mixin class to provide a (schema controlled)\nmapping interface to an object.\n\n\nz2\n==\n\nThis subpackage combines schema related and\nZope2/Zope 4+ functionality. In newer Zope versions, it depends on\n``five.formlib`` (and, of course, on Zope2 or Zope 4+, respectively).\nNote that ``five.formlib`` was not yet Python 3 compatible when\nthis package has been released.\n\n\nform\n----\n\nThe module defines default edit (``SchemaConfiguredEditForm``)\nand display (``SchemaConfiguredDisplayForm``) forms for\n``dm.zope.schema.schema.SchemaConfigured`` for use in Zope2/Zope 4+.\n\nIt depends on ``zope.formlib``.\n\n\n\nconstructor\n-----------\n\nThis module contains an add form class ``SchemaConfiguredAddForm``\nand a factory ``add_form_factory``\nfor the generation of an add form (called \"constructor\" by Zope 2)\nfor ``dm.zope.schema.schema.SchemaConfigured`` based classes.\nThe generated add form is usually used as part of the ``constructors``\nparameter to ``registerClass``.\n\n``add_form_factory`` has the parameters:\n\n ============= =========================== ======================================\n name default description\n ============= =========================== ======================================\n *class_* the class to generate the form for\n *title* Create instance of *class_* the title shown in the form\n *description* *class_*\\ ``.__doc__`` the documentation shown in the form\n *form_class* ``SchemaConfiguredAddForm`` form class to be used\n ============= =========================== ======================================\n\n``add_form_factory`` generates a ``zope.formlib`` form with fields\ndefined by the implemented schemas of\n``dm.zope.schema.schema.SchemaConfigured`` class *class_*.\n\n\nThis module is similar to ``dm.zope.generate.constructor``. However,\nit works for ``SchemaConfigured`` based classes while the latter\nsupports ``PropertyManager`` based classes.\n\n\ntemplate\n--------\n\nProvides the view page template ``form_template`` able to view and edit\nZope2/Zope 4+\nschema configured content objects within the standard ZMI interface.\n\n\n\n========\nExamples\n========\n\nSetup: It defines two schemas ``S1`` and ``S2``, an\ninterface ``I`` and a class ``C`` deriving from ``SchemaConfigured``\nimplementing the schemas and the interface.\n\n>>> from zope.interface import Interface, implementer, providedBy\n>>> from zope.schema import Int\n>>> \n>>> from dm.zope.schema.schema import SchemaConfigured\n>>> from dm.zope.schema.verify import verify_schema\n>>> \n>>> class S1(Interface): i1 = Int(default=0)\n... \n>>> class S2(Interface): i2 = Int(default=1)\n... \n>>> class I(Interface):\n... def method(): pass\n... \n>>> @implementer(S1, S2, I)\n... class C(SchemaConfigured):\n... def method(self): pass\n... \n\n\n``C`` instances have attributes corresponding to the schema fields.\nIf no arguments are given for the constructor, they get the field default\nas value. Provided (keyword!) arguments override the defaults.\n\n>>> c = C()\n>>> c.i1\n0\n>>> c.i2\n1\n>>> c = C(i1=5)\n>>> c.i1\n5\n\nThe constructor rejects keyword arguments not defined in the schema\nin order to quickly detect spelling errors. However, this hampers\nthe use of ``super`` in the class hierarchy for the ``__init__`` method.\nMaybe, future versions will provide a means to control this check.\n\n>>> c = C(x=5)\nTraceback (most recent call last):\n ...\nTypeError: non schema keyword argument: x\n\nIf the field values are appropriate, ``C`` instances provide the\nschemas (as verified by ``verify_schema``). Otherwise, ``verify_schema``\nwill raise an exception.\n\nThis example demonstrates also the elementary use\nof ``verify_schema``. Note that ``verify_schema`` raises different\nexceptions in case of failure depending on the version of ``zope.schema``\n(``WrongContainedType`` in older version,\n``SchemaNotCorrectlyImplemented`` in newer versions).\n\n>>> verify_schema(S1, c)\n>>> c.i1=None\n>>> try: verify_schema(S1, c)\n... except Exception as e: e.args[0]\n[RequiredMissing('i1')]\n\n\nWe can also explicitely specify which schemas our class should\nsupport via the class variable ``SC_SCHEMA``.\n\n>>> class SC(SchemaConfigured):\n... SC_SCHEMAS = S1, S2\n...\n>>> sc = SC()\n>>> sc.i1\n0\n>>> sc.i2\n1\n>>> verify_schema(S1, sc, check_declaration=False)\n\n\n\nWe can create an edit (or display) form for our objects. Form fields\nare automatically created for our schema fields.\nThe form classes have a ``customize_fields`` method you can override\nto provide custom fields and/or widgets.\n\nSimilar functionality is available for Zope 2/Zope 4 in the ``z2`` subpackage.\n\n>>> from zope.publisher.browser import TestRequest\n>>> from dm.zope.schema.form import SchemaConfiguredEditForm\n>>>\n>>> form = SchemaConfiguredEditForm(c, TestRequest())\n>>> list([f.__name__ for f in form.form_fields])\n['i1', 'i2']\n\n\nSchemas describe a data model with properties relevant for either\ndocumentation, validation or the user interface. Occasionally,\nyou may want to use a schema for other purposes as well --\nand then, you may lack properties to satisfy the requirements.\nI ran into this for ``dm.zope.reseller`` where I wanted to\nuse schemas to also partially describe data models\nin a relational database. For this, I needed the concept\n\"informational field\" describing a field not directly stored in\nthe database but computed from other database fields.\nI used tagging as shown in the example below.\n\n>>> from dm.zope.schema.tag import Tagger\n>>> tag = Tagger(\"dm.zope.reseller\")\n>>> class S(Interface):\n... i1 = tag(Int(default=0), informational=True)\n... i2 = Int(default=1)\n... \n\nWe check for an informational field:\n\n>>> tag.get(S[\"i1\"], \"informational\")\nTrue\n>>> tag.get(S[\"i2\"], \"informational\")\n\nWe can also ask which tags are available:\n\n>>> tag.list(S[\"i1\"])\n['informational']\n\nIf we need to check for various tags on a field, we can wrap\nit and then access the tags with typical mapping methods.\n\n>>> te = tag.wrap(S[\"i1\"])\n>>> list(te)\n['informational']\n>>> te[\"informational\"]\nTrue\n>>> \"informational\" in te\nTrue\n>>> te.unwrap() is S[\"i1\"]\nTrue\n\n\n\n=======\nHistory\n=======\n\n4.0\n\n Now depends on ``zope.schema >= 4``.\n\n The ``schema`` module defines new fields ``FilesystemPath``\n and ``IriRef``.\n\n New module ``z2.schema`` defining new fields ``ItemName`` and\n ``ItemPath``. \n \n\n3.0\n\n Python3/Zope4 compatibility.\n Note that the subpackage ``z2`` depends on ``five.formlib``\n which was not yet Python 3 compatible when this version was\n released.\n\n Modern versions of ``zope.schema`` have removed a major weaknees\n of its ``Object`` field: its validation now registers for\n failing subfields the field name in the corresponding exception\n (usually in its `field` attribute). The ``Object`` field of this\n package has been changed in an incompatible way to match the\n ``zope.schema`` behaviour; its only difference is now that\n it allows to suppress the \"provides\" check.\n\n More examples and test resources.\n\n2.1\n\n Modules ``tag`` and ``dataschema``\n\n2.0\n\n form support\n\n Zope 2 constructor support", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://pypi.org/project/dm.zope.schema", "keywords": "application development zope schema", "license": "ZPL", "maintainer": "", "maintainer_email": "", "name": "dm.zope.schema", "package_url": "https://pypi.org/project/dm.zope.schema/", "platform": "", "project_url": "https://pypi.org/project/dm.zope.schema/", "project_urls": { "Homepage": "https://pypi.org/project/dm.zope.schema" }, "release_url": "https://pypi.org/project/dm.zope.schema/4.0/", "requires_dist": null, "requires_python": "", "summary": "'zope.schema' extensions", "version": "4.0" }, "last_serial": 4858793, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "db620c1879d19dae6cc6b62083b2feb2", "sha256": "aa89f693dabfe2eae1365fef68a6887e819be55e972064f8f5e4412ebf3e0eed" }, "downloads": -1, "filename": "dm.zope.schema-1.0.tar.gz", "has_sig": false, "md5_digest": "db620c1879d19dae6cc6b62083b2feb2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4860, "upload_time": "2010-08-19T12:02:53", "url": "https://files.pythonhosted.org/packages/b9/64/d935fefa7b59a4b023666f74e09f1bfe0d1062baaac92fe1d4ef84a668c3/dm.zope.schema-1.0.tar.gz" } ], "2.0": [ { "comment_text": "", "digests": { "md5": "51aca3ddcd616a15dfcd56e540491c62", "sha256": "6e27e0f4d4868603001548e53b991429bd92e626cbf492c00b71b7035ee86c00" }, "downloads": -1, "filename": "dm.zope.schema-2.0.tar.gz", "has_sig": false, "md5_digest": "51aca3ddcd616a15dfcd56e540491c62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17056, "upload_time": "2012-03-21T12:42:27", "url": "https://files.pythonhosted.org/packages/38/e3/17c6d2a85f55e50e62b16dacf6b39360015a154dc8d84ba87029fa142b4c/dm.zope.schema-2.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "a121f2cc0d8f64082d89244d01f4f697", "sha256": "04915b0a1477b34c3eaa2aed3abb6532f28b337600045b54b569887093ae7551" }, "downloads": -1, "filename": "dm.zope.schema-2.0.1.tar.gz", "has_sig": false, "md5_digest": "a121f2cc0d8f64082d89244d01f4f697", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17372, "upload_time": "2012-08-06T20:38:20", "url": "https://files.pythonhosted.org/packages/3c/db/3a2b7dbacaa19aa968e6154f7a3fbfa0767169672e01ae9e80c08d6426c7/dm.zope.schema-2.0.1.tar.gz" } ], "2.1": [ { "comment_text": "", "digests": { "md5": "64926236d4e0a11bb18e25b1dedf50bd", "sha256": "240641e86249efe422f4a047d7b11e7719b0b727b5fbfcede1985d380ff07dad" }, "downloads": -1, "filename": "dm.zope.schema-2.1.tar.gz", "has_sig": false, "md5_digest": "64926236d4e0a11bb18e25b1dedf50bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20074, "upload_time": "2014-04-15T18:45:44", "url": "https://files.pythonhosted.org/packages/9e/63/89084d6a98d7738dfed194ad3cfbca24d5700daa59977602daf0c52a40c2/dm.zope.schema-2.1.tar.gz" } ], "3.0": [ { "comment_text": "", "digests": { "md5": "36077723058edc947e44b62a877400c5", "sha256": "36b8657f85940a3275b40d6ebb4fe37929239b433598f48c8511915659152c61" }, "downloads": -1, "filename": "dm.zope.schema-3.0.tar.gz", "has_sig": false, "md5_digest": "36077723058edc947e44b62a877400c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24500, "upload_time": "2018-12-20T13:08:23", "url": "https://files.pythonhosted.org/packages/de/c5/03696b1effaf58f82d707f9be1e04844cd932dc60d7d88c0df210fb31e29/dm.zope.schema-3.0.tar.gz" } ], "3.0.1": [ { "comment_text": "", "digests": { "md5": "022b22b7c63e699472ecd5e9d9071697", "sha256": "948ceebea156ffff59a737c5930dba726f258b1c0faa7b7d66a6072b27de4206" }, "downloads": -1, "filename": "dm.zope.schema-3.0.1.tar.gz", "has_sig": false, "md5_digest": "022b22b7c63e699472ecd5e9d9071697", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24509, "upload_time": "2019-02-13T07:44:25", "url": "https://files.pythonhosted.org/packages/20/2b/284877e39b7bdfe650c3b2daaf80683235c26170485c5eff9e2d06232388/dm.zope.schema-3.0.1.tar.gz" } ], "4.0": [ { "comment_text": "", "digests": { "md5": "fd356d4b52a5a68c8cbd0224cdf0faf9", "sha256": "16d793cb1eb7a3e1480ae9a1d1db7195128c8cd0fcbdf566f1f399ee7e346023" }, "downloads": -1, "filename": "dm.zope.schema-4.0.tar.gz", "has_sig": false, "md5_digest": "fd356d4b52a5a68c8cbd0224cdf0faf9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25308, "upload_time": "2019-02-23T17:28:20", "url": "https://files.pythonhosted.org/packages/f1/f6/90644d4d9ef1689b7dfd57492ed2d4a174067d88ab96845aa376f68bce79/dm.zope.schema-4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fd356d4b52a5a68c8cbd0224cdf0faf9", "sha256": "16d793cb1eb7a3e1480ae9a1d1db7195128c8cd0fcbdf566f1f399ee7e346023" }, "downloads": -1, "filename": "dm.zope.schema-4.0.tar.gz", "has_sig": false, "md5_digest": "fd356d4b52a5a68c8cbd0224cdf0faf9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25308, "upload_time": "2019-02-23T17:28:20", "url": "https://files.pythonhosted.org/packages/f1/f6/90644d4d9ef1689b7dfd57492ed2d4a174067d88ab96845aa376f68bce79/dm.zope.schema-4.0.tar.gz" } ] }