[Zope] python ignorance shining through...
Tony McDonald
tony.mcdonald@ncl.ac.uk
Tue, 14 Sep 1999 13:48:29 +0100
At 1:09 pm +0100 14/9/99, Phil Harris wrote:
>Hi tone
>
>If I understand correctly you want to get the contents of an object but you
>only have the name and not a reference to it, correct?
corrrrect!
>If that is the case then try this:
>
>try:
> template_str = eval("self.RENDER.%s.read_raw()" % tagclass)
> template = DocumentTemplate.HTML(template_str)
> theresult = template(self, content=content)
> return theresult
>except KeyError:
> return "no renderer for %s" % tagclass
>
>The eval will take a string and evaluate it in the current context, this
>should use the contents of tagclass to create a callable reference to that
>tagclass object.
sweeeet!
(I actually changed the last bit to
except:
pass
as I had some additional processing to do...).
Nice one Phil, one I owe yer mate! :)
Tone.
------
Dr Tony McDonald, FMCC, Networked Learning Environments Project
http://nle.ncl.ac.uk/
The Medical School, Newcastle University Tel: +44 191 222 5888
Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2