John Morton <jwm@plain.co.nz>
Date: Mon, 27 Mar 2000 16:29:30 +1200 (NZST) To: zope@zope.org Subject: [Zope] Problems with adding ZClass instances
I'm have problems with a ZClass I'm working on that uses Folder as it's base class and is supposed to install a set of default methods when it's created. The trouble is that it won't when the webDirectory is created, but it will when I invoke the same method from a tab afterwards.
Here's the body of webDirectory_add:
<dtml-with "webDirectory.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-if createDefaultMethods> <dtml-in "default_methods.objectIds()"> <dtml-try> <dtml-call "manage_delObjects(ids=[_['sequence-item']])"> <dtml-except> </dtml-try> <dtml-call "manage_clone( _.getattr(default_methods, _['sequence-item']), _['sequence-item'], REQUEST)"> </dtml-in> </dtml-if> </dtml-with>
I'm assuming that the code within the <dtml-with ...> is effectively opperating in the context of the newly created object, but when the first manage_clone() is executed, it bombs out in _getCopy, tripping over on this line:
ob=container._p_jar.importFile(f)
...because whatever container is, it's not a folderish object.
So what do I need to do to switch to the new webDirectory object at creation time, so adding methods is automatic?
I do something very similar in the ZGotW product's root factory:: <dtml-in "defaults.objectIds( 'DTML Method' )"> <dtml-let si=sequence-item> <dtml-with newRoot> <dtml-call "manage_addDTMLMethod( si, '', defaults[ si ] )"> </dtml-with> </dtml-let> </dtml-in> The key here may be the inner '<dtml-with newRoot>', which is forcing the newly-created root folder to the top of the namespace stack, so that 'manage_addDTMLMethod()' is being invoked on it, rather than on the sequence-item. Hope this helps! Tres. -- ========================================================= Tres Seaver tseaver@digicool.com tseaver@palladion.com