Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4322104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:49:51+00:00 2026-05-21T08:49:51+00:00

I’m writing a custom view to get around the bug that displays the wrong

  • 0

I’m writing a custom view to get around the bug that displays the wrong start and end times for events in table view in Plone 4. However, when I call my view I get the following error:

Traceback (innermost last):
Module ZPublisher.Publish, line 116, in publish
Module ZPublisher.BaseRequest, line 498, in traverse
Module ZPublisher.BaseRequest, line 343, in traverseName
Module ZPublisher.BaseRequest, line 110, in publishTraverse
Module zope.component._api, line 122, in queryMultiAdapter
Module zope.component.registry, line 240, in queryMultiAdapter
Module zope.interface.adapter, line 522, in queryMultiAdapter
TypeError: __init__() takes exactly 2 arguments (3 given)

It’s been awhile since I’ve created a view, but I thought (in accordance with this) that __init__() does take 3 arguments (self, context, request). At any rate here’s what my BrowserView class looks like at the moment:

class NewEventsView(BrowserView):
    """Custom View for displaying events in a table with correct times"""

    implements(INewEventsView)

    def getCurrentEvents(self):
        """Method to return all active events in order"""
        current_events = []
        cat = getToolByName(self.context, 'portal_catalog')
        brains = cat(portal_type='Event', review_state='published', sort_on='start')
        for x in brains:
            event = x.getObject()
            if event.startDate > DateTime():
                current_events.append(event)
        return current_events

I’ve tried different variations of this adding an __init__ as in the above mentioned page shows, and just for the heck of it giving it an __init__(self, context): just to see if 2 arguments would really change anything and it gives the exact same error.

I’m testing this in a Plone 4.0.2 site on Mac OS X Snow Leopard (in a python 2.6.6 virtualenv)

BrowersView registration from browser/configure.zcml (I threw this into a theme I was also working with). I call http://localhost:8080/plone/events/new_events_view to see how the view looks and get the above error. I’ve also tried registering the view in portal_types for topic and it will give me that error upon navigating to http://localhost:8080/plone/events until I remove the view.

  <browser:page
      for="*"
      name="new_events_view"
      class=".newEventsView.NewEventsView"
      template="newEventsView.pt"
      permission="zope.Public"
      allowed_interface=".interfaces.INewEventsView"
      />

Any help would be greatly appreciated.

Also, I know it’s a small block of code, but rip it apart if you think it could be done in a better fashion, I’m a student always looking for ways to improve.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:49:52+00:00Added an answer on May 21, 2026 at 8:49 am

    You shouldn’t put any code in the __init__ method of a browser view anyways. If you want to have some custom code put it into methods on the view class or overwrite the __call__ method. The view is instantiated before a security context is available and might be instantiated multiple times per request. This can lead to a lot of surprising effects if you do any non-trivial work in it – so best just avoid doing anything in there.

    In Plone 4 you would write a custom __call__ as:

    from zope.publisher.browser import BrowserView
    
    class MyView(BrowserView):
    
        def __call__(self):
            # do some work
            return super(MyView, self).__call__()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.