[Zope3-Users] Re: How to register a local adapter?
nixon
nxnth at yahoo.com.cn
Sun Jan 6 09:19:02 EST 2008
Thank you, Christophe!
I write code according to your FAQ, but an error occurs.
My code is:
class NewFolderIndex(BrowserPage):
#adapts(IFolder, IMyLayer)
#__call__ = ViewPageTemplateFile('skin/test.pt')
def __call__(self):
self.request.response.setHeader('Content-Type', 'text/plain')
return self.context.name
@adapter(IDatabaseOpenedWithRootEvent)
def RegisterLocalPage(event):
db, conn, root, root_folder = getInformationFromEvent(event)
for city in root_folder:
sm = root_folder[city].getSiteManager()
sm.registerAdapter(NewFolderIndex, [IFolder, IMyLayer], IBrowserPage, 'index.html')
transaction.commit()
conn.close()
Zope starts up without any issue. But when I access the 'index.html', an error occurs:
Traceback (most recent call last):
File "D:\wp\Python24\Lib\site-packages\zope\publisher\publish.py", line 130, i
n publish
obj = request.traverse(obj)
File "D:\wp\Python24\Lib\site-packages\zope\publisher\browser.py", line 527, i
n traverse
ob, add_steps = publication.getDefaultTraversal(self, ob)
File "D:\wp\Python24\Lib\site-packages\zope\app\publication\browser.py", line
66, in getDefaultTraversal
return ob.browserDefault(request)
ForbiddenAttribute: ('browserDefault', <mailnice.reglocalpage.NewFolderIndex obj
ect at 0x027F8BF0>)
I dont know why. It seems the inherited BrowserPage.browserDefault is available.
Thank you!
R Nixon
---------------------------------
ÑÅ»¢ÓÊÏä´«µÝÐÂÄê×£¸££¬¸öÐԺؿ¨ËÍÇ×Åó£¡
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20080106/07915362/attachment.htm
More information about the Zope3-users
mailing list