Skip to content

Acquisition wrappers do not respect equality/ordering of the base object #50

@d-maurer

Description

@d-maurer

Unless a class defines __cmp__ (which is unusual for Python 3), acquisition wrappers ignore equality and ordering definitions for the base object and implement them based on the base object's addresses.

>>> from Acquisition.tests import I
>>> class RichOrdered(I):
...   def __eq__(self, other): return self.id == other.id
...   def __lt__(self, other): return self.id < other.id
... 
>>> i1 = RichOrdered(""); i2 = RichOrdered("")
>>> top = I(""); top.i1 = i1; top.i2 = i2
>>> i1 == i2
True
>>> top.i1 == top.i2
False
>>> i2.id = "i2"
>>> i1 < i2
True
>>> top.i1 < top.i2
False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions