Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (16 sloc) 481 Bytes
from ext import db
class BaseMixin(object):
@classmethod
def create(cls, **kw):
session = db.session
if 'id' in kw:
obj = session.query(cls).get(kw['id'])
if obj:
return obj
obj = cls(**kw)
session.add(obj)
session.commit()
return obj
def __eq__(self, other):
return all([getattr(self, attr) == getattr(other, attr)
for attr in ('id', 'nick_name')])