Mick wrote:
> Hi,
> I am trying to make a product act like an external method, or dtmlmethod.
> Basically I have taken the minimal product and added a __call__ function.
> It works fine, and can be called as a function of the object that contains
> it.  The problem is that the minimal objects namespace is also pushed onto
> the stack, and to get out of it I need to go through self.aq_parent.
> Reading though all the help I could find I tried adding the following (as
> DTMLMethod suggests.)

Yes, the current object is at the top of the namespace in general.

DTML Methods get around this with the client argument which defaults to
None. AFAIK This represents the containment namespace to use for

> #Documents masquerade as functions
> class func_code: pass
> func_code=func_code()
> func_code.co_varnames='self','RQUEST','RESPONSE'
> func_code.co_argcount=3

>From what I read, this tells ZPublisher what arguments to pass by
default to the object when it is called by traversal. Since client is
omitted from co_varnames, it defaults to None, which tells the DT_String
machinery (Which executes the DTML code) to do a "containment-less"

The DTML "interpreter" just does lookups though a namespace mapping
passed in. Perhaps you could do something similar in your

> This doesn't seem to do anything to the namespace problem.  Actually,
> reading through DTMLMethod and ExternalMEthod aren't helping at all.
> mapply.py seems equally unhelpful, though I can see some of what it is
> trying to do.  Reading it also made me wonder why people say the above code
> make Documents masquerade as functions, it seems in mapply, that if __call__
> is defined, then it is bound to f in mapply anyway.  It seems to me to be in
> the __call__ method that things are important where namespaces are passed to
> HTML.__call__
> I am obviously missing some fundamental points or sequences that would help
> me to understand this, I was hoping someone could point me in the right
> direction, either documentation, or some simple explanation, that would make
> reading through that code more obvious.
> I am running Zope 2.4.0b2 on python 2.1.
> regards
> Mick

| Casey Duncan
| Kaivo, Inc.

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to