[Zope] Help! How do I get my namespace in Python??

Andrew Wilcox circle@gwi.net
Tue, 14 Dec 1999 16:40:41 -0500


>> But the DTML Method doesn't have access to the namespace!
>
>What namespace?

The regular DTML namespace, _.

>You probably want the instance's namespace plus the request
>namespace.  If this is the case, you want:
>
>     def test(self, REQUEST=None):
>         return self.myDTMLMethod(self, REQUEST)
>

Nope, doesn't work!

For example, first try a plain DTML Document called "A":

    <dtml-var standard_html_header>
    <dtml-let food="'Popcorn'">
      X says: <dtml-var X>
    </dtml-let>
    <dtml-var standard_html_footer>

which calls a DTML Method called "X":

    My favorite food is <dtml-var food>


Run A and you'll get:

    X says: My favorite food is Popcorn 


Now make a method called "test" which also calls X:

    def test(self, REQUEST=None):
        return self.X(self, REQUEST)

But try to call X through test:

    <dtml-var standard_html_header>
    <dtml-let food="'Popcorn'">
     test says: <dtml-var test>
    </dtml-let>
    <dtml-var standard_html_footer>

and I get:

    Error Type: KeyError
    Error Value: food

See, X can no longer see "food" in the namespace.

Andrew