TypeError: __init__() takes exactly 5 arguments (3 given)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmala
    New Member
    • Aug 2013
    • 5

    #1

    TypeError: __init__() takes exactly 5 arguments (3 given)

    Hi everyone

    I m trying to hide plone 4.3 default logo from the file system using viewlets. Here is my code which inherits the default code of viewlets from eggs directory. (i.e /eggs/plone.app.layou t-2.3.4-py2.7.egg/plone/app/layout/viewlets/common.py ->class LogoViewlet(Vie wletBase)

    Code:
    [B]common.py[/B]
    
    
    from cgi import escape
    from datetime import date
    from urllib import unquote
    
    from plone.memoize.view import memoize
    from zope.component import getMultiAdapter
    from zope.deprecation.deprecation import deprecate
    from zope.i18n import translate
    from zope.interface import implements, alsoProvides
    from zope.viewlet.interfaces import IViewlet
    
    from AccessControl import getSecurityManager
    from Acquisition import aq_base, aq_inner
    
    from Products.CMFCore.utils import getToolByName
    from Products.CMFPlone.utils import safe_unicode
    from Products.Five.browser import BrowserView
    from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
    from Products.CMFPlone import PloneMessageFactory as _
    
    from plone.app.layout.globals.interfaces import IViewView
    
    
    class ViewletBase(BrowserView):
        """ Base class with common functions for link viewlets.
        """
        implements(IViewlet)
    
        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
    
        @property
        @deprecate("Use site_url instead. ViewletBase.portal_url will be removed in Plone 4")
        def portal_url(self):
            return self.site_url
    
        def update(self):
            self.portal_state = getMultiAdapter((self.context, self.request),
                                                name=u'plone_portal_state')
            self.site_url = self.portal_state.portal_url()
            self.navigation_root_url = self.portal_state.navigation_root_url()
    
        def render(self):
            # defer to index method, because that's what gets overridden by the template ZCML attribute
            return self.index()
    
        def index(self):
            raise NotImplementedError(
                '`index` method must be implemented by subclass.')
    
    
    
    class LogoViewlet(ViewletBase):
        index = ViewPageTemplateFile('logo.pt')
    
        def update(self):
            super(LogoViewlet, self).update()
    
            portal = self.portal_state.portal()
            bprops = portal.restrictedTraverse('base_properties', None)
            if bprops is not None:
                logoName = bprops.logoName
            else:
                logoName = 'logo.jpg'
    
            logoTitle = self.portal_state.portal_title()
            self.logo_tag = portal.restrictedTraverse(logoName).tag(title=logoTitle, alt=logoTitle)
            self.navigation_root_title = self.portal_state.navigation_root_title()
    Code:
    [B]createPictMenu.py:[/B]
    (i m pasting here only the class which is for inherting the default viewlets code from the eggs directory.)
    
    class LogoViewlet(ViewletBase, bdrMenuView):         
        def __init__(self, context, request, view, manager):
             super(LogoViewlet, self).__init__(context, request, view, manager )
             self.__parent__ = view
             self.context = context
             self.request = request
             self.view = view
             self.manager = manager
        
        def index(self):  
            print "**************Hai I am from viewlet class method*************"
            return self.createPictMenu()
    while running i m getting this error:
    Code:
    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 exactly 5 arguments (3 given)

    can anyone tell whats wronng with the code. Please correct me as soon as possible.


    regards

    Nirmala Sudhir
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You haven't told us which line of code is throwing the error but the message itself is fairly clear. It's saying you called a function that requires 5 values but you only gave it 3.

    Comment

    • nirmala
      New Member
      • Aug 2013
      • 5

      #3
      Type Error: __init__() takes exactly 5 arguments (3 given) in python

      Originally posted by Rabbit
      You haven't told us which line of code is throwing the error but the message itself is fairly clear. It's saying you called a function that requires 5 values but you only gave it 3.
      Hi

      Can you please edit the line which is wrong in my code.I tried as lot but its not working

      thanks
      Nirmala Sudhir

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        We need you to tell us which line is throwing the error. Look through the error messages and compare it with the line numbers in your code.

        Comment

        Working...