Is it possible to use Pony with a file structure like this?
-project/
-start.py
-controller/
-view/
-model/
__init__.py
-person.py
-category.py
All examples I have seen were single file setups like this:
db = Database()
class Person(db.Entity):
...
class Category(db.Entity):
...
db.bind(...)
db.generate_mapping(create_tables=True)
I want to move the class declarations to the model folder.
Thank goodness for the related questions section. It looks like this question has already been asked and answered: PonyORM - multiple model files. Thank you to Alexander Kozlovsky for providing a detailed answer to that question.
My summary of Alexander Kozlovsky's answer:
In the model files, do
from database import db.Wherever
db.generate_mapping()is, import all your models at the top of that file.