[Zope] Clarification of a list of lists as a parameter to a python script.

Felipe E. Barousse B. fbarousse@piensa.com
13 Apr 2002 22:16:52 -0500


Hello 

Thanks to all who have responded before. This is like some
misunderstanding of the Python scripts working and just want to make
clear to ourselves how things work here, so, please bear with us:

A plain Python function does accept a "list of lists" as a parameter and
then performs a wide number of different functions with that list of
lists, like sorting it or addressing each of the sublists, even address
any individual item on any of the sublists.

It happens that I have been unable to pass a "list of lists" as a
parameter to a Python Script (within Zope, of course), and perform the
same functions that are done on the function outside of Zope.

Besides some specific python functionality that it is not available due
to security reasons and the use of the "return printed" for stuff that
gets printed out from the python script, my understanding is that the
python script should behave exactly the same if it is executed as a
standalone *.py function (program) or if it is executed as a python
script.  Is this statement correct?

If so, what is the correct way of passing a list of lists as a parameter
to a python script ?  I have the following example:

The DTML Document:

<form method="POST" action="myscript">
Data:
<input type=text name="XX:list" size=50 >
<input type="submit" value="ASIGNAR"></td>
</form>

The myscript python script with "XX" as the parameter

print XX
XX.sort()
print XX
if same_type(XX,[]):
   print "It is a list"
return printed

What is put into the form ( a list of lists) is: 

[['c','b','a'],['a','b','c'],['a','a','d']]

What I get  from the script is:

["[['c','b','a'],['a','b','c'],['a','a','d']]"]
["[['c','b','a'],['a','b','c'],['a','a','d']]"]
It is a list

Which is a list (indeed) BUT with only one element as it -somehow- gets
surrounded by quotes, that is it is NOT a "list of lists" but a list
with one string element.

I'd expect to get the same list back, then the sorted lists within the
main list and later on I could reference the elements with something
like XX[sublistnum][elementnum] kind of construction.

Any ideas on how to overcome this issue.?  The idea is NOT to modify
already working python routines -except for the printed variable and
security stuff whenever necessary-, just to Zope-fy the application if
you know what i mean.

Well, any comments are welcome. Thanks in advance for your assistance.

Felipe