Re: Re: Help with unconsistent behavior of parameter passing to Python Scripts.
Hi Thanks for replying. Sure I did. Actually I did called the script from a DTML Method / DMTL Document objects to be executed as the ACTION of an (html) FORM. The same thing happenned. It was evaluated as a STRING instead of as a LIST as it actually is. I would have expected that the behavior of a plain python program (tested directly under python prompt), then the same program "ported" to be a Zope python script tested witht the internal Zope's "test" tab and later on called from DTML would behave the same. Any ideas? Edward ----------------------------------------------------------
Message: 48 Date: Fri, 12 Apr 2002 11:00:31 +0200 Organization: http://freemail.web.de/ From: <net_seeker@web.de> To: zope@zope.org Subject: Re: [Zope] Help with unconsistent behavior of parameter passing to Python Scripts.
Hi, looks to me like the test-screen parameter input-field is not evaluated as=
an python instruction, but as a string. did you try to feed the script with a "real" list through dtml/other script =3F
Torsten
=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F Geben Sie Ihren Lottotipp gerne auf den letzten Dr=FCcker ab=3FBeim WEB.DE Lottoservice gibt's keine Warteschlangen. http://tippen2.web.de/=3Fx=3D9
-----------------------------------------------------------------------------
Hello all:
Having the following Python script:
if same_type(RR,[]): return "It is a list" if same_type(RR,'abcd'): return "it is a string"
If I use on the parameter's list (sme scrren where the Python script is edited) the value:
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']]
and proceed to TEST the script with the test tab, I am asked for the value of RR (two fields), if I give nothing, then the message
"It is a list" is printed, as expected.
But, if the same thing, (except the initial RR=) is fed into the values field at the test page, then the result comes as a "string", which is NOT the intended effect.
This is just a brief test to find out what is going on, the goal is to be able to feed into a Python script, a list of lists that the script will process and output another list of lists. We have been unable to obtain this as the scripts always ends getting a string instead of the wanted list (of lists).
Can anyone be so kind to explain the behavior of this ? And, to provide some samples on how to make this work correctly ?
By the way, we started with a perfectly working *.py program file , converting it into a script which behave on a similar way to the test just shown.
Thanks in advance for your help.
Edward.
febb wrote:
Hi Thanks for replying. Sure I did. Actually I did called the script from a DTML Method / DMTL Document objects to be executed as the ACTION of an (html) FORM.
there are different points in time. rendering the DTML happens on the server before the result is sent to the browser. you may see what the browser has received w view/source or so. then on the client (=browser) system a <form> is submitted and the resulting request sent back to the server. On the server, ZPublisher prepares a REQUEST object for you and, since the url is your python script, ZPublisher calls it. a DTML file's <form> does not call your script directly. all the browser sends is strings. You may tell ZPublisher to convert these strings to something else by exploiting a little trick on the form variable names (see again http://www.zope.org/Members/Zen/howto/FormVariableTypes, also http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html) Or, you may convert by using _.int(), _.float etc as converters, which unfortunately applies to simple values only. writing your own converter is a bit trickier.
The same thing happenned. It was evaluated as a STRING instead of as a LIST as it actually is.
I would have expected that the behavior of a plain python program (tested directly under python prompt), then the same program "ported" to be a Zope python script tested witht the internal Zope's "test" tab and later on called from DTML would behave the same.
Any ideas?
hans
febb wrote: 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']] Actually I DID test the passing of the list parameter with some sort of conversion. I did use <input type=text name="RR:list"> and <input type=text name="RR:record"> and <input type=text name="RR:records> .... ############################# how about <input type=text name="RR.date:records:text"> # '04-03-2001' <input type=text name="RR.numb:records:text"> # '0900' <input type=text name="RR.stat:records:text"> # 'MEX' <input type=text name="RR.xxxx:records:text"> # 'PBA' ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
participants (2)
-
febb -
hans