[Zope-dev] RAMCachemanager not caching brains or why doesn't Zope like the
 taste of pickled brains ?
   
    Tim Hoffman
     
    timhoffman@cams.wa.gov.au
       
    09 May 2002 08:53:51 +0800
    
    
  
Hmm
I shall investigate why <mybrains> instances can't be pickled
as it strikes me that they are probably one of the more likely 
objects one would like to cache (despite their taste ;-)  ie results of
expensive catalog searches that will be batched.
=== time elapsed =====
And now I know why I can't pickle brains
in Products.Catalog.Catalog
The following method declare the class mybrains inside it.
def useBrains(self, brains):
        """ Sets up the Catalog to return an object (ala ZTables) that
        is created on the fly from the tuple stored in the self.data
        Btree.
        """
        class mybrains(AbstractCatalogBrain, brains):
            pass
        
        scopy = self.schema.copy()
        scopy['data_record_id_']=len(self.schema.keys())
        scopy['data_record_score_']=len(self.schema.keys())+1
        scopy['data_record_normalized_score_']=len(self.schema.keys())+2
        mybrains.__record_schema__ = scopy
        self._v_brains = brains
        self._v_result_class = mybrains
And looking at the doc's seb pointed too, it says that picklable classes
must be top level classes. So two questions are raised from this
1. has mybrains been declared within the method for a specific reason
such as data hiding, and/or to prevent pickling it?
2. What would be the danger of caching brains ?
Regards
Tim
On Wed, 2002-05-08 at 21:42, seb bacon wrote:
> On Wed, 2002-05-08 at 05:36, Tim Hoffman wrote:
> > Hmm, any ideas on why brains wouldn't be picklable
> 
> *guessing* brains probably include non-top-level functions or classes:
> 
> http://www.python.org/doc/current/lib/node62.html
> 
> seb
> 
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
> 
> 
> 
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cmf
> 
> See http://www.zope.org/Products/PTK/Tracker for bug reports and
feature requests