let me tell you how pickletype works right now (by default, you can
change it).

there is a method on all TypeEngine objects called compare_values().
this method is now used by the attributes package when it checks if
something "changed".  in most cases, the method uses a the ==
comparison.  In the case of PickleType, by default it does something
different:

    def compare_values(self, x, y):
        return self.pickler.dumps(x, self.protocol) ==
self.pickler.dumps(y, self.protocol)

why does it do that ?  because it is exhaustively detecting any change
anyhwere within the pickled state.  I would hypothesize that something
is changing somewhere in your binary data.

To turn the feature off, use the flag "mutable=False" when you declare
your PickleType.  Then it will use the old method, using the "is"
operator (i.e. x is y).

you can also subclass PickleType and add a comparison of some other
method, i.e. using == for example.

for your transaction issue, its important to understand the automatic
"nesting" of transactions in sqlalchemy.  if you begin a transaction on
a resource, and then someone else also begins an transaction on the
same resource, you control the transaction; the inner call gets a
placeholder transactional object which is capable of rolling back the
transaction, but not committing it.  to commit the transaction, the
original outermost caller that began it must commit.

in the case of UOW, it begins its own transaction, and commits.  this
is essential for the flush()  method to work properly, since it a). is
issueing many SQL statements which must be in a transaction (therefore
begin()) and b). has to have the data written to the DB when its done
(therefore commit()).  If you are using your own transaction on the
same resource, then the UOW's transaction will "nest" into yours as
described above.

The transaction nesting can be used via the SessionTransaction
interface or also through the Transaction object off of Connection.

connection = e.connect()
transaction = connection.begin()
session = create_session(bind_to=connection)
  ... do stuff..
session.flush()
transaction.commit()

its all in the docs in the Sessions chapter.


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

Reply via email to