Hello, I'm building a small application using web.py with sqlAlchemy. My application has users. When a user successfully authenticates, I store his user ID in the session.user_id variable. Then I query the database every time I want to render a template using the user's information. However, this seems wasteful. I've already queried the DB once and retrieved a "User" sqlalchemy object instance, is there any place I can store this object without having to recreate it every time I GET a new page? I tried storing this in a session.user_data variable, but that caused errors.
Also, every time I query the database I am creating another sqlAlchemy DB engine and another DB session. Is there a way to share a DB engine across classes? So, for instance, I have an URL called '/map' that is linked off the home page. In the GET method of the MAP class, I am creating a new sqlAlchemy engine, connecting to it to query for user data, doing the same for other data, etc. It is the same for all my other URLs. Thanks, Jacob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
