python methods for setting selection lists selected item
OK, I've been trying to write a python script to create a DTMLDocument with a few properties in it as based on a form (inspired by http://www.evolt.org/article/A_Quick_and_Dirty_Blog_using_Zope/20/23583/). I seem to do fine with text, strings, dates and the like: A form sends in mylaunchdate, myexpireDate, mynewsContent, and mytexttype (a SELECT) and send this to a Script(Python): context.news_items.manage_addProduct['OFSP'].manage_addDTMLDocument(id,\ title=mynewsTitle, file=MyDocument) doc = getattr(context.news_items,id) doc.manage_addProperty('launchDate', mylaunchDate, 'date') doc.manage_addProperty('expireDate', myexpireDate, 'date') doc.manage_addProperty('newsContent', mynewsContent, 'text') But I can't seem to get the hang of selection lists. I create one like this: doc.manage_addProperty('newsFormatOptions', ['StructuredText','xhtml'],\ 'lines') doc.manage_addProperty('newsFormat', 'newsFormatOptions', 'selection') but how do I assign the proper selection states in a python script? How do I set or test what the current selection is in the selection? I'd like to be able to test whether the setting is html or StructuredText for instance so that the document can be properly be presented. Thanks, Jon
Jon Fox wrote at 2003-8-18 21:47 -0400:
... doc.manage_addProperty('newsFormatOptions', ['StructuredText','xhtml'],\ 'lines') doc.manage_addProperty('newsFormat', 'newsFormatOptions', 'selection')
but how do I assign the proper selection states in a python script?
You use "manage_changeProperties" (see the "PropertyManager" API (e.g. in the embedded Online help)).
How do I set or test what the current selection is in the selection?
You can use "getProperty" (from the "PropertyManager" API) or simple "doc.yourProperty". Dieter
participants (2)
-
Dieter Maurer -
Jon Fox