[Zope3-dev] Q: Custom containers, non-persistent items

Paul Everitt paul at zope-europe.org
Tue Nov 9 17:03:33 EST 2004


First, this is very much a newbie question, so apologies in advance.

I'm trying to fill in the example in 
zope/app/container/sample.py->SampleContainer.  My ultimate goal is to 
traverse a custom container, grab the next item, and look it up in 
Berkeley DB XML.  For example, dbxmlfolder/37 would look up an item "37" 
in the database that "dbxmlfolder" connected to and return some HTML 
that I generate.

SampleContainer has a method _newContainerData where you are supposed to 
supply a mapping.  If I make a product based on this and wire it in, 
returning an empty dictionary, I can browse to dbxmlfolder.  However, as 
soon as I put anything in the dictionary, I get an exception that is a 
bit tough to digest (see below).

I've tried a few things, but I'm clearly flailing.  Thus some questions:

1) Are the keys for this dictionary simple strings?

2) Are the values...errr, special in any way?  For example, can I just 
put instances of Python classes that aren't wired into the CA (so I can 
skip debugging ZCML, interfaces, factories, views, etc. until I get past 
this traceback)?  Stated differently, what is the least amount of work 
to get _newContainerData to return non-empty sample information?

3) What kinds of things in the traceback should provide cues to the 
answer, so I won't be so dumb and bother the list next time?

Traceback
---------

2004-11-09T22:50:48 ERROR SiteError http://localhost:8080/dbxml
Traceback (most recent call last):
   File "/Users/paul/sandboxes/Zope3/src/zope/publisher/publish.py", 
line 135, in publish
     object = request.traverse(object)
   File "/Users/paul/sandboxes/Zope3/src/zope/publisher/browser.py", 
line 507, in traverse
     ob, add_steps = publication.getDefaultTraversal(self, ob)
   File 
"/Users/paul/sandboxes/Zope3/src/zope/app/publication/browser.py", line 
54, in getDefaultTraversal
     adapter = queryViewProviding(ob, IBrowserPublisher, request , None)
   File "/Users/paul/sandboxes/Zope3/src/zope/component/__init__.py", 
line 240, in queryViewProviding
     return queryView(object, '', request, default, providing, context)
   File "/Users/paul/sandboxes/Zope3/src/zope/app/component/hooks.py", 
line 119, in queryView
     providing=providing)
   File 
"/Users/paul/sandboxes/Zope3/src/zope/component/presentation.py", line 
403, in queryView
     r = layer.queryMultiAdapter(objects, providing, name)
   File "/Users/paul/sandboxes/Zope3/src/zope/interface/adapter.py", 
line 452, in queryMultiAdapter
     return factory(*objects)
   File 
"/Users/paul/sandboxes/Zope3/src/zope/app/component/metaconfigure.py", 
line 301, in __call__
     return proxify(self.factory(*objects), self.checker)
TypeError: __init__() takes exactly 1 argument (3 given)

--Paul



More information about the Zope3-dev mailing list