[Zope] Error Value: can't pickle function objects
Alec Mitchell
apm13 at columbia.edu
Fri May 28 12:47:46 EDT 2004
On Friday 28 May 2004 08:36 am, Mohamed Lrhazi wrote:
> What does that error mean?
>
> In my main class I have :
>
>
> main_page=PageTemplateFile('zpt/main_page.zpt',globals())
> main_page._owner=None
>
>
> def index_html(self,REQUEST=None):
> """our main page... Enter here!"""
> if REQUEST is not None:
> if REQUEST.has_key('YSURLARGS'):
> if REQUEST['YSURLARGS'][0] == 'domain':
> self.domain = self.ddb.getDomain(REQUEST['YSURLARGS'][1])
> self.domainTitle=self.domain.getHTMLDomainName()
> else:
> pass
> else:
> pass
> else:
> pass
> return self.main_page(self,REQUEST)
>
>
> And this results in:
>
> Site Error
> An error was encountered while publishing this resource.
>
> Error Type: TypeError
> Error Value: can't pickle function objects
Interesting, in my experience (as noted in a very recent post), this means
that you are trying to add a function/method as an attribute of an class
instance stored in the ZODB. Looking at your code, I see nothing obvious
that youd indicate such behavior, unless the getDomain or getHTMLDomainName
calls return functions (that seems unlikely judging by their names). Perhaps
some other code from this class is at fault?
As a side note, in the past I believe that was able to store functions as
instance attributes in the ZODB, without any pickling errors. Perhaps in the
switch to Zope 2.7, or more likely Python 2.3 this changed. My current
suspicion is that it is related to the ZODB's inability to deal properly with
"new style" classes. Sorry I can't be of any more help.
Good luck,
Alec Mitchell
More information about the Zope
mailing list