I work on ApiLogicServer <https://github.com/valhuber/ApiLogicServer#readme>,
which creates a *models.py* file (then used to create an API and web app).
My objective is to enable users to
1. *Customize* *models.py* (e.g, add hybrid attributes, missing
relationships, etc), and
2. *Preserve* these customizations when the *models.py* file is later
recreated (e.g., the database schema was changed).
I am seeking advice. I have looked the the following alternatives, but
they all present issues:
1. I'd prefer not rely on a *code merge: *let the user alter the
*Customer.py
*file, then merge customizations when *Customer.py* is recreated.
Certainly a possibility, but it seems cleaner to keep customization files
separate from generated files.
2. I have looked into subclassing - e.g., generate *Customer_base*, let
user extend in *Customer(Customer_base)* so all their customizations are
in a separate file. But, I encountered issues since the relationships are
bound to the super classes. For example, anOrder.Customer returns an
instance of *Customer_base* instead of *Customer*
3. I investigated the API *sqlalchemy.ext.hybrid.hybrid_property* to
create hybrid attributes. I am familiar with hybrids via annotations, but
again, I want this to be in a separate file from customer.py. I am unable
to find what to do with the hybrid_property descriptor (assign it to the
class?), which raises doubts about this approach.
A clear approach is not emerging, would appreciate some guidance.
Thanks in advance,
Val
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/51c6a61a-fbcf-4d0c-b3e4-020f32cd11c7n%40googlegroups.com.