RE: [Zope] [ZClass constructor question]: How can I copy objects into my container class?
Hi Jim, Nice one! I went with the script approach and called from within the: <dtml-with productname.createInObjectManager(REQUEST['id'], ...)> All worked fine. Thank you. I looked at the other approaches you mentioned: <dtml-with newitemname> ... </dtml-with> & <dtml-call "newitemname.init()"> Much headscratching. What do I replace 'newitemname' with to get it to work? I tried "REQUEST['id'].init()" and several variants but get "Attribute errors" about "init". The only way I can get stuf fto work is when the init() call is made inside the "<dtml-with productname.createInObjectManager(REQUEST['id'], ...)>" block. I guess I need help figuring out how to look-up the name of the item that's contained in the var 'id' and use it as part of the call. Thanks again, Simon. -----Original Message----- From: Jim Washington Sent: Thu 22/11/2001 01:17 To: Simon Brogden; zope@zope.org Cc: Subject: Re: [Zope] [ZClass constructor question]: How can I copy objects into my container class? Simon Brogden wrote: >Hi All, > >I'm (banging my head against the desk) writing to write a ZClass that >inherits from ObjectManager and can contain other objects (DTMLMethods & >Images). When an instance of the class is created I want to copy/create >a couple of default DTML methods inside the instance, so the user can >modify them. > >Trouble is, the methods appear at the same nesting level as the class is >created at, not contained within it. > >I'm putting the create/copy call inside the class constructor method: ><dtml-call "manage_addProduct['OFSP'].manage_addDTMLMethod(....)> > >I've trawled the how-to's & the example products (the "How to: Build a >searchable job board" is excellent BTW) to no avail. > >Does anyone know where I'm going wrong? > Hi, Simon The standard answer is to use the dtml-with tag: <dtml-with newitemname> <dtml-call "manage_addBlah(params)"> </dtml-with> But you might consider making a python script called "init" or something like that for the class you are adding: methodID = 'example' methodTitle = 'This is the example method" methodStandardText = """<standard_html_header> example dtml text goes here <dtml-var standard_html_footer>""" container.manage_addDTMLMethod(id=methodID,title="") container[methodID].manage_edit(data=methodStandardText, title=methodTitle) then after you add the new item, <dtml-call "newitemname.init()"> hth, -- Jim Washington _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (1)
-
Simon Brogden