[Zope] Re: python script returning multiple values?

Tonico Strasser contact_tonico at yahoo.de
Thu Sep 30 19:11:40 EDT 2004


Laura McCord wrote:
> Hi,
> 
>  I have a python script:
>   
>  def userInfo(userName):
>    server = xmlrpclib.Server("http://tweety:8080/RPC2")
>    email = server.da.emailInfo(userName)
>    office = server.da.officeInfo(userName)
>    pwd = server.da.pwdInfo(userName)
>    acct = server.da.acctInfo(userName)
>    dir = server.da.dirInfo(userName)
>    return .....
> 
> I need to return all of the values and access them through a zope page
> template. I can't find any documentation on this situation. I am
> suspecting I probably need to create a list in my python script but not
> sure yet how to display the values in my zpt.
> 

You could return this as a dictionary:

     info = { 'server' : server
            , 'email' : email
            ...
            }
     return info

In ZPT you can display the values from the dictionary:

     <table tal:define="info here/myscript">
       <tr>
         <td>Server:</td>
         <td tal:content="info/server"/>
       </tr>
       <tr>
         <td>E-Mail:</td>
         <td tal:content="info/email"/>
       </tr>
       ...
     </table>

HTH
Tonico



More information about the Zope mailing list