Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install dolmen.field

How to install dolmen.field

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install dolmen.field
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.3 Available View build log
Windows (64-bit)
0.3 Available View build log
Mac OS X (10.5+)
0.3 Available View build log
Linux (32-bit)
0.3 Available View build log
Linux (64-bit)
0.3 Available View build log
 
License
GPL
Imports
Lastest release
version 0.3 on Jan 5th, 2011

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(

System Message: ERROR/3 (<string>, line 36)

Inconsistent literal block quoting.

... 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(

System Message: ERROR/3 (<string>, line 46)

Inconsistent literal block quoting.

... 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

System Message: ERROR/3 (<string>, line 58)

Inconsistent literal block quoting.

None

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

>>> field._validate(Dummy)

System Message: ERROR/3 (<string>, line 63)

Inconsistent literal block quoting.

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)

System Message: ERROR/3 (<string>, line 75)

Inconsistent literal block quoting.

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)

This version is not compatible with the previous ones.

  • Refactored the field to use the 'schema' attribute instead of

System Message: WARNING/2 (<string>, line 98)

Bullet list ends without a blank line; unexpected unindent.

'interface'. The attribute name 'interface' was conflicting with other fields manipulating packages.

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

System Message: WARNING/2 (<string>, line 102)

Bullet list ends without a blank line; unexpected unindent.

readability.

0.2 (2009-06-09)
  • Initial Pypi release
0.1 (2009-05-03)
  • Internal release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:3

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.