我正在使用viewlets
。我的想法是用我自己的徽标,菜单,地址栏等方式覆盖默认的plone网站。我在我自己的viewlet
文件中使用了默认的createPictMenu.py
代码。 brundelre3/eggs/plone.app.layout-2.3.4-py2.7.egg/plone/app/layout/viewlets/common.py ->class LogoViewlet(ViewletBase):
我的createPictMenu.py看起来像这样
class bdrMenuView(LogoViewlet):
template = ViewPageTemplateFile('templates/main_page.pt')
def __init__(self, context, request, view, manager=None):
super(ViewletBase, self).__init__(context, request)
self.__parent__ = view
self.context = context
self.request = request
self.view = view
self.manager = manager
def main_page(self):
return self.template()
这里LogoViewlet是我从egg文件夹下的common.py继承的类。
它成功地用我的菜单替换了plone.logo。我在localhost:8086/brundelre3/@@manage-viewlets
但是当我运行我的项目localhost:8086/brundelre3/main_page.html
时显示错误
错误讯息:
2013-08-14 11:18:19 ERROR Zope.SiteErrorLog 1376459299.050.254417887359 http://localhost:8086
/brundelre3/main_page.html
Traceback (innermost last):
Module ZPublisher.Publish, line 115, in publish
Module ZPublisher.BaseRequest, line 501, in traverse
Module ZPublisher.BaseRequest, line 346, in traverseName
Module ZPublisher.BaseRequest, line 116, in publishTraverse
Module zope.component._api, line 120, in queryMultiAdapter
Module zope.component.registry, line 238, in queryMultiAdapter
Module zope.interface.adapter, line 532, in queryMultiAdapter
TypeError: __init__() takes at least 4 arguments (3 given)
有人能说出这段代码的错误吗?
答案 0 :(得分:0)
我看到了一些问题,但没有更多信息,很难确切知道哪一个导致了这个错误。我的猜测是它与super
的行不应该传递view
参数。我相信这里也是一个拼写错误(应该是super(bdrMenuView, self)
,而不是super(ViewletBase, self)
)。
试用这个修订版:
class bdrMenuView(LogoViewlet):
template = ViewPageTemplateFile('templates/main_page.pt')
def __init__(self, context, request, view, manager=None):
super(bdrMenuView, self).__init__(context, request, view)
self.__parent__ = view
self.context = context
self.request = request
self.view = view
self.manager = manager
def main_page(self):
return self.template()