session[''store.mysite.com'] = session.get('store.mysite.com
',get_store_info('store.mysite.com'))


On Tuesday, 4 September 2012 15:03:10 UTC-5, Kevin C wrote:
>
> The users_id comes from the stores table, and is a foreign key to the 
> web2py users table.  Really the source of it is irrelevant.  
>
> What I need to know is what is the best practice for storing this type of 
> information?  In PHP, I would do something like the following in a global 
> include file:
>
> <?php
> if(empty($_SESSION['store.mysite.com'])) {
>   $_SESSION['store.mysite.com'] = get_store_info('store.mysite.com');
> }
> ?>
>
> This would make all of the store info (Including users_id) available to 
> the entire script through the PHP session.  I need to know how to do the 
> equivalent in web2py.  How do I execute a certain block on every page load 
> (IE to check if the store info has been retrieved and stored yet) and then 
> where should I store that info to make it accessible for the rest of the 
> script?
>
> In my limited experience with web2py, I'm thinking I should store the code 
> in a model file and have that code save the store info to a web2py session, 
> but I wanted to get a second opinion before continuing down that path.
>
> I hope I have explained it a little more clearly.
>
> Basically, how do I execute code on every page load and what is the best 
> practice for storing short term data like that?
>
> On Monday, September 3, 2012 10:43:10 PM UTC-5, Kevin C wrote:
>>
>> The title isn't very descriptive, but I hope this paragraph clears things 
>> up.
>>
>> Basically we are creating a basic SaaS app.  Users will log in at 
>> theirname.oursite.com to an administrative panel.  Each administrative 
>> panel is tied to a user ID from the auth table.  So basically here is what 
>> should happen:
>>
>> User visits theirname.oursite.com/admin
>> Web2py retrieves users_id field from stores table (This field assigns 
>> ownership of each store to a user id)
>> Web2py auth decorator should ensure that the logged in user ID is that of 
>> the store owner
>>
>> I understand how to write the decorator, but what is the best way to 
>> retrieve the users_id from the stores table and store it?  Sessions? 
>>  Temporary variable that is set on each page load?
>>
>> Please forgive my ignorance.  I am completely new to web2py and want to 
>> develop using best practices.  I appreciate any guidance you can offer.
>>
>> Thank you.
>>
>

-- 



Reply via email to