> I don't understand the problem here. Forum.query.count() should return > the number of contexts of "Forum" type.
The Forum-number is not of interest here. The member_count is about the number of participants in the given context. For a project, these are the project members. For a forum, these is the count of the set of users that have one of the groups the Forum is intendet. And I need to sort the context based on that information. For efficiency (this will be needed very often) I want to do this in the database - not on the resulting contexts. So I store the count in an extra column. And this column of course needs to be updated whenever the underlying data used to compute it changed. I admit though that there are many special cases that are hard to track (to say the least), but nevertheless the question arose if I could somehow automate some of the work using events. > > So I planned to introduce a "compute_member_count"-method on each > > subclass of context that will be invoked whenever anything in the > > relations of the Contexts changes. > > > > For that, I'd need some sort of hook that is invoked for each modified > > object so that I can invoke my compute_member_count-method. > > Don't the elixir events (probably before_insert and before_delete) fit > the bill here? > http://elixir.ematia.de/trac/browser/elixir/trunk/tests/test_events.py I didn't know of them, I will have a look - thank you. Diez --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLElixir" 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/sqlelixir?hl=en -~----------~----~----~----~------~----~------~--~---
