[Zope-dev] "Problem" using External Method
Chris McDonough
chrism@digicool.com
Tue, 23 Jan 2001 18:46:21 -0500
Espen,
The files that external methods actually live in are not Python modules,
like normal Python modules. Though I haven't tried your example, it's
likely that your reference to __main__ is confusing the external method
machinery. Additionally, the output of "print" doesn't go to the remote
browser, it instead goes to the console. You need to return a value to the
caller for it to be displayed on the remote browser.
Try instead (as an example):
class Testclass:
def setdata(self,val1,val2,val3):
self.data = [val1,val2,val3]
def updatedata(self, index):
self.data[index] = self.data[index]+1
def display(self):
print self.data
def createdata():
x = Testclass()
x.setdata(10, 20, 30)
x.updatedata(2)
return x.display()
----- Original Message -----
From: "Espen Sorbye Frederiksen" <ceeesf@cee.hw.ac.uk>
To: <zope-dev@zope.org>
Sent: Tuesday, January 23, 2001 5:52 PM
Subject: [Zope-dev] "Problem" using External Method
> The module below works using the python compiler
> class Testclass:
> def setdata(self,val1,val2,val3):
> self.data = [val1,val2,val3]
> def updatedata(self, index):
> self.data[index] = self.data[index]+1
> def display(self):
> print self.data
>
> x = Testclass()
> def createdata():
> import __main__
> __main__.x.setdata(10, 20, 30)
> __main__.x.updateLog(2)
> __main__.x.display()
>
> >>>createdata()
> >>>[10,20,31]
>
> However if I try to add it as an External Method( id= createdata) it
> doesn't
> seem to work. I've tried to call it using <dtml-var/call createdata>
> without success. Any suggestions what I do wrong.
> I am grateful for all comments,
>
> Espen
>
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )
>
>