[Zope] DTML Document Properties

Dan Shafer pydan@danshafer.com
Sun, 21 Apr 2002 09:27:49 -0700


Chris.....

Thanks for the big boost. I was part way down that curve but it would have 
taken me a long time to get as far as your code propelled me!

You are awesome.

At 10:02 AM 4/21/2002 +0100, Chris Withers wrote:
>Dan Shafer wrote:
> >
> > LOL. OK,OK, I get it. Especially when I look and look and look and I can't
> > see how to set custom-defined properties for an existing DTML Document
> > object. It *appears* I have to create the DTML document in a script, then
> > use the manage_addProperties function to add properties and assign values.
> > Feels a tad indirect but I don't see property setters and getters.
>
>Yeah, properties could have nicer interfaces...
>
>Here's a little loop I use in my edit methods when only string properties are
>used, assuming a form has been submitted that contains the properties you want
>to set the values of:
>
>REQUEST = context.REQUEST
>for name in ['my_prop1','my_prop2']:
>    update = {}
>    value = REQUEST.get(name,'')
>    if context.hasProperty(name):
>      update[name]=value
>    else:
>      context.manage_addProperty(name,value,'string')
>apply(context.manage_changeProperties,(),update)
>
>cheers,
>
>Chris