Chris Withers wrote:
> Philipp von Weitershausen wrote:
>> class IKeyReference(zope.interface.Interface):
>> """A reference to an object (similar to a weak reference).
>> The references are compared by their hashes.
>> There, that wasn't so hard...
> Well yeah, but it's also not very explanatory ;-)
> If it's similar to a weak reference, why not just a weak reference? What
> are the salient differences between a normal weak reference and a key
Basically, key references are things you can use as keys in dicts (hence
the name). In other words, IKeyReferences provide a (unique) hash for an
hash(IKeyReference(obj)) is just a fancy way of saying hash(obj).
We need the fanciness because hash(obj) is meaningless for e.g.
persistent objects or objects dynamically created from, say, a
relational database. The IKeyReference adapter can be smarter about it
and figure out what a good unique hash for the object is. E.g. the
adapter for persistent objects hashes the database name and the object's
oid. This cominbation is always unique on a system.
Feel free adding this as a README.txt to zope.app.keyreference :)
Zope3-users mailing list