Open fluffy-critter opened 4 years ago
I've tried implementing this a few times, and unfortunately this causes some other trickiness; type annotations get fouled up, for example, and when properties need to look up things on other types it gets really convoluted.
There might be a better pattern for doing this encapsulation, which is always seeming more necessary to improve the unit testing.
ponyorm has a pattern for encapsulating the database binding, which is incredibly obvious in hindsight: https://github.com/ponyorm/pony/issues/330#issuecomment-470153594
tl;dr: encapsulate
model
's classes in a closure, something like:And then the Model object which is returned gets attached to the Publ instance, which might also solve #134 since the model will persist as long as the app does.
Originally posted by @fluffy-critter in https://github.com/PlaidWeb/Publ/issues/113#issuecomment-636516531