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

webmaster@zope.org webmaster@zope.org
Fri, 04 Oct 2002 05:28:58 -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">

        % 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
         <dtml-in sql_query>
          <dtml-call expr="PythonScript(variable='<dtml-var sequence_value>')">

         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)">

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

        % 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>

         ## 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'


        % Anonymous User - Oct. 4, 2002 5:28 am:
         I would choose a different name for your script other than 'actionScript' because it causes confusion.
         'ActionScript' is a language developed by Flash. Just a minor point, but why add a 'namespace' conflict?