[Zope3-Users] Vocabularies and Zope3-svn
Frank Burkhardt
fbo2 at gmx.net
Tue Mar 21 07:34:01 EST 2006
Hi,
I've got some simple vocabularies like this one:
[vocabularies.py]
class RedirectTargetTypes(SimpleVocabulary):
def __init__(self,context):
targettypes={
'generic url':_(u"Arbitrary URL"),
'local uid':_(u"Local UID or Permalink"),
'local url':_(u"Local URL reference")
}
terms=[SimpleTerm(code,title=title) for (code,title) in targettypes.items()]
SimpleVocabulary.__init__(self,terms)
[configure.zcml]
<vocabulary
factory=".redirect.vocabularies.RedirectTargetTypes"
name="Redirect targets"
/>
After the latest svn-update, I always get this warning:
/var/lib/zope3/instance/mpgsite-test/lib/python/redirect/configure.zcml:26:
DeprecationWarning: The 'vocabulary' directive has been deprecated and will
be removed in Zope 3.5. Use the 'utility' directive instead to register the
class as a named utility:
<utility
provides="zope.app.schema.interfaces.IVocabularyFactory"
component="redirect.vocabularies.RedirectTargetTypes"
name="Redirect targets"
/>
<vocabulary
Unfortunately, when replacing the old 'vocabulary' by the new 'utility' directive,
I get this error:
File "/opt/zope3-svn/zope3/src/zope/component/site.py", line 241, in provideUtility
raise Invalid("The registered component doesn't provide "
zope.configuration.config.ConfigurationExecutionError: zope.component.interfaces.Invalid:
The registered component doesn't provide the promised interface.
in:
File "/var/lib/zope3/instance/mpgsite-test/lib/python/redirect/configure.zcml", line 26.1-30.3
<utility
component=".redirect.vocabularies.RedirectTargetTypes"
provides="zope.app.schema.interfaces.IVocabularyFactory"
name="Redirect targets"
/>
I tried some hours modifying the "RedirectTargetTypes" class with implements
and classProvides but it didn't work. How am I supposed to write a simple
vocabulary the new way? Will it be 100% "compatible" to old style vocabularies
(e.g. run on Zope 3.2)?
Regards,
Frank
More information about the Zope3-users
mailing list