Reputation: 21914
How do you render a Zope DTML from the REPL say without the Folder Object or anything like that for a test case ?
I have a file called /tmp/tmp.dtml with the following content:
<dtml-var test>
I could get this far :
from AccessControl import ImplC as impl
from App.special_dtml import DTMLFile
#globals has test variable define if that helps?
dtml_page = DTMLFile('/tmp/tmp',globals())
dtml_page() give "None\n"
How do I inject the right namespace into DTMLFile object or during invokation ?
Upvotes: 2
Views: 120
Reputation: 21914
This seems to work . I wanted to mock it without Folder though .
class Test(Folder):
test = "World"
dtml = DTMLFile('/tmp/tmp')
dtmlobj = Test()
dtmlobj.dtml()
Class inherited from Folder seems to be important here for not-so-clear reasons ?
I am not getting the significance of why the Test.test where Test is inherited from Folder to render . Is this some type of a Zope convention ?
I tried
dtml = DTMLFile('/tmp/tmp')
setattr(dtml,'test','foo')
dtml.render()
I though it was about "self" having the right variables but apparently not .
Upvotes: 0