I tried using DBSession instead -- same issue. When you ask how I run
my app, what do you mean? To start the server, I do 'paster serve
development.ini' while developing, and yea -- I expected paster to be
running several threads, but it doesn't seem to be. When I watch 'top'
while sending multiple requests, there is only one Python process and
one Paster process. Also, I'm using Pastescript v1.7.3.

Let me describe the situation in a little more detail. I'm working on
a Turbogears project that serves data from a postgres database. We're
trying to maintain the database and the webapp as two separate
entities. Because of this, we have our Model Classes defined in the
database product, and because we want it to be generic so any machine
can install this setup, we've created our own DatabaseConnection
class; the class is a singleton and the ModelClasses imports the
DatabaseConnection class expecting that some other script has already
instantiated the connection -- in that way, the ModelClasses are
ignorant of the physical location of the database, so long as it has
the correct tables. The DatabaseConnection class is where we actually
create the session, but it is a scoped_session just like it would have
been in Turbogears.

Thanks for the help!
- Adrian

On May 19, 7:13 am, Christoph Zwerschke <[email protected]> wrote:
> Am 18.05.2011 18:54 schrieb Adrian:
>
> > model, and in each controller I do: from webapp.model import
> > DBSession, session = DBSession(), session.query(..)... etc.
>
> Actually you can just import DBSession and then use DBSession directly,
> i.e. DBSession.query(User) etc. since it's a scoped session which
> provides everything at the class level already.
>
> I'm not sure if instantiating DBSession() can be harmful or whether this
> means that you also have to care for closing or removing the session
> instance afterwards. Can you try if using the class directly works
> better for you?
>
> -- Christoph

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
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/turbogears?hl=en.

Reply via email to