[Zope] ZClass container acquisition

John D. Rowell jdrowell@appwatch.com
Mon, 24 Apr 2000 19:34:21 -0700


On Mon, Apr 24, 2000 at 08:18:00PM -0400, Kapil Thangavelu wrote:
> jd, about renderable Zclasses, try inheriting from the Renderable
> Product which basically implements python hooks for __call__, with that
> and a render method (i normally define it as index_html) you can render
> your ZClasses directly in dtml:
> 
> 	<dtml-var YourZClass>
> 	
> 	or
> 
> 	<dtml-in "ObjectItems(['YourZClass'])">
> 	<dtml-var sequence-item>
> 	</dtml-in>

Thanks Kapil, I'll try that. BTW, is there any way to modify the class
to add another base class without starting from scratch?

Also, I'm having problems with acquisition that may be related to forcing 
the client when rendering ZClasses:

	- ZBox is a ZClass that renders fancy boxes
	- standard_html_header in the root folder uses ZBox (using the
          <dtml-var "zclass.method(zclass, _)"> syntax)
	- ZLeaf is a folder-aware DTML Document that creates links to
	  other documents in that folder as part of a toolbar. It uses
	  the standard_html_header in that folder, which calls the root
	  standard_html_header (thru PARENT)

When I render my ZLeaf, I get a ErrorValue: __call__ error in the ZBox
class (instance). All of the index_html is rendered ok, only the ZBox
bombs. The, even weirder:

	- index_html on root (calling the ZBox)
	- folder f (no index_html)

Trying to access the URL "http://server/f" gives exactly the same error.
This looks like if I acquire a DTML Document that contains a ZClass, it
will fail, while calling that document directly succeeds.

The dump:

--------

Error Type: AttributeError
Error Value: __call__

Traceback (innermost last):
  File /home/jdrowell/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py,
line 214, in publish_module
  File /home/jdrowell/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py,
line 179, in publish
  File /home/jdrowell/Zope-2.1.6-src/lib/python/Zope/__init__.py, line
202, in zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File /home/jdrowell/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py,
line 165, in publish
  File /home/jdrowell/Zope-2.1.6-src/lib/python/ZPublisher/mapply.py,
line 160, in mapply
    (Object: index_html)
  File /home/jdrowell/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py,
line 102, in call_object
    (Object: index_html)
  File /home/jdrowell/Zope-2.1.6-src/lib/python/OFS/DTMLDocument.py,
line 166, in __call__
    (Object: index_html)
  File
/home/jdrowell/Zope-2.1.6-src/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
    (Object: index_html)
  File
/home/jdrowell/Zope-2.1.6-src/lib/python/DocumentTemplate/DT_Util.py,
line 335, in eval
    (Object: box_search.index_html(box_search, _))
    (Info: box_search)
  File <string>, line 0, in ?
  File /home/jdrowell/Zope-2.1.6-src/lib/python/OFS/DTMLMethod.py, line
150, in __call__
    (Object: index_html)
  File
/home/jdrowell/Zope-2.1.6-src/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
    (Object: index_html)
AttributeError: (see above)

------

I'm using workarounds to handle this problem, but would much rather use
a straight approach. Any hints?

Thanks,
jdrowell
	
-- 
John Douglas Rowell            Home of jdfetch 0.4.0, jdresolve 0.5.2,
me@jdrowell.com                jdrinfo 0.2, jdtracker 0.11 and
http://www.jdrowell.com        jdwhatsnew 0.21
Member of the AppWatch staff - http://appwatch.com - staff@appwatch.com