[sqlalchemy] Automatic close of ResultProxy (using with statement)

2013-10-13 Thread Martin Stettner
I'm using SqlAlchemy core to access my database. I'm just wondering if there's a specific reason why the ResultProxy class doesn't implement the __enter__ and __exit__ methods for automatically closing the results of a query using Python's with statement. This would make the following code

Re: [sqlalchemy] SQLAlchemy 0.8 issue: with appending items to relationship

2013-10-13 Thread Marc Van Olmen
Michael, Thanks always for your time! amazing those details answers. I looked at the code and see they did something like this: beforeSerials = self._serials[:] Then a few lines later followed by: self._serials.append(MetaSerial(value=u')) Then followed by

Re: [sqlalchemy] Automatic close of ResultProxy (using with statement)

2013-10-13 Thread Michael Bayer
On Oct 13, 2013, at 7:45 AM, Martin Stettner martin.stett...@gmail.com wrote: I'm using SqlAlchemy core to access my database. I'm just wondering if there's a specific reason why the ResultProxy class doesn't implement the __enter__ and __exit__ methods for automatically closing the results

Re: [sqlalchemy] SQLAlchemy 0.8 issue: with appending items to relationship

2013-10-13 Thread Marc Van Olmen
I did some more digging today to see If I can pin down the exact reason: I tested with a unit test, and reduced the code above to bare minimum and not doing references to collections anymore. def serials(self): requiredAmountOfSerials = self.quantity if

Re: [sqlalchemy] SQLAlchemy 0.8 issue: with appending items to relationship

2013-10-13 Thread Michael Bayer
I'm glad you're still poking because I'm still not seeing anything that would trigger this warning. Here is that exact code in a test case, I can't get it to produce the warning: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base

Re: [sqlalchemy] Trying to get a 'global' session to work for SQLAlchemy database library tests

2013-10-13 Thread Michael Bayer
On Oct 11, 2013, at 9:32 PM, Ken Lareau klar...@tagged.com wrote: I have this at the end of my init_session(): Session.configure(bind=engine) but I'm assuming that's not enough? I don't have a full code example in front of me but I'd imagine that the recipe you're using is injecting