On Feb 10, 2010, at 7:38 PM, Michael Trier wrote: > What you likely want to dig into is Query enabled properties > (http://www.sqlalchemy.org/docs/mappers.html?highlight=property%20association#building-query-enabled-properties). > I used this a lot of times to tie what appears to be a relationship but > that is driven by an underlying query. I don't have time right now to > whip up the action property, but if you play with it a bit I'm sure you'll be > able to get there.
Perfect! I added these to my User object, and it works great: def _recent_usage(self, last_num_items=1): session = object_session(self) return_list = [] fs_list = session.query(Filesystem).all() for filesystem in fs_list: usage_objs = session.query(Usage).\ filter_by(user=self).\ filter_by(fs=filesystem).\ order_by(desc(Usage.datetime)).\ limit(last_num_items).\ all() for usage in usage_objs: return_list.append(usage) return(return_list) last_usage_objects = property(_recent_usage) Thanks very much for your help! David -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.