I have a hidden WriterSession which I am using behind the scenes to
manage a number of API entries that write data in bulk e.g. upsert
(MappedClass, iterator_that_returns_dicts). I want the session to only
look at its own binds and to ignore any that are in place on the
metadata collection. I wrote my own get_bind that does this
(horrible!) hack:

        if self._Session__binds:
            b = self._Session__binds
            if c_mapper:
                if c_mapper.base_mapper in b:
                    return b[c_mapper.base_mapper]
                elif c_mapper.mapped_table in b:
                    return b[c_mapper.mapped_table]

        if self.bind:
            return self.bind

I don't really understand how the double underscore stuff works in
Python. Mike, how would you feel about exposing the session bind
information with an interface that is more amenable to subclassing?

pjjH

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to