> > Ah, OK so what's happening is that _sa_instance_state hasn't yet been > assigned to the User object during the unpickle process, then your __eq__() > is trying to get at self.id which triggers the attribute system and > requires a fully composed User object. > > Here you'd need to either have a different way of __eq__() functioning, > which might mean maybe you look inside of obj.__dict__ for "id" first to > work around this, or you wouldn't use a mutable attribute. The mutable > system requires that it be able to hash the parent object in a weak key > dictionary. > > There might be other workarounds possible, perhaps we'd modify > InstanceState.__setstate__() to help here, but I'd have to think about it. > Well, I fixed it by modifying my code from this:
def _get_id(self): return self.id To this: def _get_id(self): if 'id' in self.__dict__: return self.id return id(self) Although it feels kind of wrong to patch an entity class for certain behavior of an attribute that it may have. Thanks -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/Qs_KYgBllFkJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.