On Monday 20 Jun 2005 5:26 pm, Tonico Strasser wrote: > Kenneth Gonsalves schrieb: > > hi > > i am having a very weird experience. I have a page template > > called manageheads. This requires a parameter called > > 'companyname' to be passed to it. I access this option as: > > python:somefunction(companyname=options['companyname']) > > when i call the ZPT from the web like so: > > http://.../manageheads?companyname=nameofcompany > > it works > > Are you shure this works? Did you redefine 'options' somewhere? > > > but if i call it from a python script like so: > > return manageheads(companyname=nameofcompany) > > it complains saying > > key error 'companyname' > > It should simply work. > > > The weird thing is that i have several similar ZPTs where this > > call from python scripts work perfectly in the same zope > > instance. So why not in this one? any clues? > > Maybe you did redefine 'options' in your template.
options has not been redefined anywhere. The problem appears to be in the way to call a particular python script this is a bit long, but interesting nevertheless -:) the variable in question is 'compname' which is either request['compname'] or options['compname'] depending on how the ZPT is called (from web it goes to 'request' and from script in goes to 'options') This is the script: callheadtree.py parameter list: compname theads=context.getheadleafs() heads=[] for k in theads: heads.append(k['id']) htree=context.getheadtree(compname=compname,id=1,name='chart',ret=[],heads=heads) headtree=[] for k in htree: headtree.append({'name':k}) return headtree when tested using the test tab it works when the originating ZPT is called from the web using '?' notation it works when called from the following script: onetest.py names=callheadtree(compname='testcompany') return names it gives a Keyerror 'compname' when the originating ZPT is called from a script: it gives a Keyerror 'compname' -- regards kg http://www.livejournal.com/users/lawgon tally ho! http://avsap.org.in ಇಂಡ್ಲಿನಕ್ಸ வாழ்க! _______________________________________________ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt