[Zope] manageAddProperty for a Multiple Selection in a Python Script

complaw@hal-pc.org complaw@hal-pc.org
Tue, 29 Jan 2002 20:07:48 GMT


I also tried the code...
> 
my_obj = getattr(context, id)
my_obj.manageAddProperty('my_keywords', user_keywords, 'multiple selection',
context.select_keywords)
 
.. which, when run, prompted the following error message:


                                Zope Error

                                Zope has encountered an error while publishing
this resource.

                                Error Type: Bad Request
                                Error Value: No select variable ['Censorship']

[Snip]


Traceback (innermost last):
  File /usr/local/zope/Zope-2.4.3-src/lib/python/ZPublisher/Publish.py, line
223, in publish_module
  File /usr/local/zope/Zope-2.4.3-src/lib/python/ZPublisher/Publish.py, line
187, in publish
  File /usr/local/zope/Zope-2.4.3-src/lib/python/Zope/__init__.py, line 226, in
zpublisher_exception_hook
    (Object: links)
  File /usr/local/zope/Zope-2.4.3-src/lib/python/ZPublisher/Publish.py, line
171, in publish
  File /usr/local/zope/Zope-2.4.3-src/lib/python/ZPublisher/mapply.py, line 160,
in mapply
    (Object: addLink)
  File /usr/local/zope/Zope-2.4.3-src/lib/python/ZPublisher/Publish.py, line
112, in call_object
    (Object: addLink)
  File /usr/local/zope/Zope-2.4.3-src/lib/python/Shared/DC/Scripts/Bindings.py,
line 324, in __call__
    (Object: addLink)
  File /usr/local/zope/Zope-2.4.3-src/lib/python/Shared/DC/Scripts/Bindings.py,
line 354, in _bindAndExec
    (Object: addLink)
  File
/usr/local/zope/Zope-2.4.3-src/lib/python/Products/PythonScripts/PythonScript.py,
line 363, in _exec
    (Object: addLink)
    (Info: ({'script': <PythonScript instance at fe0ada8>, 'context': <Folder
instance at a5e7480>, 'container': <Folder instance at a5e7480>,
'traverse_subpath': []}, ('Test', 'http://', ' Add the New Link ',
['Censorship']), {}, ([],)))
  File Script (Python), line 40, in addLink
  File /usr/local/zope/Zope-2.4.3-src/lib/python/OFS/PropertyManager.py, line
320, in manage_addProperty
    (Object: z_20020129210657_695690639821)
  File /usr/local/zope/Zope-2.4.3-src/lib/python/OFS/PropertyManager.py, line
247, in _setProperty
    (Object: z_20020129210657_695690639821)
Bad Request: (see above)




> A python script is attempting to add a DTML Document to a folder.  The folder
> has a property called "select_keywords" which, as the name implies, is a list
of
> keywords for the user.  
> 
> A form is in the folder to allow the user to add informaiton.  In the form is
a
> list of the keywords from the select_keywords property of the form (the
> parameter is called 'user_keywords').  The user can then select the
appropriate
> keywords and press the Submit button.
> 
> The python script then creates a new DTML Document object and then attempts to
> add a multiple selection property to the new DTML Document object.  In doing
so,
> the object is created, but there is no link to the newly created multiple
select
> property (called my_keywords) and the select_keywords property.
> 
> The code...
> 
> my_obj = getattr(context, id)
> my_obj.manageAddProperty('my_keywords', user_keywords, 'multiple selection',
> select_keywords)
> 
>  ... runs correctly, but the link between my_keywords and select_keywords is
> nott established, so Zope cannot use that field.
> 
> The code...
> 
> my_obj = getattr(context, id)
> my_obj.manageAddProperty('my_keywords', user_keywords, 'multiple selection',
> select_variable='select_keywords')
> 
> ... generates an error (complaining about "select_variable").
> 
> 
> Does anyone know the trick to make this work properly?
> 
> Thanks in advance,
> 
> Ron
> 
> select_variable =
> select_keywords
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>