On Friday, March 18, 2016 at 10:19:40 AM UTC-7, Lisandro wrote:
>
> Anthony, thank you very much for your help.
>
 

> [...]
> I'm tempted to ask one more thing that I'm wondering about:
>
> In my model, I  have several tables (lets say about 8 or 9) that are used 
> to store information about list of options. 
> These tables only have a few records each, and they will never grow.
>
> For example, one table could be "days" (I don't have this table 
> specifically, it's for the example).
> So, let's say the table "days" has a "name" field and a "plural_name" 
> field.
> The table is populated with data only once, at application startup, and 
> remains the same forever: "days" table will only have 7 records, one for 
> each day of the week.
>
> Now, the part that I'm worried about is this: *inside the same model, I 
> store each record in a variable*, like this:
>
> db.define_table('days', Field('name'), Field('plural_name'))
>
> MONDAY = db.days[1]
> TUESDAY = db.days[2]
> WEDNESDAY = db.days[3]
> THURSDAY = db.days[4]
> FRIDAY = db.days[5]
> SATURDAY = db.days[6]
> SUNDAY = db.days[7]
>
> I use that to be able to reference each day from the app code, but I've 
> realised that in this way, the "days" table won't be lazy, because it's 
> called to get the record.
>
> So my question is: *what would be the correct approach for storing that 
> kind of records in variables, without compromising lazy tables?*
>
>
For tables this small, does lazy make a difference?  You're only calling 
the Field constructor twice in this example.

You may have a good reason for having this sort of thing as a table, but if 
you're just wanting a global list, putting an actual list in the globals 
seems reasonable.

/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to