[Zope] changing ZClass properties from a PythonScript
Tim Wilson
wilson@isis.visi.com
Tue, 26 Mar 2002 13:23:33 -0600 (CST)
Hi everyone,
I've built a simple ZClass for publishing news items on my site. The
news articles have a "teazer" property for holding a short
attention-getting paragraph and an optional "body" property for the full
article. When displaying the news on the site, the teazer paragraph is
displayed and if a body exists, a "Read more..." link is displayed. No
problem there.
I'm using a boolean property called "readmore" that determines whether
the link is displayed or not. I use a PythonScript to add the instance
and I'm trying to figure out how to set the "readmore" property
depending on whether any text has been entered in the body field. Here's
what I have so far:
## Script (Python) "NewsClass_add"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Add a NewsClass instance
##
REQUEST = container.REQUEST
newsitem = container.NewsClass.createInObjectManager(REQUEST['id'],
REQUEST)
newsitem.propertysheets.Basic.manage_editProperties(REQUEST)
if REQUEST.has_key('body'):
newsitem.propertysheets.Basic.manage_changeProperties(REQUEST,
readmore=TRUE)
else:
newsitem.propertysheets.Basic.manage_changeProperties(REQUEST,
readmore=FALSE)
newsitem.reindex_object()
RESPONSE = REQUEST.RESPONSE
if REQUEST.has_key('DestinationURL'):
return # following line wrapped in my email
RESPONSE.redirect(REQUEST['DestinationURL']+'/manage_workspace')
return RESPONSE.redirect(REQUEST['URL2']+'/manage_workspace')
Should I be using manage_addProperty instead. I've tried a bunch of
different approaches.
-Tim
--
Tim Wilson | Visit Sibley online: | Check out:
Henry Sibley HS | http://www.isd197.org | http://www.zope.com
W. St. Paul, MN | | http://slashdot.org
wilson@visi.com | <dtml-var pithy_quote> | http://linux.com