hi paul - Im not entirely opposed to an additional hook,however this is a per- object hook which means we are adding method call overhead to each individual object loaded, which is why im hesitant. does the approach that Rick outlined in his email work ?
i.e. def populate_instance(self, mapper, selectcontext, row, instance, identitykey, isnew): mapper.populate_instance(selectcontext, row, instance, identitykey, isnew) if isnew: YOUR CODE HERE return None in the above approach, all attributes on the instance are fully present. however, eagerly-loaded collections may not be fully populated with their final results (and of course, lazily-populated collections will not be populated at all). if the issue is that you are waiting for eagerly-loaded collections on the instance to be fully populated, or that you want to be able to fire off lazy collections, then the above is not as optimial; populate_instance() is called repeatedly for each eagerly-loaded row (with the isnew flag set only the first time), and theres no indicator when the "last" row has been loaded...also there might be issues firing off lazy collections at this stage. So as far as that hook, we have a much better place for this hook in the 0.4 version of SQLAlchemy, since that version does include an official "post-load" step after all result rows have been exhausted. can you wait til then ? (the 0.4 checkout is available right now from its branch). also let me know if firing off lazy collections is a requirement, as I will add additional unit tests to ensure that scenario works. On Jul 14, 2007, at 12:27 PM, Paul Howell wrote: > > I've gotten a long way with using SA in Turbogears, but I want one > more thing (for now). > > In short, I want to attach some properties to the Data objects after > everything else has been done. I could do this in my Python code > AFTER my select() results are returned (I do that now), but would > rather do that in a MapperExtension. I want/need to do it at the very > end because I want the objects to have all their mapper-added > attributes added on to them, so that I can reference them in the > creation of these attributes. This would be MUCH easier than digging > deeper into the SQL joins and such to get the information from the > rows. > > I tried using MapperExtension, append_results() (and everything else > in MapperExtension), but the attributes added in the mapper are not > there yet, even in append_results, which seems to be the last thing > called. > > I think this feature/concept was what Rick Morrison was referring to > when he tried to "bump" Mike Bayer about "after" hooks here ( > http://groups.google.com/group/sqlalchemy/browse_thread/thread/ > 912c8f55f483069b/4bdc2c8320b8cac1?lnk=gst&q=MapperExtension > +bump&rnum=1#4bdc2c8320b8cac1 > ) back in February. > > Any ideas? > Paul > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---