[Zope3-Users] Extending the Buddy demo -- adding BuddyFolder.hello() method how?

Florian Lindner mailinglists at xgm.de
Wed Dec 29 06:51:42 EST 2004


Am Mittwoch, 29. Dezember 2004 05:16 schrieb Adam Summers:
> Hi,
>
>     Thanks for your tip Dominik - I understand what you mean, however I
> still have a problem with calling the method in my BuddyFolder class:
> My interface is:
>
>     class IBuddyFolder(IContainer, IContentContainer):
>
>     def __setitem__(name, object):
>         """Add a buddy"""
>
>     __setitem__.precondition = ItemTypePrecondition(IBuddy)
>
>     def hello():
>         """Return list of buddy names"""
>
> My Implementation is:
>
>     class BuddyFolder(BTreeContainer):
>     zope.interface.implements(IBuddyFolder)
>
>     __used_for__ = IBuddyFolder
>
>     def hello(self):
>         return "Hello World"
>
> And my configuration is:

I think you also need to register the interface:

<interface interface=".interfaces.IBuddyFolder" 
type="zope.app.content.interfaces.IContentType" />

>     <content class=".buddy.BuddyFolder">
>         <require permission="zope.View"
>             interface="zope.app.container.interfaces.IReadContainer" />
>         <require permission="zope.ManageContent"
>             interface="zope.app.container.interfaces.IWriteContainer" />
>     </content>

>   File
> "/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/app/container/trav
> ersal.py", line 99, in traverse
>     raise NotFoundError, name
> NotFoundError: 'hello'
> 192.168.168.1 - zope.manager [29/Dec/2004:15:24:22 +1100] "GET
> /testF/nwF/hello.
> html HTTP/1.1" 200 292 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1;
> en-US; rv:1.
> 7.5) Gecko/20041107 Firefox/1.0"

HTH

Florian


More information about the Zope3-users mailing list