[Zope-dev] OrderedMultiSelectWidget in Zope2: context weirdness?
Josh Johnson (jjmojojjmojo)
joshjohnson.cpc at gmail.com
Thu May 8 13:39:41 EDT 2008
I'm looking at the code for OrderedMultiSelectWidget, in
zope.app.form.browser.itemswidgets (line 535).
This code doesn't make sense to me:
if hasattr(self.context.context, self.context.__name__):
available_values = self.context.get(self.context.context)
else:
available_values = []
From what I can tell, this code is grabbing anything on the current
content/view that's named the same as the name of the vocabulary
provider. This bit me earlier with this error:
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 770, in __call__
Module zope.formlib.form, line 764, in render
Module plone.app.form._named, line 26, in __call__
Module Shared.DC.Scripts.Bindings, line 313, in __call__
Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
Module Products.PageTemplates.PageTemplateFile, line 129, in _exec
Module Products.PageTemplates.PageTemplate, line 89, in pt_render
Module zope.pagetemplate.pagetemplate, line 117, in pt_render
Module zope.tal.talinterpreter, line 271, in __call__
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 891, in do_useMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 891, in do_useMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 957, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 861, in do_defineMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 949, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 949, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 861, in do_defineMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 861, in do_defineMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 957, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 534, in do_optTag_tal
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 824, in do_loop_tal
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
Module Products.PageTemplates.Expressions, line 221, in evaluateStructure
Module zope.tales.tales, line 696, in evaluate
- URL: pageform
- Line 104, Column 10
- Expression: <PathExpr standard:'widget'>
- Names:
{'container': <PloneSite at /plone>,
'context': <PloneSite at /plone>,
'default': <object object at 0xb7dd6528>,
'here': <PloneSite at /plone>,
'loop': {'widget':
<Products.PageTemplates.Expressions.PathIterator object at 0xb248fd8c>},
'nothing': None,
'options': {'args': ()},
'repeat': <Products.PageTemplates.Expressions.SafeMapping object
at 0xb249e32c>,
'request': <HTTPRequest, URL=http://xxxxxxxxxxxxxxxxxxxxx>,
'root': <Application at >,
'template': <ImplicitAcquirerWrapper object at 0xb249e2ac>,
'traverse_subpath': [],
'user': <PropertiedUser 'admin'>,
'view': <Products.Five.metaclass.ImportActivitiesView object at
0xb244898c>,
'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper
object at 0xb249e2cc>}
Module zope.tales.expressions, line 217, in __call__
Module Products.PageTemplates.Expressions, line 161, in _eval
Module Products.PageTemplates.Expressions, line 123, in render
Module zope.app.form.browser.itemswidgets, line 568, in __call__
Module zope.app.pagetemplate.viewpagetemplatefile, line 83, in __call__
Module zope.app.pagetemplate.viewpagetemplatefile, line 51, in __call__
Module zope.pagetemplate.pagetemplate, line 117, in pt_render
Module zope.tal.talinterpreter, line 271, in __call__
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 822, in do_loop_tal
Module zope.tales.tales, line 682, in setRepeat
Module zope.tales.tales, line 696, in evaluate
- URL:
/xxxxxxxxxxxxxxxxx/parts/zope2/lib/python/zope/app/form/browser/orderedSelectionList.pt
- Line 146, Column 8
- Expression: <PathExpr standard:u'view/choices'>
- Names:
{'args': (),
'context': <zope.schema._field.List object at 0xb244816c>,
'default': <object object at 0xb7dd6528>,
'loop': {},
'nothing': None,
'options': {},
'repeat': {},
'request': <HTTPRequest, URL=http://xxxxxxxxxxxxxxxxxxxxxxxxxx>,
'template':
<zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile object
at 0xb634682c>,
'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object at
0xb24b966c>,
'view':
<zope.app.form.browser.itemswidgets.OrderedMultiSelectWidget object at
0xb249e16c>,
'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper
object at 0xb24b938c>}
Module zope.tales.expressions, line 217, in __call__
Module zope.tales.expressions, line 211, in _eval
Module zope.app.form.browser.itemswidgets, line 547, in choices
TypeError: iterable argument required
I had a named utility that was mapped to a function called 'activities'
which provides IVocabularyFactory. I had a browser form page that had a
field in it that used that named utility. The form class had a method on
it called 'activities'. Through some pdb digging, I was able to figure
out that it was grabbing the view method and not the function. It makes
sense looking at the code, but why would it work that way? Am I looking
at this wrong, or is this a bug?
My setup :
Plone 3.0.6 (according to Plone control pannel.. it's supposed to be 3.1.1)
CMF 2.1.1
Zope (Zope 2.10.5-final, python 2.4.3, linux2)
Python 2.4.3 (#2, Mar 7 2008, 01:58:20) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)]
PIL 1.1.5
Five 1.5.6
I can put together some example code to reproduce the issue, if necessary.
Thanks,
JJ
More information about the Zope-Dev
mailing list