nti.externalization.factory: Object factories

Implementations of object factories.

New in version 1.0.

class ObjectFactory(callable=None, title='', description='', interfaces=None)[source]

Bases: zope.component.factory.Factory

A convenient zope.component.interfaces.IFactory meant to be registered as a named utility.

The callable object SHOULD be a type/class object, because that’s the only thing we base equality off of (class identity).

This class can be subclassed and trivially instantiated by setting class properties default_factory and (optionally) default_title and default_description. Constructor arguments will override these, but if not given, the class values will be used.

For example:

>>> class MyObjectFactory(ObjectFactory):
...    default_factory = object
...    default_title = 'A Title'
...    default_description = 'A Description'
>>> factory = MyObjectFactory()
>>> factory 
<MyObjectFactory titled 'A Title' using <... 'object'> producing []>
>>> print(factory.title)
A Title
>>> print(factory.description)
A Description
default_description = u''

The default description, if none is given to the constructor.

default_factory = None

The default callable argument, if none is given to the constructor.

default_title = u''

The default title, if none is given to the constructor.

class MimeObjectFactory(callable=None, title='', description='', interfaces=None)[source]

Bases: nti.externalization.factory.ObjectFactory

Default implementation of IMimeObjectFactory.

class ClassObjectFactory(callable=None, title='', description='', interfaces=None)[source]

Bases: nti.externalization.factory.ObjectFactory

Default implementation of IClassObjectFactory.

class AnonymousObjectFactory(callable=None, title='', description='', interfaces=None)[source]

Bases: nti.externalization.factory.ObjectFactory

Default implementation of IAnonymousObjectFactory.

New in version 1.0a3.