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)


What do you think?
Tomasz



But when I add A2->B and B->C dependency it all fails again.

On Sat, Jan 17, 2009 at 2:40 AM, Michael Bayer <[email protected]> wrote:
>
>
> On Jan 16, 2009, at 6:13 PM, Tomasz Nazar wrote:
>
>>
>> Do I have control over this behaviour? Or am I doing sth wrong?
>> Thanks for any help..Tomasz
>
>
> you can !   its an exposed internal API but its pretty stable for
> now.  Build a SessionExtension like this:
>
> from sqlalchemy.orm.interfaces import SessionExtension
>
> class SetupDependencyExt(SessionExtension):
>     def before_flush(self, session, flush_context, instances):
>         flush_context.register_dependency(class_mapper(A),
> class_mapper(B))
>
> where "A" is the mapper that should execute first.   then configure
> that extension with your sessionmaker(extension=SetupDependencyExt()).
>
>
>
>
> >
>



-- 
_i______'simplicity_is_the_key'__________tomasz_nazar
_ii____'i_am_concern_oriented'________________JKM-UPR
_iii__'patsystem.sf.net'___________________linux_user
_'aspectized.com'___________________________prevayler

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to