[Zope] Dynamic DTML

peter sabaini sabaini@inode.at
Fri, 04 Oct 2002 11:04:57 +0200


i use this; i got a class:

  -- snip --

class DTMLStringAttribute(PlainTextAttribute):
     'An attribute which renders itself as a DTML Template (i.e. it 
returns an object)'
     def render(self):
         s = self.d
         h = Globals.HTML(s, __name__='DTMLStringAttribute_%s' % self.name)
         return h

  -- snip --

ie. i instantiate a Globals.HTML object with a string s (containing 
DTML). you can then call this object to get it interpreted.

caveat: this is rather slow. use sparingly.

cheers, peter.

Chris Beaven wrote:
> I think that the question was "I have DTML source in a database. Can I
> retrieve and render this source?" (which seems rather dangerous to me, but
> anyway...
> 
> You'd have to look at creating a DTMLDocument object (in memory), insert the
> source, then call it (which will render it).
> I wouldn't know where to start :) but maybe someone else can help add to the
> conversation.
> 
> 
> -----Original Message-----
> From: Russell Hires [mailto:rhires@earthlink.net]
> Sent: Friday, 4 October 2002 2:16 p.m.
> To: Colin Fox
> Cc: zope@zope.org
> Subject: Re: [Zope] Dynamic DTML
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> You mean the Zope book says nothing about this? Hmmm...
> try this: 
> http://www.zope.org/Documentation/Books/ZopeBook/current/RelationalDatabases
> .stx
> 
> HTH
> 
> Russell
> 
> On Thursday 03 October 2002 21:16 pm, you wrote:
> 
>>Hi, all.
>>
>>I have some dtml stored in an SQL table. I would like to be able to
>>retrieve it and execute it. I can't find any documentation on this - I
>>seem to remember something about eval, but I can't find anything.
>>
>>Also - I would like to be able to do this from a PythonScript.
>>
>>Thanks!
>>  Colin
> 
> 
> - -- 
> Linux -- the OS for the Renaissance Man 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> 
> iD8DBQE9nPnYAqKGrvVshJQRAiUbAKDiWIAQyEgzXzhMCwBqzE8ePkFsEACeKdzS
> Hco16Bc8AOuIJSL4gSeOxaI=
> =W+GI
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
> 
>