dmiller wrote:
> That's a good idea (why didn't I think of that? :). Only one other
> thing, it should allow something this:
>
> def foo(s):
>      # do stuff
>      trans = s.begin()
>      bar(s) # pass the baton again
>      trans.commit()
>
> trans = s.begin()
> func(s)
> trans.commit() # commit everything
>
> That completes the solution--any code can be nested in a session
> transaction. Only the outer trans.commit() does anything. Every
> session.begin() must be balanced with a trans.commit() (i.e. the
> outer trans.commit() would raise an exception if the inner one had
> not been committed or rolled back). There should probably be a
> trans.rollback() method that just discards all changes since the last
> s.begin() or trans.commit()--this could be left out for the time
> being (I'm sure it will eventually be requested).
>

yah absolutely, thats all part of this idea (which is actually something I
did many years ago in an old java framework).  rollback rolls everything
back no matter where you are, consistency of begin/commit enforced, etc.

> a generic exception class for each module (i.e. MapperError) or even
> just one for the whole project (SQLAlchemyError). All exceptions
> raised in that module use that exception. Later you can create fine-
> grained subclasses for specific situations if needed. No user code
> needs to be rewritten unless the fine-grained control is needed. This
> takes very little effort on your part and saves a lot of time (and
> upgrade pains) for the early adopters off SA.
>

OK point taken, Ill go through and just add a module of SQLAlchemyError /
<MajorFunctionalArea>Error to start with, and distribute those throughout
the code, as my next major commit task later this week.

for SQL execution, Ill also throw in a SQLStatementError which will
contain a reference to the original DBAPI error as well as the full
text/bind parameters that failed.  While I often shy away from exception
wrapping due to the difficulties it imposes on stack traces, in this case
its not that important since the code path beneath execute() is static. 
Sound good ?

a solution at last ! I am psyched.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to