[Zope] python methods for setting selection lists selected item

Jon Fox jonfox at drfox.com
Mon Aug 18 22:47:37 EDT 2003


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



More information about the Zope mailing list