类型错误:__init__()接受至少4个参数(3个给定参数)

时间:2022-11-29 19:34:15

I m working with viewlets. My idea is to override the default plone site with my things like my own logo, my menus, my address bar ,etc. I used the default viewlet code in to my own createPictMenu.py file. The code which is in brundelre3/eggs/plone.app.layout-2.3.4-py2.7.egg/plone/app/layout/viewlets/common.py ->class LogoViewlet(ViewletBase):

我正在处理viewlet。我的想法是用我自己的标志,我的菜单,我的地址栏等来覆盖默认的plone网站。我在自己的createPictMenu中使用了默认的viewlet代码。py文件。代码在brundelre3/eggs/plone.app.layout-2.3.4-py2.7.egg/plone/app/layout/viewlet /common中。py - >类LogoViewlet(ViewletBase):

My createPictMenu.py looks like this

我的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()

Here LogoViewlet is the class which i inherit from common.py which is under eggs folder. It successfully replaces the plone.logo with my menus. I saw it under localhost:8086/brundelre3/@@manage-viewlets

这里LogoViewlet是我从common继承的类。在鸡蛋文件夹下的py。它成功地取代了plone。商标和菜单。我在localhost:8086/brundelre3/@ manage-viewlet下看到了它

But when i run my project localhost:8086/brundelre3/main_page.html its showing error

但是当我运行我的项目localhost:8086/brundelre3/main_page时。html的显示错误

Error Message :

错误信息:

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)

Can anyone tell whats wrong with this code?

有人知道这段代码有什么问题吗?

1 个解决方案

#1


0  

I see a few issues, but without more information it's hard to know exactly which one is causing this error. My guess is that it's the line with super that's not passing the view parameter when it should be. I believe there's also a typo here (should be super(bdrMenuView, self), not super(ViewletBase, self)).

我看到了一些问题,但是如果没有更多的信息,很难确切地知道是哪个问题导致了这个错误。我的猜测是,它是与super的线,它不传递视图参数。我认为这里也有一个错误(应该是super(bdrMenuView, self),而不是super(ViewletBase, self))。

Try out this revised version:

试试这个修订版:

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()

#1


0  

I see a few issues, but without more information it's hard to know exactly which one is causing this error. My guess is that it's the line with super that's not passing the view parameter when it should be. I believe there's also a typo here (should be super(bdrMenuView, self), not super(ViewletBase, self)).

我看到了一些问题,但是如果没有更多的信息,很难确切地知道是哪个问题导致了这个错误。我的猜测是,它是与super的线,它不传递视图参数。我认为这里也有一个错误(应该是super(bdrMenuView, self),而不是super(ViewletBase, self))。

Try out this revised version:

试试这个修订版:

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()