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

Jim Fulton jim@digicool.com
Tue, 14 Dec 1999 21:15:58 +0000


Andrew Wilcox wrote:
> 
> I have a Python method in a product, which in turn calls a DTML Method.
> 
>     def test(self, REQUEST=None):
>         return self.myDTMLMethod(REQUEST)
>
> But the DTML Method doesn't have access to the namespace!

What namespace?
 
> I see I can pass in a mapping to the DTML Method, but how do I get the
> namespace in Python?

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)

DocumentTemplates (of which DTMLMethods are special
cases) take two positional arguments:

  - An object who's attributes are added to the namespace,

  - An object who's keys are added to the namespace.

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.