[Zope] Help with unconsistent behavior of parameter passing to
Python Scripts.
Felipe E. Barousse B.
fbarousse@piensa.com
12 Apr 2002 17:40:40 -0500
Seems the problem may be better expressed as having a python script that
when run (within python), can be fed with a list of lists, like:
RR=[
['04-03-2001','0900','MEX','PBA','0300','N'],
['04-03-2001','1100','MTY','NLD','0300','N'],
['04-03-2001','1600','NLD','MTY','0300','N'],
['04-03-2001','1800','MTY','NLD','0300','N'],
['04-03-2001','1400','MTY','NLD','0300','N'],
['04-03-2001','1000','NLD','MTY','0300','N'],
['04-03-2001','0800','MTY','NLD','0300','N'],
['04-03-2001','0900','NLD','MTY','0300','N'],
['04-03-2001','1000','MTY','NLD','0300','N'],
['04-03-2001','1300','NLD','MTY','0300','N'],
['04-03-2001','1200','PBA','MEX','0300','N'],
['04-03-2001','0930','NLD','MTY','0300','N'],
['04-03-2001','0800','MTY','NLD','0300','N'],
['04-03-2001','0900','MTY','NLD','0300','N'],
['04-03-2001','1100','NLD','MTY','0300','N']
]
If this is given as input to a simple script that say, it only sorts the
list of lists
for i in range(len(RR)):
print RR[i]
RR.sort()
print "---------------------------------"
for i in range(len(RR)):
print RR[i]
It works fine. But, when this is made a python script, it does not
work. When RR is typed into (or pasted into) the form:
<form method="POST" action="mypythonscript">
<input type=text name="RR:list">
</form>
The script at mypythonscript indeed receives a list, but it does not
know that the elements of this list are in turn other lists. The
questions that come up then are:
1.- Why it works with plain python and does not with Zope
2.- How to make it work with zope by indicating that the passed value is
a "list of lists"
Hope this clears things a bit. Any help is greatly appreciated. Thanks
in advance.
Felipe Barousse
On Fri, 2002-04-12 at 14:48, Dieter Maurer wrote:
> febb writes:
> > Having the following Python script:
> >
> > if same_type(RR,[]):
> > if same_type(RR,'abcd'):
> > return "it is a string"
> >
> > ... calling "Test" with parameter value "[...]" returns "is a string"...
> I think, this is correct behaviour:
>
> Python is not statically typed. The same name can be bound to different
> types over time.
>
> The fact, that your argument has a list as default value does
> not mean, that all passed in values will be lists.
>
> The parameters passed with any Web request *ARE* all strings
> in the first place. Zope uses various ":XXX" suffixes to
> the parameter names to control how these strings are converted
> into other datatype (see e.g.
>
> <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
>
> ). But the "Test" interface of "PythonScripts" does not support
> these conversion suffixes.
>
> I agree, this is a limitation, but not inconsistent...
>
>
> Dieter