Hi I have a general question on how to implement business logic in declarative sqlalchemy.
I have an Invoice Model: class Invoice(db.Base): client = Column(...) state = Column(...) [...] For simplicity I do not show all columns. Assuming an Invoice belongs to one client and has a state within 'open', 'close', 'callable' I want to be able to map all callable Invoices to a second Model. class CallableInvoices(db.Base): __table__ = db.session.query(Invoice).filter_by(state=='callable') But now I want to be able to select for the client as well: class CallableInvoice(db.Base): __table__ = db.session.query(Invoice).filter_by(state=='callable').filter_by(client==??) So the usage should be: ==> either client = # some client callables = db.session.query(CallableInvoice).filter_by(client=client).all() assert callables.client == client ==> or client = # some client callable1 = CallableInvoice(client=client) callables = db.session.query(callable1).all() So: 1. Is this possible with SQLAlchemy? 2. Is it the right way to do such a thing or should I rather have a class method 'def callable_invoices(cls, client=None)' on the Invoice Model Thanks in advance, Florian -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
