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. Any ideas would be greatly appreciated. Thanks, Laura
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
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
participants (3)
-
J. Cameron Cooper -
Laura McCord -
Tonico Strasser