~stoq-dev/stoq/1.5

« back to all changes in this revision

Viewing changes to stoqlib/database/orm.py

  • Committer: Ronaldo Maia
  • Date: 2012-12-13 17:11:51 UTC
  • Revision ID: romaia@async.com.br-20121213171151-a5vrfqc7hhi25vpm
Implement equality comparison for database objects.

If they are from different stores, storm consider them different, but this
causes some errors on Stoq.

Fixes bug 5356

Show diffs side-by-side

added added

removed removed

Lines of Context:
372
372
        if self._connection is None:
373
373
            self._connection = STORE_TRANS_MAP[Store.of(self)]
374
374
 
 
375
    def __eq__(self, other):
 
376
        if type(self) is not type(other):
 
377
            return False
 
378
        return self.id == other.id
 
379
 
 
380
    def __ne__(self, other):
 
381
        return not self.__eq__(other)
 
382
 
375
383
    def set(self, **kwargs):
376
384
        for attr, value in kwargs.iteritems():
377
385
            # FIXME: storm is not setting foreign keys correctly if the