[Zope] Refactoring Question

James W. Howe jwh@allencreek.com
Mon, 06 Mar 2000 10:53:51 -0500


I have a DTML method that I would like to refactor but I'm unsure of the 
results I'll get.  In one of my products, I have a ZClass_add method which 
has code which does something like this:

<dtml-with "ZClass.createInObjectManager(...)">
     <do something>
     <do something else>
     <dtml-call unindex_object>
     <dtml-call "method_editCataloger(...)">
     <dtml-call index_object>
</dtml-with>

What I would like to do is yank all the content out of the <dtml-with> 
block and put it in its own method.  I'm thinking that I would like the 
method to live in my product folder, but I'm open to suggestions.  The end 
result would be something like:

<dtml-with "ZClass.createInObjectManager(...)">
<dtml-call initObject>
</dtml-with>

and the initObject method would be contain

<do something>
<do something else>
<dtml-call unindex_object>
<dtml-call "manage_editCataloger(...)">
<dtml-call index_object>

My first question is, if I create an initObject method in my product 
folder, if I call it from within my dtml-with, will it execute exactly the 
same way as if it were included inline or would it somehow lose the fact 
that it was executing in the context of the "with" object?  I'm thinking 
that the "with" information is put on the namespace and the namespace will 
be available with my initObject method is executed, but I want to confirm 
that my thinking is correct.  Alternatively, should I define my initObject 
as a method of the ZClass itself rather than defining it in the Product folder?

Thanks.

James W. Howe				mailto:jwh@allencreek.com
Allen Creek Software, Inc.		pgpkey: http://ic.net/~jwh/pgpkey.html		
Ann Arbor, MI  48103