[Zope] Questions re: REQUEST, external methods; newbie stupidity at play

zoper@disturbance.dhs.org zoper@disturbance.dhs.org
Tue, 15 Jul 2003 12:35:01 -0700 (PDT)


Greetings:

I realize I am likely doing stuff in the cruftiest way possible: Rather
than flame if you have the urge, a link to specifics on better ways to do
what I am doing would be appreciated.

I have a set of external methods that do some stuff to create and build an
XML document. I am also doing a lot of logic in DTML and passing stuff
back and forth to these external methods. A great simplification of what I
am doing:

----------------------
<dtml-call expr="REQUEST.set('myxmldoc',createxmldoc())">
<!-- createxmldoc is an external method that creates a (minidom)
Document() and adds a root node. They are returned as a tuple, i.e.
myxmldoc[0] will be the xml doc object and myxmldoc[1] will be the node-->

<!-- dtml logic that gets some info from a database -->

<dtml-call
expr="REQUEST.set('myxmldoc',addanode(myxmldoc[0],myxmldoc[1],databasevar)">
<!-- in the line above, databasevar is some info from my DB, and addanode
is an external method... -->
----------------------

The problem is, that when I do this, re-using the myxmldoc var causes a
__getitem__ attribute error. I have to use a new name, i.e. modxmldoc, to
get around the error.

OK, I thought, fine, so long as I can kill the original myxmldoc object,
as I have many iterations of this and I do not want to end up with a huge
amount of objects in memory, getting larger and larger. However, I can't
figure out how to 'unset' myxmldoc - setting it to '' doesn't work, I get
a string index out of range error. If I specifically set myxmldoc[0] and
myxmldoc[1] to '', that works, but I still get the __getitem__ error when
I attempt to re-use the variable.

Suggestions?

TIA, Bryan