[Zope] How does DTML handle return variables from Python

McDonnell, Larry lmcdonnell@protonenergy.com
Wed, 19 Jun 2002 07:51:23 -0400


Hi,

In my first dtml doc I have seven select statements to help the user
generate a part number. So I stop getting the global undefined error
message, I added the input statement for the part_num variable. I set the
variable to "zz" so I can see it as a <dtml-var part_num> output on the next
dtml doc gen_part_num. The goal is to take the seven select variables to
create the part_num variable. 

<form method="post" action="gen_part_num">

<body bgcolor="#FFFFFF" text="#000000">
<select name="st1" size="1">
    <option value="01-">01</option>
    <option value="02-">02</option>
    <option value="03-">03</option>
.
.
  <select name="sub_type2" size="1">
    <option value="01">01</option>
    <option value="02">02</option>
.
.
<input name="part_num" type = "hidden" size="2" value="zz">

On the next form it will be a basic re-display of the part number and a
submit to add part_num to the db. 

<form name="form1" method="post" action="create_part_num">
<p>Your here!!<dtml-var st1><dtml-var sub_type2><dtml-var part_num> pn</p>

<dtml-if expr="part_num=='zz'">
<dtml-call "REQUEST.set('part_num',' ')"> 
<p><dtml-var part_num>part_num
</dtml-if>

<dtml-var expr="concat_sub_types_to_part_num(st1,sub_type2)">

**<dtml-var part_num>pn
<input type="submit" name="Submit" value="Submit">

I can see the dtml-vars but when I call the python script part_num is still
set to blank. Sorry for the long email. Thanks in advance.

-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
Thomas B. Passin
Sent: Tuesday, June 18, 2002 3:46 PM
To: ''Zope@Zope. Org' (E-mail)'
Subject: Re: [Zope] How does DTML handle return variables from Python


[McDonnell, Larry]
>
> Yes, the Parameter List is set to st1,sub_type2.
>

Good.  Python will return the concatenated parameters, so it must not be
getting them.  I can't tell where they come from, but you must not be doing
something that you think you are doing.

BTW, if you are just concatenating them you won't even need a script:

<dtml-var "REQUEST.st1"><dtml-var "REQUEST.sub_type2">

or

<dtml-var st1><dtml-var sub_type2>

or

<dtml-var "st1 + sub_type2">

or

&dtml-st1;&dtml-sub_type2;

That's all you need (I'm assuming that these variables come from a
previously-submitted form, so that they are contained in the REQUEST).

Of course, if you aren't getting these parameters correctly, these simpler
forms won't work either.

Maybe you better explain in simple terms just how these two items are
getting to your page.

Cheers,

Tom P
>
> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Thomas B. Passin
> Sent: Tuesday, June 18, 2002 3:02 PM
> To: 'Zope@Zope. Org' (E-mail)
> Subject: Re: [Zope] How does DTML handle return variables from Python
>
>
> [McDonnell, Larry]
> >
> > I sorted of asked this question before but I am still hitting a wall. I
am
> > using this python code:
> >
> > context, container, script, traverse_subpath
> > part_num = st1 + sub_type2
> > return part_num
> >
> > But when "part_num" is returned it is blank. I test the script and
> > "part_num" has a return value.
> >
>
> You have to include the two parameters in the script's parameter list,
which
> you will find in the Edit tab for the script.  Otherwise they don't get
> passed to the script.
>




_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )