[z3-five] ZCML initialization question
Rob Miller
ra at burningman.com
Sat Jun 11 07:50:34 CEST 2005
hi there,
i'm finally digging in to the z3/five world, have started playing around
w/ sidnei's "Fate" product
(https://svn.plone.org/svn/archetypes/Fate/trunk/) to use z3 views for
my custom archetypes objects.
i've managed to have some proof-of-concept success, using z3 addforms,
autogenerated from the AT schema, to instantiate AT objects. when i
tried to move from my proof-of-concept on to the actual project,
however, i started hitting some weird ZCML initialization errors.
i have a custom AT class called "OpenProject", which is a registered
content type within my "OpenPlans" product. in the OpenPlans
configure.zcml file, i've got the following tag, modeled after the
sample in Fate's configure.zcml:
<fate:addform
name="add_project"
for="Products.Fate.tests.sample.interfaces.IAdding"
permission="zope2.View"
product="OpenPlans"
meta_type="OpenProject"
/>
when i start zope, i'm getting a ZopeXMLConfigurationError with the
following error message:
ValueError: No archetype registered under the meta_type OpenProject
for OpenPlans
this is happening because Fate is doing an explicit check for this
content type when it's parsing the configuration files. it's raising
the exception when the following command fails:
type_info = getType(self.meta_type, self.product)
the thing is, if i remove the configure.zcml file and then restart zope,
after initialization has finished the above command actually works:
>>> from Products.Archetypes.ArchetypeTool import getType
>>> getType('OpenProject', 'OpenPlans')
{'name': 'OpenProject', 'package': 'OpenPlans', 'portal_type':
'OpenProject', 'module': <module 'Products.OpenPlans.content.project'
from '/Users/rob/devzope/Products/OpenPlans/content/project.pyc'>,
'meta_type': 'OpenProject', 'klass': <extension class
Products.OpenPlans.content.project.OpenProject at 3c24188>, 'signature':
"\xff>`\x08\x9e%\x872\xf1\xabx\x01#'e\x90", 'identifier': 'Openproject',
'type': <Schema instance at 3a1c500>, 'schema': <Schema instance at
3a1c500>}
so the problem seems to be that this content type has not yet been
initialized at the time when the zcml files are being parsed. i'm a
complete newbie when it comes to zcml... is there a way to delay the
initialization until after this content type has been registered? is
there a way to force AT to register this content type directly from the
zcml file? i'm at a loss re: how to proceed, since zcml is not python
none of my familiar debugging tools and techniques are available.
i know this is all a bit Fate-specific, but can anyone help point me in
the right direction re: how to debug and resolve a problem like this?
thx,
-r
More information about the z3-five
mailing list