RAMCachemanager not caching brains or why doesn't Zope like the taste of pickled brains ?
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
On 5/8/02 6:53 PM, "Tim Hoffman" <timhoffman@cams.wa.gov.au> wrote:
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?
It's specific reason is that the brains to attach to catalog results are basically created on the fly by mixing one known (AbstractCatalogBrain) and one unknown (value of 'brains') element together. The results of this meshing are cached in the volitile attributes '_v_result_class'
2. What would be the danger of caching brains ?
Brains themselves are just classes, and not chachable. I take it you mean Brained Result objects... And I can't answer that one. I think there's a general issue of caching result sets and knowing to which search query and user they apply to. -- Jeffrey P Shell www.cuemedia.com
participants (2)
-
Jeffrey P Shell -
Tim Hoffman