Yes and no.

I don't agree with the default Pylons session approach -- where you
have 1 global db session.

I tend to use a mixture of 2 things to handle sessions in the Model:

1- A Factory class manages a session pool and which type is active
( read, write, log, etc). I call out to the factory to grab a session
as needed in the model.
2- I pass in explicit sessions to the model as needed.


so my model might look like this:

class UseraccountBase():
    def get__by__email( self, dbSession, email ):
        return dbSession.query(self.__class__).filter
( sqlalchemy.sql.func.lower( (self.__class__).c.email ) == email.lower
() ).filter_by( is_active = True ).first()

and my controller would look like:

def update_user(self):
    session_write= SessionFactory.get_or_init('write')
    user= model.user.Useraccount().get__by__email( session_write ,
'[email protected]' )




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to