[Zope3-Users] Extending the Buddy demo
Adam Summers
adam at 4js.com.au
Tue Dec 28 10:19:18 EST 2004
Hi,
Can someone help me with the following problem:
I wanted to add methods to the Buddy and BuddyFolder objects, which
do nothing more than return a "hello world" message that I can use in a
zpt page
So, I have added the following to the IBuddy and IBuddyFolder class
definitions
def hello():
"""Displays a hello world message"""
and then in the Buddy and BuddyFolder class Definitions:
def hello(self):
return "Hello World"
and then I have the following zpt page (helloF.zpt):
<html metal:use-macro="context/@@standard_macros/page"
i18n:domain="buddydemo">
<body><div metal:fill-slot="body">
<table>
<caption i18n:translate="">Buddy Folder Hello</caption>
<tr> <td tal:content="*context/hello*">hiya</td>
</tr>
</table>
</div></body></html>
and I have a page definition in the configure.zcml:
<browser:page
for=".interfaces.IBuddyFolder"
name="hello.html"
class=".buddy.BuddyFolder"
template="hello.pt"
permission="zope.ManageContent"
/>
calling the hello method for a buddy works fine, but when I try and
use the "context/hello" directive for the BuddyFolder (via hello.html) I
get the following error:
2004-12-29T02:15:49 ERROR SiteError
http://demo:8080/testF/buddyF/hello.html
Traceback (most recent call last):
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/publisher/publish.
py", line 135, in publish
object = request.traverse(object)
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/publisher/browser.
py", line 493, in traverse
ob = super(BrowserRequest, self).traverse(object)
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/publisher/http.py"
, line 381, in traverse
ob = super(HTTPRequest, self).traverse(object)
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/publisher/base.py"
, line 258, in traverse
subobject = publication.traverseName(
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/app/publication/pu
blicationtraverse.py", line 56, in traverseName
ob2 = adapter.publishTraverse(request, nm)
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/app/container/trav
ersal.py", line 73, in publishTraverse
view = zapi.queryView(self.context, name, request)
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/app/component/hook
s.py", line 116, in queryView
providing=providing)
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/component/presenta
tion.py", line 403, in queryView
r = layer.queryMultiAdapter(objects, providing, name)
File
"/home/adam/ZopeX3-3.0.0/build/lib.linux-i686-2.4/zope/interface/adapter.
py", line 470, in queryMultiAdapter
return factory(*objects)
TypeError: __init__() takes exactly 1 argument (3 given)
192.168.168.1 - zope.manager [29/Dec/2004:02:15:49 +1100] "GET
/testF/buddyF/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"
Is anyone able to help with this, by explainign what I should be doing
if I want to have methods against containers? Whilst this in itself is a
trivial example, I need to have this understanding.
Thanks in advance,
Adam
More information about the Zope3-users
mailing list