in my apps, i attach a db connection object to the request.
It's basically just a wrapper that holds SqlAlchemy connections
my code tends to look like this:
class AView():
@viewconfig(...)
def something(self):
self._setupDb('reader')
the _setupDb function attaches an object that has a .reader and/or .writer
attribute , and in keeping with some really old Pylons conventions --
issues an initial rollback and adds an 'add_finished_callback' to the
request that will issue a close() on the SqlAlchemy ScopedSession(s). [ i
use separate reader and writer connections for both replication and a bit
of security , one day i'll move to sharding - just not today ].
i have a few questions about this setup:
1. i recall seeing an announcement a few weeks ago about the
set_request_method adding some sort of lazy access by incorporating @reify
. has anyone used this for establishing dbConnections yet ?
2. does anyone know if the initial rollback and cleanup of
the ScopedSession are needed anymore ?
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pylons-discuss/-/JKMNlUeiWSQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.