Hi,
We recently started implementing peewee in our projects. Right now we are very happy with it. But now we are bumping on some fundamental questions, we need to solve.
Our projects are customer dependend. Therefore we have a basemodel that consists of several "base'" classes. A base class should be extended by custom logic / extra fields depending on the exact customer / project.
I was testing with the following code. As you can see, Person.select().count(), will only return 1. After inspecting the database, i could see there is only row inserted in the Person table, though SpecialPersion is a Person too. So all logic that is handled in my baseproject wouldn't be aware of any customisations.
So how would you solve this? All suggestions are really appreciated. thanks!
class BaseModel(Model):
class Meta:
database = database
schema_manager_class = MSSQLSchemaManager
only_save_dirty = True
class Person(BaseModel):
id = AutoField()
name=CharField()
def greet(self):
class SpecialPerson(Person):
def greet(self):
print "Hi my name is %s, I'm special !" % (
self.name)
def create_tables():
with database:
database.create_tables([Person, SpecialPerson])
#Drop Tables
database.drop_tables([Person, SpecialPerson])
#Recreate all tables
create_tables()
Person.create(name="Bar")
SpecialPerson.create(name="Foo")
print Person.get().greet()
print SpecialPerson.get().greet()
print SpecialPerson.select().count()
print Person.select().count()