setting Zclass instance id based on properties
I would like to set the id of a Zclass instance based on some of the properties I can not use the property variables in the add method since the properties have not yet been assigned a value For instance let's say I have three properties: Section, Chapter and Page How do I assign the id the value <dtml-var Section>-<dtml-var Chapter>-<dtml-var Page> when I create the zclass instance?
Charlie Kalech wrote:
I would like to set the id of a Zclass instance based on some of the properties
I can not use the property variables in the add method since the properties have not yet been assigned a value
For instance let's say I have three properties: Section, Chapter and Page
How do I assign the id the value <dtml-var Section>-<dtml-var Chapter>-<dtml-var Page> when I create the zclass instance?
There is no data in the 'Section', 'Chapter' or 'Page' until after you create an instance of your ZClass and assign some value to the properties. The property fields of a ZClass are just 'field names' until you create an instance of that ZClass, so you can't do anything with them. What are you trying to accomplish? Jonathan
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
I'm trying to create a context-based id based on the properties. There must be a way to customize the python constructor such that instead of two steps there is a third step that reassigns the value of the id based on properties *after* they are assigned. I'm a designer, not a programmer - can somebody help me out here? I'm looking for someone to fill in the third blank: (1) Add a new instance of the ZClass request = context.REQUEST instance = container.MyZClass.createInObjectManager(request['id'], request) (2) update a property sheet from the form values instance.propertysheets.MyZClassProperties.manage_editProperties(request) (3) set id to be equal several properties (such as section-chapter-book) At 13:11 -0500 12/2/03, Small Business Services wrote:
Charlie Kalech wrote:
I would like to set the id of a Zclass instance based on some of the properties
I can not use the property variables in the add method since the properties have not yet been assigned a value
For instance let's say I have three properties: Section, Chapter and Page
How do I assign the id the value <dtml-var Section>-<dtml-var Chapter>-<dtml-var Page> when I create the zclass instance?
There is no data in the 'Section', 'Chapter' or 'Page' until after you create an instance of your ZClass and assign some value to the properties. The property fields of a ZClass are just 'field names' until you create an instance of that ZClass, so you can't do anything with them.
What are you trying to accomplish?
Jonathan
Re: [Zope] setting Zclass instance id based on propertCharlie wrote: I'm trying to create a context-based id based on the properties. There must be a way to customize the python constructor such that instead of two steps there is a third step that reassigns the value of the id based on properties *after* they are assigned. I'm a designer, not a programmer - can somebody help me out here? I'm looking for someone to fill in the third blank: (1) Add a new instance of the ZClass request = context.REQUEST instance = container.MyZClass.createInObjectManager(request['id'], request) (2) update a property sheet from the form values instance.propertysheets.MyZClassProperties.manage_editProperties(request) (3) set id to be equal several properties (such as section-chapter-book) There is a manage_rename routine. I have never used it myself (other than indirectly by clicking on the 'Rename' button on the ZMI display) so I don't know the parameters required. I would guess it would be something like: <dtml-call "manage_rename(old_id, new_id)"> or <dtml-call "old_id.manage_rename(new_id)"> or <dtml-call "old_id.manage_rename(id=new_id) If these don't work, try looking at the source or maybe someone else on the mailing list has some experience with it. HTH Jonathan Jonathan
Charlie Kalech wrote at 2003-12-2 17:18 +0300:
I would like to set the id of a Zclass instance based on some of the properties
I can not use the property variables in the add method since the properties have not yet been assigned a value
For instance let's say I have three properties: Section, Chapter and Page
How do I assign the id the value <dtml-var Section>-<dtml-var Chapter>-<dtml-var Page> when I create the zclass instance?
When you have created your ZClass, two constructors have been (usually) created: a form and its action. The action is a PythonScript in modern Zope versions -- quite easy to customize. When you have special needs you customize these two constructors... -- Dieter
participants (3)
-
Charlie Kalech -
Dieter Maurer -
Small Business Services