[Zope] dtml-calendar: cannot update existing entry

Chris Withers chrisw at nipltd.com
Thu Aug 28 11:57:53 EDT 2003


Daniel Huang wrote:
> I'm following Jon Udell's tutorial 
> (http://zope.org/Members/judell/CalendarTagExample) verbatim and have 
> successfully created entries in the calendar (version 1.0.15) .  However 
> when I click on an existing entry and try to change the content, I get 
> the following error:
> 
> Error Type: Bad Request
> Error Value: Invalid or duplicate property id.

Have you got the traceback which goes with this?

> Its happening in the editCalendarProperty code:
> ///////////////
> REQUEST = context.REQUEST
> 
> if ( context.hasProperty(REQUEST['prop']) ):
>     context.manage_changeProperties({ REQUEST['prop'] : 
> REQUEST['propval'] })
> else:
>     context.manage_addProperty(REQUEST['prop'], REQUEST['propval'], 
> 'string')
> return REQUEST.RESPONSE.redirect(REQUEST['BASE4'])
> ////////////////

This code could do with a lot of refactoring, when done, it becomes:

r = context.REQUEST
propname = r.prop
propval  = r.propval
if context.hasProperty(propname):
   context.manage_changeProperties({propname:propval})
else:
   context.manage_addProperty(propname,propval,'string')
return r.RESPONSE.redirect(r.BASE4)

cheers,

Chris




More information about the Zope mailing list