Thanks for the advise I'll look into that. I was trying to figure out how best to get a db connection and make sure its closes properly. putting it an a tween seemed convienent, but I get what your saying about the unnessary load for every request especiualy if a connection to the database is not needed.
Jose On Monday, July 20, 2015 at 2:48:29 PM UTC-4, Jonathan Vanasco wrote: > > I'm not sure what `request.peewee_dbs()[db].connect()` does, but I would > probably recommend against this db setup pattern that you're using. By > doing this in a tween, every request that pyramid handles will do a > connect/disconnect to all the databases you defined. > > One of the more popular patterns to implement db connections is something > like this: > > - `add_request_method` provides an object that either returns an database > connection, or creates a new one. > - if you create a new connection, it registers a 'db.close()' via > `add_finished_callback` > > this way you only connect as needed, and disconnect to actually connected > databases. > -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-devel+unsubscr...@googlegroups.com. To post to this group, send email to pylons-devel@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-devel. For more options, visit https://groups.google.com/d/optout.