> > How can I create a seperate, 'clean' session for each request?
> >
> > How can I get a reference to this same session from different places in
> > my app?

> 1. Are you using bound or dynamic meta data?  I'm guessing dynamic.


DynamicMetaData



> 2. Can you show me the code you're using to create the session?


http://pylonshq.com/docs/0.9.2/quick_wiki.html#the-model

I followed the QuickWiki tutorial and create a session in
lib/database.py. My code is a copy&paste from the tutorial with one
change: I assign None to engine just above get_engine to avoid a name
error exception.


> 3. Are you making sure that all the data is attached to the right session?


I think I am, although I wasn't at first. I am passing around the
session var which I'd rather not do, but I don't have a better
solution.


> 4. Did you get rid of all uses of "import sqlalchemy.mods.threadlocal"
> and "objectstore"?


My app is very young and is based on my understanding of the recent
discussion concerning SQLAlchemy integration. I grepped just to make
sure: these symbols do not appear in my code.


> 5. I assume there is no SQLAlchemy stuff in your lib/base.py.  Is this 
> correct?


Yes, although I am copying and pasting some standard code to my
controllers which perhaps should be on the BaseController in which case
the answer is no:

def __before__(self):
       self.session = session_context.current
       self.session.clear()

This code is also based on the tutorial but changed slightly. I create
my own query objects in each of the methods since I sometimes want an
eagerloading query and sometimes not.

The session.clear()  which I added after my initial message seems to
have solved the issue with ghost values appearing in certain cases.

Unless calling session.clear() is ill-advised, that leaves my other
issue: acquiring the session object without passing it around
explicitly as argument in method calls to my mapped models.

Is it possible to get the session object from within a mapped instance?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

Reply via email to