flask-peewee icon indicating copy to clipboard operation
flask-peewee copied to clipboard

Use singleton for db.Model

Open thomdixon opened this issue 10 years ago • 0 comments

This change uses a singleton for db.Model, permitting sane subclass behavior. That is, rather than

BaseModel = db.Model
class Foo(BaseModel):
    def __init__(self, *args, **kwargs):
        super(BaseModel, self).__init__(*args, **kwargs)

    def extra(self):
        pass

one can simply write

class Foo(db.Model):
    def __init__(self, *args, **kwargs):
        super(db.Model, self).__init__(*args, **kwargs)

    def extra(self):
        pass

as you would expect.

thomdixon avatar Jul 09 '14 00:07 thomdixon