[Zope-CMF] Formlib for folders
Charlie Clark
charlie at begeistert.org
Wed Feb 13 17:14:09 EST 2008
Am 13.02.2008 um 13:16 schrieb Wichert Akkerman:
> vocabulary factories take a context as argument.
>
> This vocabulary is already implemented in plone.app.vocabularies, you
> can just use that:
> http://dev.plone.org/plone/browser/plone.app.vocabularies/trunk/plone/app/vocabularies/types.py
Thanks very much for this. Would it be possible to include the two
portal_types vocabularies in CMFDefault?
I got the vocabulary in my view class but then I got an Assertion
Error relating to it:
2008-02-13 21:16:34 ERROR Zope.SiteErrorLog http://localhost:8080/new/b/@@edit.html
Traceback (innermost last):
Module ZPublisher.Publish, line 119, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 42, in call_object
Module zope.formlib.form, line 769, in __call__
Module Products.Five.formlib.formbase, line 55, in update
Module zope.formlib.form, line 732, in update
Module Products.camaoCms.browser.masterpage, line 86, in setUpWidgets
Module Products.CMFDefault.formlib.form, line 117, in setUpWidgets
Module zope.formlib.form, line 379, in setUpEditWidgets
Module zope.schema._field, line 244, in bind
AssertionError
Looking at the source:
def bind(self, object):
"""See zope.schema._bootstrapinterfaces.IField."""
clone = super(Choice, self).bind(object)
# get registered vocabulary if needed:
if IContextSourceBinder.providedBy(self.vocabulary):
clone.vocabulary = self.vocabulary(object)
assert ISource.providedBy(clone.vocabulary)
elif clone.vocabulary is None and self.vocabularyName is not
None:
vr = getVocabularyRegistry()
clone.vocabulary = vr.get(object, self.vocabularyName)
assert ISource.providedBy(clone.vocabulary)
looks like I'm a victiom of copy & paste programming (again! ;-) The
vocabulary definitely doesn't provide ISource but I can't seem to get
this to work: either by adding it as a parameter to implements() or in
ZCML leads to a lookup error:
ComponentLookupError: (<InterfaceClass
zope.schema.interfaces.IVocabularyFactory>,
'cmf.UserFriendlyContentTypes')
mm, guess I need to double check my declarations. I thought that
implements(IMyInterface)
is equivalent to provides="...IMyInterface" in ZCML
BTW. this is probably academic but I noticed the top of the types.py is
from zope.app.schema.vocabulary import IVocabularyFactory
Is there a reason for not importing the interface directly?
I'll also be reading up ISource in Philip's book.
Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226
More information about the Zope-CMF
mailing list