[z3-five] SimpleViewClass and __hash__

Florent Guillaume fg at nuxeo.com
Mon May 9 11:28:46 CEST 2005


Tarek Ziadé wrote:
> Hi,
> 
> I've ran into some problems with CPSSkins under CPS3 and a Product using
> Five.
> 
> CPSSkins creates a persistent dictionnary wich keys are zope 2 methods
> names (zpt, py, dtml, etc)
> 
> It raises errors on pages templates created through Five because they do
> not have a __hash__ method
> for the dict to work properly.

If the hash key is the script *name* then you shouldn't need a hash on
instances. And I don't see why CPSSckins would use the object itself as
a key into a dict. That's absurd.

Florent

> I would like to suggest a change in
> pagetemplatefile.ZopeTwoPageTemplateFile by adding a hash method :
> 
>    def __hash__(self):
>        return hash(self._cook)
> 
> then in browserconfigure, adding a method :
> 
> def __hash__(self):
>    return hash(self.index)
> 
> that's binded in makeClassForTemplate to class_ =
> 
> class_.__hash__ = __hash__
> 
> 
> That would make page templates usable as dictionnary keys in Zope 2.
> 
> Cheers
> 
> Tarek
> 


-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the z3-five mailing list