Using 2.6.1, I'm trying to get the constructor of a ZClass to dynamically assign the ID, and set the title from data passed to the constructor. Setting the ID works fine; setting the title isn't working at all. From the constructor: *# Create an ID dynamically timestamp = "SHLH-%X" % int(context.ZopeTime()) request.set('id', timestamp) request.set('title', 'My title') #request.set('title', request.form['Sender_Name']) instance = container.MyZClass.createInObjectManager(request['id'], request) * Why does this work for 'id', but not for 'title'? Older code samples using dtml seem to have set both attributes the same way. Thanks, Rob** ** -- Rob Thorne Torenware Networks
Folks, I got this working. Since the fix wasn't obvious, I'm documenting it here. ZClass objects inherit from ZObject. Apparently, either a ZObject does not have a "title" attribute, or at the very least, does not have a "title" attribute that you can change. The fix is to make sure that your ZClass has a "title" property. Once you do this, constructor code like the example below will set the "title" property without error, and a title for the object will appear in the ZMI. Cheers, Rob Rob Thorne wrote:
Using 2.6.1, I'm trying to get the constructor of a ZClass to dynamically assign the ID, and set the title from data passed to the constructor. Setting the ID works fine; setting the title isn't working at all.
From the constructor:
*# Create an ID dynamically timestamp = "SHLH-%X" % int(context.ZopeTime()) request.set('id', timestamp)
request.set('title', 'My title') #request.set('title', request.form['Sender_Name'])
instance = container.MyZClass.createInObjectManager(request['id'], request) *
Why does this work for 'id', but not for 'title'? Older code samples using dtml seem to have set both attributes the same way.
Thanks, Rob** **
-- Rob Thorne Torenware Networks http://www.torenware.com
Rob Thorne wrote at 2003-2-14 17:49 -0800:
Using 2.6.1, I'm trying to get the constructor of a ZClass to dynamically assign the ID, and set the title from data passed to the constructor. Setting the ID works fine; setting the title isn't working at all.
From the constructor:
*# Create an ID dynamically timestamp = "SHLH-%X" % int(context.ZopeTime()) request.set('id', timestamp)
request.set('title', 'My title') #request.set('title', request.form['Sender_Name'])
instance = container.MyZClass.createInObjectManager(request['id'], request) *
Why does this work for 'id', but not for 'title'? Older code samples using dtml seem to have set both attributes the same way.
Because "createInObjectManager" sets the id but not the title. Use "manage_changeProperties" to change the title. Dieter
participants (2)
-
Dieter Maurer -
Rob Thorne