Skip to main content

dolmen.field

The dolmen.field package provides additional generic fields to extend zope.schema.

Configuration fields

The configuration fields are used for description and constraints, to impose a consistent schema and data model.

GlobalClass

GlobalClass is a field requiring a valid Interface class. It can be used for factories and other components that need to store an interface with the possibility to check and verify the consistency of the given value:

>>> from zope.interface import Interface
>>> from dolmen.field import GlobalClass, IClassField

>>> class IDummy(Interface):
...     def shall_fail():
...         pass

>>> class Dummy(object):
...     pass

Of course, it must be a valid interface:

>>> field = GlobalClass(
...             title=u'a class field',
...             schema=object
...             )
Traceback (most recent call last):
...
WrongType: <type 'object'> is not a valid Interface

The interface will be used to validate the class:

>>> field = GlobalClass(
...             title=u'a class field',
...             schema=IDummy
...             )

>>> field.schema
<InterfaceClass dolmen.field.tests.IDummy>
>>> IClassField.providedBy(field)
True

We make sure the interface attribute is not touched:

>>> print field.interface
None

In a first time, we make sure the class implements the needed interface:

>>> field._validate(Dummy)
Traceback (most recent call last):
...
ConstraintNotSatisfied: <class 'dolmen.field.tests.Dummy'> does not implement <InterfaceClass dolmen.field.tests.IDummy>

>>> from zope.interface import classImplements
>>> classImplements(Dummy, IDummy)
>>> IDummy.implementedBy(Dummy)
True

Then the interface acts as a strict validator:

>>> field._validate(Dummy)
Traceback (most recent call last):
...
BrokenImplementation: An object has failed to implement interface <InterfaceClass dolmen.field.tests.IDummy>
<BLANKLINE>
The shall_fail attribute was not provided.
<BLANKLINE>

>>> Dummy.shall_fail = lambda x: u'not'
>>> field._validate(Dummy) is None
True

Changelog

0.3 (2009-10-25)

  • Refactored the field to use the ‘schema’ attribute instead of ‘interface’. The attribute name ‘interface’ was conflicting with other fields manipulating packages.

  • Now using a README.txt instead of inline doctests, for more readability.

0.2 (2009-06-09)

  • Initial Pypi release

0.1 (2009-05-03)

  • Internal release

Metadata

Release files for dolmen.field 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dolmen.field 0.3
File Size Uploaded Provenance Actions
dolmen.field-0.3.tar.gz 3.7 kB Without provenance Details for dolmen.field-0.3.tar.gz

Release files / dolmen.field-0.3.tar.gz

Download URL dolmen.field-0.3.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c42446b44628d36be6bfe85cc89a35936d5adccf13ff4f71ed384e3814cb25d6
BLAKE2b-256 checksum
How to use checksums
c18a9d35e951bb0fa8601ce4d1ab695812cd07cf3ef3a0e7089e8d10fb3c6590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for dolmen.field 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page