[Zope-dev] Help, please!!! __call__ problems with DTML templates
Evan Simpson
evan@4-am.com
Tue, 10 Oct 2000 14:29:40 -0400
From: Stephen Simmons <stephen.simmons@healtharena.net>
> 1.) How do you magically get the DTML context from '<dtml-var A>' without
> having to resort to '<dtml-var "A(_,REQUEST)">' in the templates?
A.isDocTemp = 1 # or make it a shared class attribute
> 2.) How to convert an arbitrary text string into rendered DTML inside a
> python product method?
Here's what I use:
from Globals import HTML
from AccessControl import getSecurityManager
class DTML(HTML):
"""DTML objects are DocumentTemplate.HTML objects that allow
dynamic, temporary creation of restricted DTML."""
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
"""Render the DTML given a client object, REQUEST mapping,
Response, and key word arguments."""
security=getSecurityManager()
security.addContext(self)
try:
return apply(HTML.__call__, (self, client, REQUEST), kw)
finally: security.removeContext(self)
def validate(self, inst, parent, name, value, md):
return getSecurityManager().validate(inst, parent, name, value)
Cheers,
Evan @ digicool & 4-am