[Zope] Re: [Zope-dev] Creating a namespace
Casey Duncan
cduncan@kaivo.com
Mon, 29 Jan 2001 09:01:00 -0700
Stephan Richter wrote:
>
> Hello everyone,
>
> I want to make my own name space with the following situation:
>
> class X:
>
> attributes = {'foo': 'bar'}
>
> x = X()
>
> Then I want to use it like that:
>
> <dtml-with x>
> <dtml-var foo>
> </dtml-with>
>
> The result should be : bar
>
> I found out that I have to somehow use TemplateDict and InstanceDict, but I
> have no clue how to use it....Of course there is no documentation on any
> web site or in the Zope code itself....
>
> Thanks for you help!!!
>
> Regards,
> stephan
> --
> Stephan Richter
> CBU - Physics and Chemistry Student
> Web2k - Web Design/Development & Technical Project Management
>
I think the key to your problem is the "mapping" option of dtml-with. If
your class/External method returns a dictionary, you can add it to the
namespace like so:
<dtml-with x mapping>
<dtml-var foo>
</dtml-with>
You do not need to explicitly create a new InstanceDict yourself,
dtml-with takes care of that.
--
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>