[Zope] a question on external method arguments
Guido A.J. Stevens
gyst@nfg.nl
13 Dec 1999 13:08:21 +0100
I'd like to use an external Python method to reference it's caller's
object id. Broken down to the simplest example:
def testid(self, idref):
"""test scoping of variables"""
return idref
which is supposed to return its input argument "idref" unchanged. This
works nicely when called from a DTML method, but when I call this
external method from a DTML document, something weird happens. DTML
source:
<p>
This is the <!--#var id--> Document.<br>
My id is reported to be:<dtml-var "testid(id)"><br>
<dtml-let myid=id>
but also:<dtml-var "testid(myid)"><br>
</dtml-let>
</p>
gives the following result:
<p>
This is the sub1-1 Document.<br>
My id is reported to be:<Python Method object at 8451b20><br>
but also:sub1-1<br>
</p>
Can anybody explain to me, why I need to copy the "id" variable to a
locally scoped "myid" for this to work? And what is the logic that
makes the external method return self instead of its input argument?
And, of course, I'd like to get to the "id" value through self instead
of using an ugly hack like passing an explicit id, which I'm only
using for debugging purposes right now. Got to understand where self
comes from in an external method, first :-(.
:*CU#
--
*** Guido A.J. Stevens *** mailto:gyst@nfg.nl ***
*** Net Facilities Group *** tel:+31.43.3618933 ***
*** http://www.nfg.nl *** fax:+31.43.3560502 ***