What do you have running that results in something happening every 15
seconds? Your module won't run just by virtue of existing. You must be
running some code somewhere in order for the database to be getting
updated. If the only code that updates your database is your application
code, then th
Thanks, that makes sense. Ok test2 in the above code comes from a potentiometer
that is sensed inside the module. Right now I'm not really doing anything
specific and I'm using the code I put in here; I'm just trying to learn.
So what you said matches with my tests that with http request it gets
The model does not "routinely run" at all. None of your app code will run
at all (ever) unless (a) you make an HTTP request to the app (i.e., via a
browser), (b) you run a web2py shell via the command line via the -S
option, or (c) you run a job via the web2py scheduler.
I highly doubt your cod
even if you have many rows an insertion doesn't involve parsing this rows...
Richard
On Tue, Dec 8, 2015 at 2:11 PM, Richard Vézina
wrote:
> There is no reason that you app should take 15 sec except you have many
> many tables, you define functions or classes in models, you have many many
> row
There is no reason that you app should take 15 sec except you have many
many tables, you define functions or classes in models, you have many many
rows in your tables and you parse them or you operate over all of them...
What you show is a simple insertion even if there is no reason that it
could t
I think when a table gets updated on the web it already refreshes the
databases immediately and the data gets written, but I think the models
routinely run or there is a delay of about 15 second after you update the
data in a module to get into the database.
On Tuesday, 8 December 2015 14:03:3
I am testing it with a test code which is exactly what I wrote so there is
only one table with my field.
I think it makes sense, that's why there is scheduler and cron developed
for web2py. I'm trying to understand if I should run model1.py (where the
module1 is imported) as a web2py cron or sc
15 seconds... how many tables does your app has? I think you are doing
something wrong somewhere...
Richard
On Tue, Dec 8, 2015 at 1:53 PM, Aydin S wrote:
> I realized the data gets updated but it takes around 15 seconds which I
> think it is what the model1.py routinely runs. This is a problem
I realized the data gets updated but it takes around 15 seconds which I
think it is what the model1.py routinely runs. This is a problem for me
because I want it to run faster.
On Tuesday, 8 December 2015 13:37:42 UTC-5, Richard wrote:
>
> Notice if you chage your module file you need to resta
Notice if you chage your module file you need to restart web2py... Or user
track change feature, but in the past it was broken don't know if now it
works properly...
http://web2py.com/books/default/chapter/29/04/the-core?search=track_changes
On Tue, Dec 8, 2015 at 1:33 PM, Aydin S wrote:
> In ot
Yes you need db.commit() after db.Table1.insert(...)
To my understanding you also need in models/file_name.py
# from gluon import current
# current.db = db
Where you add db to current...
Not sure if it still the case with new web2py version but with 2.9.5 I need
to do that...
Richard
On Tue,
In other words, module1 does not seem to run unless I refresh the website.
On Tuesday, 8 December 2015 13:28:26 UTC-5, Aydin S wrote:
>
> Here is what I have:
>
> In model db.py I have:
>
> db.define_table('Table1',
> Field('var1', 'integer'),
> from module1 import insert_record
> insert_reco
Here is what I have:
In model db.py I have:
db.define_table('Table1',
Field('var1', 'integer'),
from module1 import insert_record
insert_record(db)
and in a module1 I write on the database and also get access to the
database:
from gluon import current
def insert_record(db):
db = curren
Difficult to say without seeing the code, you may need db.commit() or not.
Richard
On Tue, Dec 8, 2015 at 1:05 PM, Aydin S wrote:
> I got another question if you could help.
> The database does not get updated without I refresh the website in this
> scenario. I don't know why it is, do I need t
I got another question if you could help.
The database does not get updated without I refresh the website in this
scenario. I don't know why it is, do I need to use commit() somewhere or
since this is in the models it will not run as the variable inside the
module changes? Do I have to use sche
Thanks Anthony and Richard.
Yes, my variable was inside the module and was not a global one. Thanks for
the link, I am running the variable inside the function and it is local.
I tested the code and it worked.
On Monday, December 7, 2015 at 12:44:40 PM UTC-5, Richard wrote:
>
> @Hans, what is yo
@Hans, what is your question about variable in module exactly?
What you did seems correct to me...
About "db = current.db" be aware of that :
http://web2py.com/books/default/chapter/29/04/the-core#Warning--Do-not-use-the-current-object-in-global-scope-in-a-module
On Mon, Dec 7, 2015 at 12:13 PM,
Sure, that seems fine.
On Monday, December 7, 2015 at 12:13:07 PM UTC-5, Hans Soflao wrote:
>
> Thank you, I used the method Anthony mentioned and it worked.
> Now a follow up question, in order to have access to database in this
> module to assign var1 (defined in the database) to var2 (defined
Thank you, I used the method Anthony mentioned and it worked.
Now a follow up question, in order to have access to database in this
module to assign var1 (defined in the database) to var2 (defined in the
module) what is the best method?
For instance to have access to the latest row of data in th
In the general case, you can use current. For example, in a model do:
from gluon import current
current.db = db
And then in your MyExporter class code, you can refer to current.db.
In this particular case, though, there is no need, as the ExportClass is
initiated by passing it the Rows object f
Anthony, I see the advantage of passing db as a parameter to the code
on modules and not relaying to much on current, but what happen when u
can't control the parameters, for example i have a custom Exporter for
a grid in a module:
class MyExporter(ExportClass):
...
on a controller:
exports
In your module, you could have something like:
def insert_record(db):
db.Table1.insert(F1=var2)
And from a model or controller:
from mymodule import insert_record
insert_record(db)
Anthony
On Friday, December 4, 2015 at 9:39:35 AM UTC-5, Aydin S wrote:
>
> This might be asked before and I
22 matches
Mail list logo