[Zope-CMF] [dev] using newstyle content factories - a proposal
y.2006_ at wcm-solutions.de
Fri May 26 04:41:38 EDT 2006
In Zope there are two ways to register content classes and factories:
meta_type = 'Foo Type'
def manage_addFoo(folder, id):
ob = Foo(id)
# the meta_type attribute is added by registerClass
FooFactory = Factory(Foo)
Oldstyle factories are used this way::
dispatcher = folder.manage_addProduct['FooProduct']
And newstyle factories like this::
factory = getUtility(IFactory, 'fooproduct.foo')
ob = factory(id)
FactoryTypeInformation currently just supports oldstyle factories.
If the 'product' property of a type info instance is empty the 'factory'
property is interpreted as a newstyle factory ID.
Newstyle factories are placeless, they know nothing about the container
and can't add the objects themselves to the container. There are many
complex factories out there that can't be easily replaced by newstyle
factories. So we can't deprecate the old way - at least for now.
Any feedback is welcome. If there are no objections I'll check in the
proposed change on the trunk.
More information about the Zope-CMF