[Zope] How to render tales in strings in a script

Dieter Maurer dieter@handshake.de
Wed, 8 Jan 2003 22:51:43 +0100


Elena Schulz wrote at 2003-1-8 15:51 +0100:
 > ...
 > I need to render a string (not a zpt-object) with tales like <img
 > tal:attributes="src here/images/spacer.gif/absolute_url"
 > src="spacer.gif" alt="" title="" border="0" width="1" height="15" />.
 > 
 > Does anybody know how to do this in a script? I already know how to import
 > PageTemplate.py and it should work with
 > read() or pt_render() or document_src() but it does'nt. :( I get
 > unauthorized errors.
Not a very big problem in an External Method:

  You create a Zope Page Template object, wrap it into a context
  (using its "__of__" method) and then call it.

Few chances in an (internal) Python Script, as you will not be allowed
to call "__of__".
Without this "__of__", the template has no way to know its
context (e.g. "here", "container", ...).


Dieter