Re: [Zope] How come you can't add a multiple selection property in a python script?
complaw@hal-pc.org writes:
How come this...
doc.manage_addProperty('specific_topics', specific_topics, 'multiple_selection', select_variable=context.list_of_selections)
.. won't work (it generates an error) when you try it from a python script. You pass in the *name* of the select variable, not the select variable itself...
Well, neither of these work... doc.manage_addProperty('specific_topics', specific_topics, 'multiple_selection', select_variable='list_of_selections') doc.manage_addProperty('specific_topics', specific_topics, type= 'multiple_selection', value='list_of_selections') ..(the latter was inspired after a look at the source code. Value is used at the point where the error message is generated). How is the association made between the select_variable and the property? Ron
complaw@hal-pc.org writes:
.... Well, neither of these work...
doc.manage_addProperty('specific_topics', specific_topics, 'multiple_selection', select_variable='list_of_selections')
doc.manage_addProperty('specific_topics', specific_topics, type= 'multiple_selection', value='list_of_selections')
In "OFS.PropertyManager._setProperty", I read: # for selection and multiple selection properties # the value argument indicates the select variable # of the property This implies: "value" contains the name of the select variable. Dieter
Dieter Maurer wrote:
complaw@hal-pc.org writes:
.... Well, neither of these work...
doc.manage_addProperty('specific_topics', specific_topics, 'multiple_selection', select_variable='list_of_selections')
doc.manage_addProperty('specific_topics', specific_topics, type= 'multiple_selection', value='list_of_selections')
In "OFS.PropertyManager._setProperty", I read:
# for selection and multiple selection properties # the value argument indicates the select variable # of the property
This implies: "value" contains the name of the select variable.
Thanks, Dieter. But for the record, I had "value" associated with the name of the variable. (Note the second try above). However, that didn't work either. I had read the source. Unfortunately, even after having read that, it still wouldn't work from a python script. I think there is something wrong here. Ron
complaw@hal-pc.org writes:
... "manage_addProperty" does not work with selection in Python Script ... The following Python Script works fine for me:
context.dd.manage_addProperty('new_property','selvar','selection') "selvar" in this case is a token property acquired by "context.dd". Dieter
participants (3)
-
complaw@hal-pc.org -
Dieter Maurer -
Ronald L. Chichester