[Zope] Passing not-string variables to a python script
Thomas B. Passin
tpassin@mitretek.org
Mon, 17 Jun 2002 11:55:30 -0400
[Dianne Van Dulken]
> I'm finding whenever I call a python script from within a zope page (as
> opposed to submitting a form to a script), it assumes that every parameter
> is a string. This isn't always the case, in fact, it is rarely the case.
I
> was wondering if there was anyway that I could force it to know what type
it
> was. I am particularly interested in passing in lists.
>
> The way I call it at the moment is like this:
>
> <dtml-var expr="script1(var1='blah', var2=['a', 'b', 'c'])"> etc.
>
Please explain what behavior led you to conclude that the python script is
getting or handling the parameters as strings. Naturally, if you say
var1='blah', you will get a string, because you explicitly said so. If you
say var2=[1,2,3] you will get a list. I just tested this on my system and
a list is passed as a list (Zope 2.3.3 on Win 2000).
Also please say what version of Zope you are using. Zope does pass the
right type of parameter and Python does understand them, so it seems likely
that you are doing something you don't realize that is interfering.
> I tried calling them like var1:string, var2:list, but I get a syntax
error.
> Ditto when I try setting types in the parameter list on the script option.
Naturally, because var2:list is not python syntax.
> I am using the "python script" default option that comes with zope, as
> opposed to importing one.
>
Do you mean that you have created a "python script"? Have you added the
parameters in the list at the top of the script's page?
Cheers,
Tom P