Re: Spyce and SQL Alchemy Questions

"Jonathan Ellis" <[email protected]>
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
On Wed, 07 Jun 2006 10:10:32 -0400, "Bruce Webber"
<[email protected]> said:
> I have another question.

> Once openDB() is executed, it does not need to be executed again. The 
> dbEngine object and the mappings that are created in dbOpen() persist. So 
> the Spyce webserver must be keeping these. Is this because dbEngine is 
> global? What is the scope (if that's the right word) for these objects?
> Are 
> they available for the one session only, or across sessions at the 
> application level?

Spyce isn't doing anything special to keep it around; that's just the
default SQLAlchemy behavior.  SA stores the engine in a (module-level)
global somewhere...  it "just works" because the setup you are using
only involves the one Python process.

If you had a non-Spyce program like this,

// foo.py
from sqlalchemy import *

def one():
  // init db

def two():
  session = create_session()

one()
two()

... you would see the same behavior, even though no global state per se
is shared between one() and two().

-Jonathan
-- 
C++ is history repeated as tragedy. Java is history repeated as farce.  --Scott McKay
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.