On 5/25/15 11:43 AM, [email protected] wrote:
On 2015-05-25 11:12 Mike Bayer <[email protected]> wrote:
CreateSession and sessionmaker do the same thing. I'd lose one or
the other.
Yes, I will do so.
For the memoized thing, I'd use a decorator like Pyramid @reify or
SQLAlchemy's @memoized_property, wouldn't bother with all those
conditionals and such.
I am quite new to Python and not familiar with the decorator concept.
What do you mean with "memoized thing"? And why could the decorators
help me here?
As for "the session would be destroyed/closed", I'd never rely on
that,
I see. The link helped.
Of course the Gui-Dialog related to such a Controller instance will
call a SessionCommit() ('OK' is pressed) or SessionRollback() ('Cancel'
is pressed). So the controller instance itself call commit() or
rollback() on its session object.
Maybe you could implement a BasicController.__del__() to check the
state of the Session if it is commited or rolled back. I mean if
someone missed to call commit() or rollback() on int.
But I am not sure if it is possible to ask a Session object for things
like that. What do you think?
don't use __del__(), it causes the object to be uncollectable and should
be avoided.
Also, the garbage collector in general is not predictable as to when it
will fire off. If you use Pypy, the GC is no longer generational and
might not invoke for a long time. Database connections are a lot more
important than this and should not be left to an asynchronous GC thread
for cleanup.
that's a poor design, and it will lead to problems like
connection pool overflows and deadlocks.
I understand that. I thought the Session object would be destroyed
automaticly when the controller is destroyed.
And I think the Session take care of itself to release the resources
while it is destroyed.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.