From: Ian B. <ia...@co...> - 2003-09-16 15:49:26
|
On Tuesday, September 16, 2003, at 08:20 AM, Mark Mueller wrote: > Ian -- > > Very nice job with the SQLObject project. I am > considering using it for several projects. > > I like to model problems using the BON technique, > however, most middleware does not map to the program > space in a way that allows me to go easily from the > BON diagram to the program. SQLObject help my by > hiding the details. > > Thanks for all your work. I'm glad you enjoy it. You should post questions to the mailing list so that everyone can participate, answer, or hear the answer. > I do have a question. I have two classes arranged in > a parent-child (one-to-many) relationship. I need to > be able to have my collection in the parent object > include only a subset of the child items. (For > example, a customer's account object that has a > transactions collection that includes transactions for > a date range.) My problem is that the account object, > automatically, gives me all the transations. Is there > a way to filter the child objects? You have to construct the select yourself, like (untested): class Account(SQLObject): transactions = ForeignKey('Trans') def transactionsDuring(self, start=None, end=None): query = Trans.q.accountID == self.id if start: query = AND(query, Trans.q.eventDate > start) if end: query = AND(query, Trans.q.eventDate < end) return Trans.select(query) Ian |