ZCML
Directives to be used in ZCML.
These directives are all in the http://nextthought.com/ntp/ext namespace,
and are loaded using the meta.zcml file.
Example (non-sensical) of all the directives:
<configure xmlns:ext="http://nextthought.com/ntp/ext">
<include package="nti.externalization" file="meta.zcml" />
<ext:registerMimeFactories module="the.module" />
<ext:registerAutoPackageIO
root_interfaces="other_module.interfaces.IExtRoot"
modules="other_module.factories"
iobase="other_module.externalization.IOBase"
register_legacy_search_module="yes" />
<ext:classObjectFactory
factory="third_module.Factory"
name="AName" />
<ext:anonymousObjectFactory
factory="module3.Factory"
for="interfaces.ISchema"
field="field" />
<ext:anonymousObjectFactoryInPlace
for="interfaces.ISchema"
field="field2" />
</configure>
- interface IAnonymousObjectFactoryDirective[source]
Extends:
nti.externalization.zcml.IBaseAnonymousObjectFactoryDirectiveDefines the
ext:anonymousObjectFactorydirective.This directive registers a single
nti.externaliaztion.interfaces.IAnonymousObjectFactoryfor a single field used within a single object.Added in version 1.0a3.
- description
Description
Provides a description for the object.
- Implementation:
zope.configuration.fields.MessageID- Read Only:
False
- Required:
False
- Default Value:
None
- Allowed Type:
- factory
The class object that will be created.
- Implementation:
zope.configuration.fields.GlobalObject- Read Only:
False
- Required:
True
- Default Value:
None
- pass_external_object_to_factory
Pass the external object to the factory.
If true (not the default), then, the factory will recieve one argument, the anonymous external data. Otherwise, it gets no arguments.
- Implementation:
zope.configuration.fields.Bool- Read Only:
False
- Required:
False
- Default Value:
False
- Allowed Type:
- title
Title
Provides a title for the object.
- Implementation:
zope.configuration.fields.MessageID- Read Only:
False
- Required:
False
- Default Value:
None
- Allowed Type:
- interface IAnonymousObjectFactoryInPlaceDirective[source]
Extends:
nti.externalization.zcml.IBaseAnonymousObjectFactoryDirectiveDefines the
anonymousObjectFactoryInPlacedirective.This directive causes the external object itself to be used and updated in place. This is helpful when the object itself is not modelled, but its values are.
Such data might look like this:
{'home': {'MimeType': 'Address', ...}, 'work': {'MimeType': "Address', ...}}
And it might have a schema field that looks like this:
class IAddress(Interface): pass class IHasAddresses(Interface): addresses = Dict( title="A mapping of address objects.", key_type=TextLine(title="Adresss key"), value_type=Object(IAddress))
The ZCML would then look like this:
<ext:anonymoustObjectFactoryInPlace for="IHasAddresses" field="addresses" />
Added in version 1.0a3.
- interface IAutoPackageExternalizationDirective[source]
Defines the
ext:registerAutoPackageIOdirective.This directive combines the effects of
IRegisterInternalizationMimeFactoriesDirectivewith that ofautopackage, removing all need to repeat root interfaces and module names.After this directive is complete, a new class that descends from
AutoPackageSearchingScopedInterfaceObjectIOwill be registered as theIInternalObjectIOadapter for all of the root_interface objects, and the modules (or factory_modules) will be searched for object factories viaIRegisterInternalizationMimeFactoriesDirective.Changed in version 1.0: Add the register_legacy_search_module keyword argument, defaulting to False. Previously legacy search modules would always be registered, but now you must explicitly ask for it.
- factory_modules
If given, module names that should be searched for internalization factories.
If not given, all modules will be examined. If given, only these modules will be searched.
- Implementation:
zope.configuration.fields.Tokens- Read Only:
False
- Required:
False
- Default Value:
None
- Allowed Type:
Value Type
- Implementation:
zope.configuration.fields.GlobalObject- Read Only:
False
- Required:
True
- Default Value:
None
- iobase
If given, a base class that will be used. You can customize aspects of externalization that way.
This class should descend from
object, and it should implement the extension methods documented to customizeAutoPackageSearchingScopedInterfaceObjectIO.- Implementation:
zope.configuration.fields.GlobalObject- Read Only:
False
- Required:
False
- Default Value:
None
- modules
Module names that contain the implementations of the root_interfaces.
- Implementation:
zope.configuration.fields.Tokens- Read Only:
False
- Required:
True
- Default Value:
None
- Allowed Type:
Value Type
- Implementation:
zope.configuration.fields.GlobalObject- Read Only:
False
- Required:
True
- Default Value:
None
- register_legacy_search_module
Register found factories by their class name.
If true (not the default), then, in addition to registering factories by their mime type, also register them all by their class name. This is not recommended; currently no conflicts are caught and the order is ill-defined. See https://github.com/NextThought/nti.externalization/issues/33
- Implementation:
zope.configuration.fields.Bool- Read Only:
False
- Required:
False
- Default Value:
False
- Allowed Type:
- root_interfaces
The root interfaces defined by the package.
- Implementation:
zope.configuration.fields.Tokens- Read Only:
False
- Required:
True
- Default Value:
None
- Allowed Type:
Value Type
- Implementation:
zope.configuration.fields.GlobalInterface- Read Only:
False
- Required:
True
- Default Value:
None
Value Type
- Implementation:
- Read Only:
False
- Required:
True
- Default Value:
None
- interface IBaseAnonymousObjectFactoryDirective[source]
The common parts of anonymous object factory directives.
Added in version 1.0a3.
- field
The name of the schema field
The factory results will be assigned to this field.
- Implementation:
zope.configuration.fields.PythonIdentifier- Read Only:
False
- Required:
True
- Default Value:
None
- Allowed Type:
- for_
The interface that is the parent object this will be used for
- Implementation:
zope.configuration.fields.GlobalInterface- Read Only:
False
- Required:
True
- Default Value:
None
Value Type
- Implementation:
- Read Only:
False
- Required:
True
- Default Value:
None
- interface IClassObjectFactoryDirective[source]
Defines the
ext:classObjectFactorydirective.This directive registers a single
nti.externalization.interfaces.IClassObjectFactory.The factory will be registered for a class object.
- description
Description
Provides a description for the object.
- Implementation:
zope.configuration.fields.MessageID- Read Only:
False
- Required:
False
- Default Value:
None
- Allowed Type:
- factory
The class object that will be created.
This must define the
__external_can_create__attribute to be true.- Implementation:
zope.configuration.fields.GlobalObject- Read Only:
False
- Required:
True
- Default Value:
None
- name
The name for the factory.
If not given, the
__external_class_name__of the class will be used. If that’s not available, the__name__will be used.- Implementation:
zope.configuration.fields.PythonIdentifier- Read Only:
False
- Required:
False
- Default Value:
None
- Allowed Type:
- title
Title
Provides a title for the object.
- Implementation:
zope.configuration.fields.MessageID- Read Only:
False
- Required:
False
- Default Value:
None
- Allowed Type:
- interface IRegisterInternalizationMimeFactoriesDirective[source]
Defines the
ext:registerMimeFactoriesdirective.Poke through the classes defined in module. If a class defines the
mimeTypeattribute and can be created externally, (because it defines__external_can_create__to be true), registers a factory utility under themimeTypename. (For backwards compatibility,mime_typeis accepted if there is nomimeType.)Factories are discovered using
find_factories_in_module.See
nti.externalization.internalization.find_factory_for()for how factories are used.- module
Module to scan for Mime factories to add
- Implementation:
zope.configuration.fields.GlobalObject- Read Only:
False
- Required:
True
- Default Value:
None
- find_factories_in_module(module, case_sensitive=False)[source]
Look through the
varsof module to find any eligible factory functions.An eligible factory is a callable object with a True value for the attribute
__external_can_create__.If module is really a module, then only objects that are defined in that module will be found. Otherwise (module is some namespace object) any callable object is acceptable.
- Parameters:
case_sensitive (bool) – If False (the default), then the results will have each factory twice, once with its found name, and once with its name lower cased.
- Returns:
An iterable of found (name, factory).