returning list from PythonScript
Hi, I'm trying to pass a list of values between the script and external method. ZPT contains the following: <tal:block tal:define="whatever python: container.myExtMethod ( container.myScript() )" /> container.myScript() is a Python Script that returns a list of values. container.myExtMethod() is an External Method expecting that list. However, all it gets is a string representation of the list ( "[]" instead of [] ). How can I pass the list itself? Btw, hard-coding list in ZPT works fine: <tal:block tal:define="whatever python: container.myExtMethod( ['a', 'b', 'c' ] )" /> Thanks, Jovca _________________________________ Slobodan Jovcic Teaching Enhancement Center Office of Instructional Development, UCLA (310) 794 2099
Slobodan Jovcic wrote:
Hi,
I'm trying to pass a list of values between the script and external method. ZPT contains the following:
<tal:block tal:define="whatever python: container.myExtMethod ( container.myScript() )" />
container.myScript() is a Python Script that returns a list of values. container.myExtMethod() is an External Method expecting that list. However, all it gets is a string representation of the list ( "[]" instead of [] ). How can I pass the list itself?
Btw, hard-coding list in ZPT works fine: <tal:block tal:define="whatever python: container.myExtMethod( ['a', 'b', 'c' ] )" />
The problem is likely in 'myScript', which you do not show us. --jcc -- "Building Websites with Plone" http://plonebook.packtpub.com
True. Somehow, some of the latest changes in the script were lost, probably by closing the browser without save, including a change of: print result return printed to: return result Very stupid. Jovca _________________________________ Slobodan Jovcic Teaching Enhancement Center Office of Instructional Development, UCLA (310) 794 2099 On Jan 20, 2006, at 2:54 PM, J Cameron Cooper wrote:
Slobodan Jovcic wrote:
Hi, I'm trying to pass a list of values between the script and external method. ZPT contains the following: <tal:block tal:define="whatever python: container.myExtMethod ( container.myScript() )" /> container.myScript() is a Python Script that returns a list of values. container.myExtMethod() is an External Method expecting that list. However, all it gets is a string representation of the list ( "[]" instead of [] ). How can I pass the list itself? Btw, hard-coding list in ZPT works fine: <tal:block tal:define="whatever python: container.myExtMethod ( ['a', 'b', 'c' ] )" />
The problem is likely in 'myScript', which you do not show us.
--jcc -- "Building Websites with Plone" http://plonebook.packtpub.com
J Cameron Cooper wrote:
Slobodan Jovcic wrote:
Hi,
I'm trying to pass a list of values between the script and external method. ZPT contains the following:
<tal:block tal:define="whatever python: container.myExtMethod ( container.myScript() )" />
container.myScript() is a Python Script that returns a list of values. container.myExtMethod() is an External Method expecting that list. However, all it gets is a string representation of the list ( "[]" instead of [] ). How can I pass the list itself?
Btw, hard-coding list in ZPT works fine: <tal:block tal:define="whatever python: container.myExtMethod( ['a', 'b', 'c' ] )" />
The problem is likely in 'myScript', which you do not show us.
--jcc
I'd probably just call container.MyScript() as self.MyScript() in the external method. But i'm curious as to why your example doesn't work. Maybe you could first define the array first with something like ... <tal:block tal:define="thearray structure? python: container.myScript(); whatever python: container.myExtMethod( thearray )" DAvid
I'd probably just call container.MyScript() as self.MyScript() in the external method.
I'm trying to keep external method versatile.
But i'm curious as to why your example doesn't work.
There was an error in the script that I fixed, but never saved the file. Doh! Thanks, Jovca _________________________________ Slobodan Jovcic Teaching Enhancement Center Office of Instructional Development, UCLA (310) 794 2099 On Jan 20, 2006, at 4:05 PM, David wrote:
J Cameron Cooper wrote:
Slobodan Jovcic wrote:
Hi,
I'm trying to pass a list of values between the script and external method. ZPT contains the following:
<tal:block tal:define="whatever python: container.myExtMethod ( container.myScript() )" />
container.myScript() is a Python Script that returns a list of values. container.myExtMethod() is an External Method expecting that list. However, all it gets is a string representation of the list ( "[]" instead of [] ). How can I pass the list itself?
Btw, hard-coding list in ZPT works fine: <tal:block tal:define="whatever python: container.myExtMethod ( ['a', 'b', 'c' ] )" />
The problem is likely in 'myScript', which you do not show us.
--jcc
I'd probably just call container.MyScript() as self.MyScript() in the external method. But i'm curious as to why your example doesn't work. Maybe you could first define the array first with something like ...
<tal:block tal:define="thearray structure? python: container.myScript(); whatever python: container.myExtMethod( thearray )"
DAvid
Slobodan Jovcic wrote:
<tal:block tal:define="whatever python: container.myExtMethod ( container.myScript() )" />
This kind of logic has no business being in a page template... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Chris Withers -
David -
J Cameron Cooper -
Slobodan Jovcic