Zope schema related support
nti.schema includes utilities for working with schema-driven development using zope.schema.
For complete details and the changelog, see the documentation.
Some of the most useful features include:
- nti.schema.interfaces.find_most_derived_interface for finding a bounded interface.
- nti.schema.eqhash.EqHash is a class-decorator for creating efficient, correct implementations of equality and hashing.
- nti.schema.field contains various schema fields, including a Variant type and more flexible collection types, all of which produce better validation errors.
- nti.schema.fieldproperty contains field properties that can adapt to interfaces or decode incoming text. The function createDirectFieldProperties can assign just the necessary properties automatically.
- StrippedValidTextLine should accept single character lines.
- Ensure StrippedValidTextLine correctly recognizes single character values as stripped. Previously, ‘b’ would have been rejected.
- JSON schemas report the schema for IObject fields and the schemas for the possible fields in IVariant.
- Fields in JSON schemas may specify a JSON-serializable dictionary to be passed as the application_info schema value. See issue 44.
- JSON schemas now output more constraints automatically. See issue 47.
- Add nti.schema.fieldproperty.field_name to compensate for the mangling that FieldPropertyStoredThroughField does.
- Fix Variant and other implementations of IFromObject to stop passing known non-text values to fromUnicode methods. This only worked with certain fields (such as zope.schema.Number) that could accept non-text values, usually by implementation accident, and could have surprising consequences. Instead, non-text values will be passed to the validate method.
- Fix Variant to stop double-validating values. The underlying fromUnicode, fromBytes or fromObject methods were supposed to already validate.
- Make VariantValidationError and Variant have more useful string representations.
- Make fromObject methods more gracefully handle an AttributeError raised by an underlying fromUnicode method on non-string input (such as None). This is especially helpful for Variant fields because they can catch the error and continue to the next field.
- Fix Variant, TupleFromObject, DictFromObject, ListFromObject and ListOrTupleFromObject to allow the missing_value (which defaults to None) in their fromObject methods; passing that value in simply returns it without raising an exception if the field is not required. If the field is required, a RequiredMissing is raised. Previously the sequences raised a WrongType error, while Variant may or may not have raised an error, depending on the underlying fields in use.
- Variant objects now automatically add fromObject support to ICollection and IMapping fields that do not already provide it, if their value_type (and key_type) qualify by being either an Object field, or something that provides IFromObject or can be made to, such as a collection or mapping.
- Add VariantValidationError, an error raised by variant fields when none of their constituent fields could adapt or validate the value.
- Add support for IFromBytes in zope.schema 4.8.0.
- The Variant and ListOrTupleFromObject, TupleFromObject, DictFromObject fields all have tweaked behaviour in fromObject. If the incoming value is a bytestring or text string, the underlying field’s fromBytes and fromUnicode will be called in preference to a fromObject, if that method is implemented.
- ValidSet and UniqueIterable now implement fromObject.
- All fields that implement fromObject now accept an Object field for their value_type (and key_type in the case of DictFromObject) and will attempt to adapt objects that do not provide the schema in fromObject.
- Adjust the deprecated zope.schema.interfaces.InvalidValue to be a simple alias for zope.schema.interfaces.InvalidValue (while preserving the constructor) for improved backwards compatibility.
- Add support for zope.schema 4.7.0; drop support for older versions.
- Make nti.schema.interfaces.InvalidValue a class again. It is deprecated. See issue 24.
- Drop support for dm.zope.schema fields, in particular the Object field. The validation performed by zope.schema.Object is much improved.
- Drop support for zope.schema older than 4.6.1.
- Deprecate nti.schema.field.Number.
- Add support for Python 3.7.
- Minor fix for changes in zope.schema 4.6.0 (import BeforeObjectAssignedEvent from its new, but still private, location).
- Depend on zope.deferredimport >= 4.2.1 to be able to generate Sphinx documentation.
- Clean up code to match PEP8.
- Fix an UnboundLocalError on Python 3 in the Variant field. See issue 14.
- Drop the Python 2 dependency on plone.i18n in favor of the new library nti.i18n, which supports Python 3. If plone.i18n is installed, it should not be configured (ZCML), but its utility objects can be looked up by either interface.
- Remove use of unicode_literals.
- Add support for Python 3.6.
- The SchemaConfigured constructor doesn’t hide errors when checking for properties on Python 2. See issue 11.
- Add info to minLength validation message.
- Add Acquisition and zope.event as install dependencies. Previously they were only pulled in via the test extra.
- Substantial speedups to the hash functions generated by EqHash.
- Substantial speedups to the equality functions generated by EqHash.
- Add support for Python 3. Note the countries vocabulary will not be complete on Python 3.
- Drop the dolmen.builtins dependency.
- Drop the dm.zope.schema dependency.
- The plone.i18n dependency is Python 2 only (and can even be removed).
- The matchers in nti.schema.testing have been moved to nti.testing.matchers.
- Using AdaptingFieldProperty will now raise the more specific SchemaNotProvided error instead of a TypeError if adapting the value fails.
- EqHash has moved from nti.schema.schema to nti.schema.eqhash. A compatibility shim remains.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash||File type||Python version||Upload date|
|nti.schema-1.13.1-py2.py3-none-any.whl (50.8 kB) View hashes||Wheel||py2.py3|
|nti.schema-1.13.1.tar.gz (52.1 kB) View hashes||Source||None|
Hashes for nti.schema-1.13.1-py2.py3-none-any.whl