[Zope] python script returning multiple values?
J. Cameron Cooper
zope-l at jcameroncooper.com
Thu Sep 30 16:58:35 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.
Return a tuple or list::
return (a,b,c,d,e)
and on the other side you can access it with a TALES expression like::
python: result[0]
which would be the value of 'a'.
Alternately, you can treat it as a list, and do a 'tal:repeat' over it,
although in this case I don't think that would be helpful.
You could also create and return a dictionary; access it by key name on
the other side. Another option is to create a legit class, but this must
be done in file system code.
--jcc
More information about the Zope
mailing list