dtml access to the instance data
Hi! I'm having strange problems with simple dtml example: ===== test.py # -*- python -*- file # $Id$ # # Copyright (C) 1999 by Andrey V Khavryutchenko <akhavr@compchem.kiev.ua> import DocumentTemplate class Test: title = 'Test page' index_html = DocumentTemplate.HTMLFile('test.dtml') t = Test() print t.index_html() ===== test.dtml <html> <head><title><!--#var head--></title></head> <body> <p>This is a test </body> </html> [akhavr@netmaster] ZTemplates-2.3.0$ python test.py Traceback (innermost last): File "test.py", line 13, in ? print t.index_html() File "DocumentTemplate/DT_String.py", line 514, in __call__ return render_blocks(self.blocks,md) File "DocumentTemplate/pDocumentTemplate.py", line 244, in render_blocks if type(section) is StringType: section=md[section] File "DocumentTemplate/pDocumentTemplate.py", line 209, in __getitem__ v=self.dicts[key] File "DocumentTemplate/pDocumentTemplate.py", line 178, in __getitem__ raise KeyError, key KeyError: head Obviously, I do not understand some fundamentals. Can anyone give me a hint? TIA. -- SY, Andrey V Khavryutchenko http://www.kbi.kiev.ua/~akhavr Shick's Law: There is no problem a good miracle can't solve.
Hi! On 2 Apr 1999, Andrey V Khavryutchenko wrote:
import DocumentTemplate
class Test: title = 'Test page' index_html = DocumentTemplate.HTMLFile('test.dtml')
t = Test() print t.index_html()
After creating template, you should call it: print t.index_html(...my-data-here...) If you need an example, I can send you ZIP-file with some examples. Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN.
participants (2)
-
Andrey V Khavryutchenko -
Oleg Broytmann