Please bear with me while I explain my use case:
I have a list of "standard" websites, like all the major search engines.
Traditionally, I can make do with a python list, like so:
list_of_sites =['google.com','yahoo.com',...]
However, the code base has evolved and it's much better to have other data
too, like:
one_site = dict(
url='google.com',
name='Google',
short='G',
..and many more..
)
I have that for each site. As you can see, having a table will serve this
data much better.
My problem is when I need to use this same list of sites, but for different
apps (as defined by web2py, i.e. having a new folder within the application
folder)
I will need to add these sites each time and when I make an edit, I have to
edit the same table but over many apps.
And in each app, there are other tables that reference data from this
table, like so:
Field('site_id', 'reference abcde_sites')
I thought, if there is a way to hardcode this table into a file, somewhat,
so that I just need to duplicate the file, or even, just reference or load
the same file, and web2py will include it as a web2py's "define.table".
As the last resort I may use a "list of dicts", but I do not know how to
keep the current references to this particular table.
In summary, I am using sqlite db. There is a table that I don't wish to
store in the sqlite db, but yet have that particular table data be served /
accessed like a normal table (as if from the db). Is that possible, and how
can I achieve this?
Why did I ask this question? Because I vaguely recall some very old
examples of web2py where items are inserted to a "virtual" table, that only
exists in that controller (it wasn't defined in the model). So only when
you call that controller, that particular table will be "loaded", and with
that particular set of data. If another controller tried to access that
table, that data had vanished.
Thank you.
On Wednesday, May 17, 2017 at 6:48:16 AM UTC+8, Anthony wrote:
>
> On Tuesday, May 16, 2017 at 12:34:01 PM UTC-4, lyn2py wrote:
>>
>> Thanks Anthony, I'm sorry my question was ambiguous.
>>
>> I meant to define a table and to add data to a table that doesn't exist
>> in the sqlite table, but yet web2py can get the data (I can "hardcode" the
>> data into the controller or model). How do I achieve that? Or rather can I?
>>
>
> Sorry, still not clear what you are really trying to do. Maybe show the
> code you would like to write and what you want to happen once the code
> executes. It's still not clear whether this table exists in the SQLite
> database, some other database, or nowhere at all (and if the latter, then
> where the data goes).
>
> Anthony
>
--
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.