[z3-five] SimpleViewClass and __hash__
Tarek Ziadé
tziade at nuxeo.com
Mon May 9 11:52:25 CEST 2005
Florent Guillaume wrote:
>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 CPS Sckins would use the object itself as
>a key into a dict. That's absurd.
>
>
Well, it does, and I have seen this in other Z2 products that uses
objects as keys for dicts.
This hash is provided by z2 page templates when they are used as keys in
dicts and fails when it's a SimpleClassView wrapped through Five.
I think Five role is to make things work under Zope 2 when it's possible.
I don't want to look over all zope 2 products to check if they use page
templates objects as keys and correct them,
even if it's not ok to do it this way.
>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
>>
>>
>>
>
>
>
>
--
Tarek ZIADE, Nuxeo SARL: Zope Service Provider.
Mail: tz at nuxeo.com - Tel: +33 (0)6 30 37 02 63
Nuxeo Collaborative Portal Server: http://www.nuxeo.com/cps
Gestion de contenu web / portail collaboratif / groupware / open source
More information about the z3-five
mailing list