[ZPT] ZPT served from a python Product / where are my attr. gone ?
michael@beehive.de
michael@beehive.de
Thu, 19 Jul 2001 17:36:56 +0200
Hi,
perhaps my Problem is easy to solve, but perhaps ...
let=B4s start
I am trying to create an object on the fly with data out of an=20
SQL-Method.
The Object i am creating is an Instance of an class.
Let=B4s asume
myFolder =3D DeTeLineFolder()
First round:
1. Via my URL ..../myfolder/index_html -- i get my standard index_html
2. Via my URL ..../myfolder/213
-- i get the index_html from the class Document. With the values of my=20=
Query. works ok
Round 2:
1. the same
2. the same, but i used ZPT (PageTemplateFile) an i get the following=20
message
Error Type: Undefined
Error Value: "doc_type" not found in "here/doc_type"
I tried alle namespaces !!!!!!(container ... ) But i think it has to be=20=
"here" ?
more trace back below !
Question ::::
Why is "here" empty ?
How can i put something in it ?
Why is DTML working, but not ZPT ?
The Code :::::::::::::::::::::::::::::::::::::::::::::::
class Document(Acquisition.Implicit):
"""I am Used"""
def __init__(self, TMP=3DNone):
"""Zuweisung aller Objektproperties aus einer =
SQL-Abfrage"""
self.id2 =3D str(TMP[0]['id'])
self.doc_type =3D str(TMP[0]['doc_type'])#The thing i am =
trying=20
to access
=09
#the 2 cases ######
#round 1=09
templateFile =3D HTMLFile("Templates/test", globals() )
#round 2
templateFile =3D PageTemplateFile("Templates/test", globals() )
#end
def index_html(self):
"""dfdd"""
return self.templateFile(self)=09
=09
def it(self):
"""dfdd"""
#return self.hallo
return self.templateFile(self)
class DeTeLineFolder( Folder ):
"""The Caller"""
=09
meta_type =3D 'DeTeLineFolder'
=09
_isDeTeLineFolder =3D 1
=09
=09
def __getitem__(self, attr):
"""Get all request which could not resolved after =
Acquesition"""
#attr =3D string.split(attr, '.')[0]
TMP =3D self.SQL.getDocbyRed_Query(r_red_id =3D attr)
self._v_Docu_Instace =3D Document(TMP)
return self._v_Docu_Instace
=09
hallo =3D "Hallo Michael"
and so on ......
The 2 Files ::::::::::::::::::::::::
test.zpt:
<html>
<head>
<title>BLarg</title>
</head>
<body>
Something<br>
<h1 tal:content=3D"here/doc_type">Page Title</h1>
</body>
test.dtml:
</html>
<dtml-var standard_html_header>
Vorher<br>
<dtml-var doc_type>
Nacher
<dtml-var standard_html_footer>
The raceback :::::::::::::::::::::::::::::::::::::::::::
Traceback (innermost last):
File E:\Beehive\TeDeLine\lib\python\ZPublisher\Publish.py, line 223,=20=
in publish_module
File E:\Beehive\TeDeLine\lib\python\ZPublisher\Publish.py, line 187,=20=
in publish
File E:\Beehive\TeDeLine\lib\python\Zope\__init__.py, line 221, in=20
zpublisher_exception_hook
File E:\Beehive\TeDeLine\lib\python\ZPublisher\Publish.py, line 171,=20=
in publish
File E:\Beehive\TeDeLine\lib\python\ZPublisher\mapply.py, line 160, =
in=20
mapply
(Object: index_html)
File E:\Beehive\TeDeLine\lib\python\ZPublisher\Publish.py, line 112,=20=
in call_object
(Object: index_html)
File=20
=
E:\Beehive\TeDeLine\lib\python\Products\DeTeLineRedaktion\DeTeLineRedaktio=
n.
py, line 50, in index_html
File E:\Beehive\TeDeLine\lib\python\Shared\DC\Scripts\Bindings.py,=20
line 324, in __call__
(Object: test)
File E:\Beehive\TeDeLine\lib\python\Shared\DC\Scripts\Bindings.py,=20
line 354, in _bindAndExec
(Object: test)
File=20
=
E:\Beehive\TeDeLine\lib\python\Products\PageTemplates\PageTemplateFile.py,=
line 162, in _exec
(Object: test)
File=20
E:\Beehive\TeDeLine\lib\python\Products\PageTemplates\PageTemplate.py,=20=
line 156, in pt_render
(Object: test)
File E:\Beehive\TeDeLine\lib\python\TAL\TALInterpreter.py, line 232,=20=
in __call__
File E:\Beehive\TeDeLine\lib\python\TAL\TALInterpreter.py, line 265,=20=
in interpret
File E:\Beehive\TeDeLine\lib\python\TAL\TALInterpreter.py, line 484,=20=
in do_insertText_tal
File E:\Beehive\TeDeLine\lib\python\Products\PageTemplates\TALES.py,=20=
line 301, in evaluateText
File E:\Beehive\TeDeLine\lib\python\Products\PageTemplates\TALES.py,=20=
line 292, in evaluate
Undefined: (see above)
Thanx
---------------------------------------------------------
Michael Kobald
beehive elektronische medien GmbH
Fischerhuettenstr. 79 b
D-14163 Berlin
Tel.: 0 30 / 84 78 20