[Zope-dev] Creating a namespace
Steve Alexander
steve@cat-box.net
Sun, 28 Jan 2001 11:07:46 +0000
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
If you use
<dtml-with x mapping>
<dtml-var foo>
</dtml-with>
You will get the result you want.
For the other stuff, look in DocumentTemplate/pDocumentTemplate.py. The
python code is pretty clear, although the C version is what is normally
used in Zope.
Otherwise, see DocumentTemplate/DT_Util.py and DT_With.py, or see how it
is done in ZPatterns in Expressions.py.
By the way, I notice you posted this to zope@zope.org and
zope-dev@zope.org. If you look in the standard footer of each email from
both lists, you'll see this:
** No cross posts or HTML encoding! **
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net