[Zope] Namespace within a product... (argh...)

2000-10-10 Thread Pierre-Julien Grizel



Well, beeing very straightforward, I read this, in
OSFP/Help/DTMLDocument.py :


"""
A DTMLDocument implicitly pass itself as a client argument in
addition to the specified client, so names are looked up in
the DTMLDocument itself.

Passing in a namespace to a DTML Document is often referred to
as providing the Document with a *context*.

DTML Documents are called three ways:

  From DTML -- A DTML Document can be called from another DTML
Method or Document::

  

  

In this example, the Document 'aDTMLDocument' is being
called
from another DTML object by name.  The calling method
passes the value 'this' as the client argument and the
current DTML names pace as the REQUEST argument.  The above
is identical to this following usage in a DTML Python
expression::

  

  

  From Python -- Products, External Methods, and PythonMethods 
can call a DTML Document in the same way as calling a DTML
Document from a Python expression in DTML; as shown in the
previous example.

  By the Publisher -- When the URL of a DTML Document is fetched 
from Zope, the DTML Document is called by the publisher.
The REQUEST object is passes as the second argument to the 
Document.  
"""

So - I had a look at DTMLDocument.py and saw the following method :

def __call__ (self, client = None, REQUEST = {}, **kw):
...

SO - I try to create this method for my product :

def __call__ (self, client = None, REQUEST = {}, **kw):
print client
print REQUEST


and it prints :
None
{}


It seems that in fact the DTML document doesn't actually pass _.None and
_ to my object. WHY ??

How can I enforce DTML Docs/Meths to pass it anyway ???



Many thanks,


P.-J.




-- 
If the only tool you have is a hammer, 
you tend to see every problem as a nail.
Si le seul outil dont vous disposez est un marteau, 
vous avez tendance à voir chaque problème comme un clou. 
   --Abraham Maslow

___
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] Namespace within a product... (argh...)

2000-10-10 Thread Lalo Martins

On Tue, Oct 10, 2000 at 11:56:11AM +0200, Pierre-Julien Grizel wrote:
> 
> So - I had a look at DTMLDocument.py and saw the following method :
> 
> def __call__ (self, client = None, REQUEST = {}, **kw):
>   ...
> 
> SO - I try to create this method for my product :
> 
> def __call__ (self, client = None, REQUEST = {}, **kw):
>   print client
>   print REQUEST
> 
> 
> and it prints :
> None
> {}
> 
> 
> It seems that in fact the DTML document doesn't actually pass _.None and
> _ to my object. WHY ??

Evan already answered, but the short story is:

your object needs to have an attribute (it may be a class
attribute and usually is) named "isDocTemp", and this attribute
must evaluate to true. Otherwise, your object is called with no
parameters.

The relevant code is:

if hasattr(v,'isDocTemp') and v.isDocTemp:
v=v(None, self)
else:
try: v=v()
except (AttributeError,TypeError): pass

(from DocumentTemplate/DT_Util.py:277)

[]s,
   |alo
   +
--
  Hack and Roll  ( http://www.hackandroll.org )
News for, uh, whatever it is that we are.


http://zope.gf.com.br/lalo   mailto:[EMAIL PROTECTED]
 pgp key: http://zope.gf.com.br/lalo/pessoal/pgp

Brazil of Darkness (RPG)--- http://zope.gf.com.br/BroDar

___
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 )