[Zope] Python equivalent of dtml-with?

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


I'm writing an external method in Python which is going to be used to 
create new instances of a ZClass that I've written.  In my normal DTML for 
object creation, I would do something like this:

<dtml-with "ZClass.createInObjectManager(REQUEST['id'], REQUEST)">
    <dtml-call 
"propertysheets.instanceProperties.manage_editProperties(REQUEST)">
    <dtml-call unindex_object>
    <dtml-call "manage_editCataloger('MyCatalog', REQUEST)">
    <dtml-call index_object>
</dtml-with>

I've got an external method written which is able to create a new object by 
calling the ZClass.createInObjectManager method.  However, I'm not sure how 
to code up the code contained in the dtml-with block using Python.  I 
suspect that I could get things to work for the example above with 
something like this:

(self is the product containing my ZClass definition)

newobj = self.ZClass.createInObjectManager(REQUEST['id'], REQUEST)
newobj.propertysheets.instanceProperties.manage_editProperties(REQUEST)
newobj.unindex_object()
newobj.manage_editCataloger('MyCatalog', REQUEST)
newobj.index_object()

However, I'm interested in knowing how do code up stuff in Python which 
would take into account acquisition.

Thanks.



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