create objects with dot in product
Via the ZMI i can create an object with a . in the name (for example, an object with an id 'file.htm'); how can this be done in a disk based product? For example, the following obviously won't work: file.htm = PageTemplateFile('www/file.htm', globals()) There must be a trick, since the ZMI can do it?
I think this might work: setattr(self, 'file.htm', PageTemplateFile('www/file.htm', globals())) Tim wrote:
Via the ZMI i can create an object with a . in the name (for example, an object with an id 'file.htm'); how can this be done in a disk based product? For example, the following obviously won't work:
file.htm = PageTemplateFile('www/file.htm', globals())
There must be a trick, since the ZMI can do it?
_______________________________________________ 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 )
At 13:59 2003-02-24 -0500, Tim wrote:
Via the ZMI i can create an object with a . in the name (for example, an object with an id 'file.htm'); how can this be done in a disk based product? For example, the following obviously won't work:
file.htm = PageTemplateFile('www/file.htm', globals())
There must be a trick, since the ZMI can do it?
class MyProduct: ... file_htm = PageTemplateFile('www/file.htm', globals()) MyProduct.__dict__['file.htm'] = MyProduct.file_htm You basically make a new reference and this syntax allows you to do that.
_______________________________________________ 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 )
Peter wrote on Monday, February 24, 2003, 5:48:53 PM:
There must be a trick, since the ZMI can do it?
class MyProduct: ... file_htm = PageTemplateFile('www/file.htm', globals())
MyProduct.__dict__['file.htm'] = MyProduct.file_htm
This worked, thanks. Chris's (whom i also thank for his response) setattr(self, ...) solution didn't work, because there is no "self" available at that point in the object. Probably would work if it was inside a method. -- Tim Middleton | Cain Gang Ltd | Asios pummeled his thighs..."Father Zeus, x@veX.net | www.Vex.Net | you, even you, turn out to be a liar." (H)
participants (3)
-
Chris Beaven -
Peter Bengtsson -
Tim