Kwissle

My real-time quiz battle game Kwissle.com

Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Photos

Photoalbum, both old and new.

Twitter

Follow me on Twitter

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 
Zope

__call__ folderish Zope objects


19th of December 2004

I ran into trouble with a Zope class that inherits from OFS.Folder.Folder (the classic Folder class). My class is a bit special since it's acting both as a non-folderish document like object but still needs to contain other objects such as images and file attachments. The class had a method called index_html which looked something like this:

 def index_html(self, REQUEST, **kw):
     """ return something"""
     return self.something

The problem was that if I create one of these instances with the id index_html it simply could not be viewed. What I had to do was to use the __call__() function on my class. That is apparently how Zope figures out which document to show/call. Now my class had this instead:

 def __call__(self, REQUEST, **kw):
     """ wrap view() """
     return self.view(self.REQUEST, **kw)

 def view(self, REQUEST, **kw):
     """ return something"""
     return self.something

That took care of my problems and now the parent instances could instantly view my document like instances called index_html.

So, for the next time; use __call__() instead of index_html().



Comment

 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.