Note, sessions are specific to individual users (clients). If you put 
something in session.store.mysite on a given request, it will only be 
available to that specific user, not to anyone who goes to the 
store.mysite.com URL. If you need data accessible to all users store-wide, 
you should put it in the cache.

Anthony

On Tuesday, September 4, 2012 4:26:02 PM UTC-4, Kevin C wrote:
>
> Every store has a unique URL (So store.mysite.com) which will be the key 
> we look up on.  This is why the session trick will work.  Because we are 
> storing the store data for store.site.com in session.store.mysite.com so 
> every store would have a unique session. 
>
> I guess the real question is - Should we just cache this query result or 
> should we store it in a session?  Which way is preferred for Python / 
> web2py development? 
>
> Kevin Cackler 
> Tech Daddies 
> 501-205-1512 
> http://www.techdaddies.com 
>
> On 9/4/2012 3:22 PM, Niphlod wrote: 
> > you can certainly do 
> > 
> > STORE_DETAILS = db(db.stores.user_id == auth.user_id).select() 
> > 
> > in models. 
> > You'd have the variable STORE_DETAILS available in all controllers and 
> > every time a user loads a page the data will be refreshed. 
> > 
> > In order to reduce the db pressure, you can 
> > 
> > STORE_DETAILS = db(db.stores.user_id == 
> > auth.user_id).select(cache=(cache.ram, 60)) 
> > 
> > Doing so, the 2nd select will be fired only if more than 60 seconds 
> > passed from the 1st (i.e. a new page requested by the same user within 
> > 60 seconds will be fetched from the cache and not from the db) 
> > 
> > What you are doing in php works for web2py also: if you are positive 
> > that once a user is logged-in he would get the same stores forever (so 
> > it's not necessary to fetch the data every time you load the page), 
> > you can cache it with a high number or simply store the store details 
> > in session, i.e. 
> > 
> > if not session.store_details: #so it will be fetched one time only, if 
> > no store_details "key" is found on session 
> >       store_details = db(db.stores.user_id == auth.user_id).select() 
> > 
> > Then you'd have to access this data as session.store_details 
> > 
> > That's all if I got it correctly: if I didn't understand please post 
> > more details. 
> > 
> > -- 
> > 
> > 
> > 
>
>

-- 



Reply via email to