On Jan 19, 2009, at 9:10 AM, Tomasz Nazar wrote:
> > Thanks Michael, it works for simple case and solved my issue for now. > In SqlA 0.4 import is wrong. proper one is: > from sqlalchemy.orm.session import SessionExtension > > > So, for A->B dependency it works. 'Inserts' seem not be random any > more. > I wanted to play a bit more with that feature and can I configure many > dependencies in that way? I was thinking if can tell SQLA to have kind > of global order for more than just 2 classes (to have ordered tree of > classes [inserts]) > > > I have a working example: > class SetupDependencyExt(SessionExtension): > def before_flush(self, session, flush_context, instances): > flush_context.register_dependency(A, B) > flush_context.register_dependency(A2, B) > > But when I add another line it fails, and inserts are random again > flush_context.register_dependency(B, C) > > But adding this instead of above causes no problems. > flush_context.register_dependency(A3, C) > the dependency order is a firm requirement of mappers. however if a circular dependency occurs among one or more mappers, the unit of work has no choice but to drop into row-level dependency checking. at that point the hack I've given you won't work because a different system is queried for row-level dependencies, and there is not as public of an API for that (though of course there could be). you really have that complex of a network of interdependent triggers ? --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---