Re: [Zope] Black Magic
In article <00e801c032ea$50b15970$[EMAIL PROTECTED]>, Evan Simpson <[EMAIL PROTECTED]> writes >From: Fred Yankowski <[EMAIL PROTECTED]> >> The information you just provided about the DTML Method "call >> signature" and the like is very useful. Is this kind of reference >> material written down somewhere in a guide/how-to/wiki/...? > >The only thing I could find offhand is >http://www.zope.org//Wikis/DevSite/Projects/PythonMethods/NamespaceObjectInterfa >ce, which I wrote. >I don't know if ZDP or someone else has documented it. > >Cheers, > >Evan @ digicool & 4-am OK so I have a similar but still to me confusing problem I have a Product P containing two folderish ZClasses A and B. A and B both have class specific methods A_init and B_init to initialise specific bits of each. The product P has some methods eg M defined which are useful to both A and B. 1) How do I make the add methods behave identically whether I invoke as /dir/manage_addProduct/P/A_add or when I invoke from the manage add interface. I want to know the meta_type of the actual location where the product will appear not the factory's meta_type. 2) When I attempt to call B_add from inside A's private method A_init I seem to see a completely different context from when I call B_add directly on an instance of A. 3) I suppose this is related to the fact that inside A_init (the private method) I don't seem to see the same context as in A_add, ie the method M is visible in A_add, but not in A_init. How do ZClass contexts and the product context relate? -- Robin Becker ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Black Magic
From: Fred Yankowski <[EMAIL PROTECTED]> > The information you just provided about the DTML Method "call > signature" and the like is very useful. Is this kind of reference > material written down somewhere in a guide/how-to/wiki/...? The only thing I could find offhand is http://www.zope.org//Wikis/DevSite/Projects/PythonMethods/NamespaceObjectInterface, which I wrote. I don't know if ZDP or someone else has documented it. Cheers, Evan @ digicool & 4-am ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Black Magic
Evan, The information you just provided about the DTML Method "call signature" and the like is very useful. Is this kind of reference material written down somewhere in a guide/how-to/wiki/...? I tried to figure out the call signature of a Python method by having the called function use just "(*varargs, **kwargs)" as formal parameters, but the inscrutable mapply() function seems to thwart that effort as mapply() adjusts the function call according to what parameters the called function (or callable object, ...) expects. Very weird. Is there some document that covers the how and why of mapply()? On Tue, Oct 10, 2000 at 11:17:13AM -0400, Evan Simpson wrote: > 1. DTML Methods' __call__ signature is (client=None, REQUEST={}, > RESPONSE=None, **kw). The client, REQUEST, and keyword arguments > are layered to form the namespace for the Method, with the keywords > on top, then the client, then REQUEST. ... -- Fred Yankowski [EMAIL PROTECTED] tel: +1.630.879.1312 Principal Consultant www.OntoSys.com fax: +1.630.879.1370 OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Black Magic
From: Chris Withers <[EMAIL PROTECTED]> > Pierre-Julien Grizel wrote: > > It seems that in fact the DTML document doesn't actually pass _.None and > > _ to my object. WHY ?? > > This is deep voodoo that I don't fully understand. To me, it appears > that what you get depends on how your __call__ was called... > > The arguments vary dependign on whether: > -you were called from a bit of DTML > -traversed directly through a URL > -called from soem python you wrote Here's the scoop: 1. DTML Methods' __call__ signature is (client=None, REQUEST={}, RESPONSE=None, **kw). The client, REQUEST, and keyword arguments are layered to form the namespace for the Method, with the keywords on top, then the client, then REQUEST. 2. If you call a DTML Method in a Python expression, its namespace will be empty unless you explicitly pass a client, REQUEST, and/or keyword arguments. 3. URL traversal automatically tries to look up parameter names in the REQUEST. Both REQUEST and RESPONSE are found in REQUEST, so they are passed to the Method. 4. When an object is named in the name attribute of a DTML tag, the DTML code checks to see whether the object is callable and has a true attribute called "isDocTemp". If so, it passes the namespace to the REQUEST parameter. Otherwise, if the object is callable it calls it with no arguments. Thus, to simulate in Python code, including DTML expressions, you must either use "obj(_.None, _)" or "obj(REQUEST=_)". Cheers, Evan @ digicool & 4-am ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Black Magic
Pierre-Julien Grizel wrote: > It seems that in fact the DTML document doesn't actually pass _.None and > _ to my object. WHY ?? This is deep voodoo that I don't fully understand. To me, it appears that what you get depends on how your __call__ was called... The arguments vary dependign on whether: -you were called from a bit of DTML -traversed directly through a URL -called from soem python you wrote Maybe someone from DC could shed some light on 'the rules' or point us to soem documentation? cheers, Chris ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )