[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Advanced Zope Scripting

webmaster@zope.org webmaster@zope.org
Tue, 01 Oct 2002 16:55:50 -0400


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/ScriptingZope.stx#3-34

---------------

      All scripts can be passed parameters. A parameter gives a script
      more information about what to do. When you call a script from the
      web, Zope will try to find the script's parameters in the web
      request and pass them to your script. For example if you have a
      script with parameters *dolphin* and *REQUEST* Zope will
      look for *dolphin* in the web request, and will pass the request
      itself as the *REQUEST* parameter. In practical terms this means
      that it is easy to do form processing in your script. For example
      here is a form::

        <form action="actionScript">
        Name <input type="text" name="name"><br>
        Age <input type="text" name="age:int"><br>
        <input type="submit">
        </form>

        % Anonymous User - Aug. 23, 2002 5:38 am:
         Can you also pass DTML variables to a Python Script from within a sequence loop in a DTML Document. For
         Example:
         <dtml-in sql_query>
          <dtml-call expr="PythonScript(variable='<dtml-var sequence_value>')">
         </dtml-in>

         I know this does not work, but is there another syntax to get it to work. Or is the PythonScript always
         rendered first, before the DTML is interpreted.

        % Anonymous User - Sep. 4, 2002 11:30 am:
         <dtml-in sql_query>
           <dtml-call expr="PythonScript(sequence_value)">
          </dtml-in>

        % Anonymous User - Sep. 4, 2002 11:30 am:
         <dtml-in sql_query>
           <dtml-call expr="PythonScript(sequence_value)">
          </dtml-in>

        % Anonymous User - Sep. 11, 2002 5:09 am:
         Is there any way to pass variables from a DTML-Method or SQL-Method to a Python Script automatically? In the
         given examples the user always has to submit the data manually to have it processed. Especially for records
         an automatic-pass-feature would very interesting to me.

        % Anonymous User - Oct. 1, 2002 4:55 pm:
         How can I capture in a DTML Document a variable defined in a python script ?
         The sources of my code are as follow:

         -----
         <dtml-in expr="MyScript('var1','var2')>
             <img src='<dtml-var myimg>'></img>
         </dtml-in>

         -----
         ## Script (python) "MyScript"
         ## arguments=var1, var2
         "select the image to show depending the level"

         if a1 > a2 :
             myimg = 'a1.png'
         elif a1 < a2 :
             myimg = 'a2.png'
         else :
             myimg = 'a0.png'

         ...