Looking for suggestions on a problem I've run into from time to time. I'm trying to use attribute events kindof like database triggers. The only problem is that I only get a "before" trigger on an attribute event where what I really need is an "after" trigger.
For example: Given two tables, account and account_charges, I would like to keep a computed total of the charges on the account. Whenever a charge changes, I need to update the account. Using sqlalchemy events I can watch for the change and easily change the totals on the account based on the difference from the charges. However, if I want to do a full recalculation of the totals it becomes harder because if I do something like account.recalculate_charges() I get the total before the attribute is set. My current solution to this problem is to use before_flush events to calculate the totals whenever a charge changes. This has actually worked quite well for a long time, however as my application has gotten much, much more complex and I have many before_flush handlers to run, I gets very complicated to keep track of ordering and dependancies of my attribute changes. Does anybody else have better techniques for handling this situation? -- 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.
