[Zope] __getitem__ and returning a PageTemplateFile instance
Anders Bruun Olsen
anders at bruun-olsen.net
Fri Oct 14 05:53:51 EDT 2005
Hi,
I am trying to make a product where-in I want to be able to return a
page based on the url, think something like /product/username
which would return a page with the users details.
For this purpose I am using __getitem__, but when I return a
PageTemplateFile instance it just tells me it has encountered a problem
publishing the object.
Example:
class TestProd(SimpleItem):
"""A TestProd object"""
meta_type = "TestProd"
manage_options = ( {"label": "Edit", "action": "manage_main"},
{"label": "View", "action": "index_html"})
manage_main = PageTemplateFile("templates/mainTestProd", globals())
index_html = PageTemplateFile("templates/indexTestProd", globals())
userdetails = PageTemplateFile("templates/userdetails", globals())
def __init__(self, id, title):
self.id = id
self.title = title
def __getitem__(self, id):
# Does not work!
results = fetch_userdata_from_db(id)
return self.userdetails(self, self.REQUEST, results=results)
def test(self, username):
# Works, but uses /product/test?username=username
results = fetch_userdata_from_db(username)
return self.userdetails(self, self.REQUEST, results=results)
I have tried with everything I can think of to debug this, but have so
far failed. What am I doing wrong here?
Please note that I have also tried with static data, that is returning
self.userdata(self, self.REQUEST, results="some data")
--
Anders
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/O d--@ s:+ a-- C++ UL+++$ P++ L+++ E- W+ N(+) o K? w O-- M- V
PS+ PE@ Y+ PGP+ t 5 X R+ tv+ b++ DI+++ D+ G e- h !r y?
------END GEEK CODE BLOCK------
PGPKey: http://random.sks.keyserver.penguin.de:11371/pks/lookup?op=get&search=0xD4DEFED0
More information about the Zope
mailing list