[web2py] decremental subtraction of values in DB field 2

2019-09-17 Thread mostwanted
For a while now i have been trying to simulate excel functionality without 
success, i have had some assistance from Anthony but i still failed to make 
it work but its all because of my limited imagination, i just didn't 
understand his solution.

https://groups.google.com/forum/#!topicsearchin/web2py/author$3Ame/web2py/QyYe78_MH4Q

I am working on an application where I am changing a spread sheet document 
into a web application, the problem i am facing with one of the 
calculations is that I have to calculate for the answer_x and to get the 
value of answer_x i have to subtract the previously entered reading_x value 
from the newly entered reading_x value e,g in excel the value of answer_x 
is (=reading_x2 - reading_x1 ) or E1 would be (=D2-D1), i hope this is 
clear.

This was my solution:

db.define_table('subtract_value',
Field('reading_x', 'integer', requires=IS_NOT_EMPTY()),
Field('answer_x', compute=lambda 
r:r['reading_x']-r['reading_x']))


But Anthony suggested i do this:

def subtract_value_before_update(*args, **kwargs):
db.subtract_value.answer_x.compute = lambda r: 
(db.subtract_value.reading_x* -1) + r.reading_x

db.define_table('subtract_value',
Field('reading_x', 'integer'),
Field('answer_x', 'integer', default=0))

db.subtract_value._before_update.append(subtract_value_before_update)


I believe this solution can work if i only understood it but i dont, i am 
missing something because this code is not doing any calculations at all, I 
am not getting the calculated values I want but it could be the way i wrote 
it, i could be missing something or not doing something right! 

All i want i want to do is to calculate for answer_x by subtracting the 
previously entered value of reading_x from the newly entered value of 
reading_x.


How can i achive my task?


Regards;


Mostwanted

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d46731a7-bd34-48d1-bfaf-501672a9422f%40googlegroups.com.


[web2py] Re: AWS Lambda Deployment Recipe

2019-09-17 Thread Jaime Sempere
Hi Mike,

I've been following your recipe, but I have an 'read-only file system 
issue' (I think is due that I did not set up a database and web2py is 
trying to create the datatables files)


So, can you give me some clues about it? Also, how should i set up and 
configure my rds to work with web2py? I have not noticed anything about it 
on the recipe.

Check my log error from Zappa:

[1568721920013] [ERROR] 2019-09-17T12:05:20.12Z 
75fc21f1-e92e-4c80-ada1-a3e042112bf3 Traceback (most recent call last):
  File "/var/task/gluon/restricted.py", line 219, in restricted
  exec(ccode, environment)
  File "/var/task/applications/zerca_maps/models/db.py", line 179, in 

  Field('registered', 'boolean', default=False),
  File "/var/task/gluon/packages/dal/pydal/base.py", line 590, in 
define_table
  table = self.lazy_define_table(tablename, *fields, **kwargs)
  File "/var/task/gluon/packages/dal/pydal/base.py", line 624, in 
lazy_define_table
  polymodel=polymodel)
  File "/var/task/gluon/packages/dal/pydal/adapters/base.py", line 798, in 
create_table
  return self.migrator.create_table(*args, **kwargs)
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 318, in 
create_table
  fake_migrate=fake_migrate
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 463, in 
migrate_table
  self.save_dbt(table, sql_fields_current)
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 472, in 
save_dbt
  tfile = self.file_open(table._dbt, 'wb')
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 495, in 
file_open
  fileobj = portalocker.LockedFile(filename, mode)
  File "/var/task/gluon/packages/dal/pydal/contrib/portalocker.py", line 
185, in __init__
  self.file = open_file(filename, mode.replace('w', 'a'))
  File "/var/task/gluon/packages/dal/pydal/contrib/portalocker.py", line 
170, in open_file
  f = open(filename, mode)
IOError: [Errno 30] Read-only file system: 
'/var/task/applications/zerca_maps/databases/c
*8b669d15150d7109e5f7ab36744a5b7_retailers.table*'

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c9ca824e-da0d-4c26-8dfc-573b7de4a2f7%40googlegroups.com.


[web2py] Re: cache.action

2019-09-17 Thread Attilio Drei

for information, using web2py with python3 and gunicorn/meinheld, i am able 
to do 1000 queries per second using a redis backend and 1 key seek., in 
this case i set db to sqlite:memory.

GUNICORN_CMD_ARGS=" --workers=6 
--worker-class=meinheld.gmeinheld.MeinheldWorker"python3  
//web2py/anyserver.py -s gunicorn  --workers=6   -i 0.0.0.0 -p 8000 

https://fgimian.github.io/blog/2018/05/17/choosing-a-fast-python-api-framework/

meno male , lo  testo subito...


Il giorno martedì 17 settembre 2019 08:04:23 UTC+2, Massimo Di Pierro ha 
scritto:
>
> No. That is why I am making py4web and it is 20x faster.
>
> On Monday, 16 September 2019 23:02:02 UTC-7, Attilio Drei wrote:
>>
>> hi, when i set a cache action  still web2py  continue to do queries to 
>> database for every call. ( select 1; commit)
>> is possible to set db to null or sqlite:memory when in cache mode ?
>>
>>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2413c7eb-6cd8-40bf-8260-40b8033265b0%40googlegroups.com.


[web2py] Re: How to stopped redirection to user/login.html

2019-09-17 Thread Patito Feo
Hi,

After many hours of desperately search i found the solution.

You dont import Auth() on any of the controllers.

#from gluon.tools import Auth
#auth = Auth(db)

So, in db.py will imported and configured it for all the app.


Regards,



El miércoles, 11 de septiembre de 2019, 18:40:26 (UTC-5), Patito Feo 
escribió:
>
> Hi,
>
> I had done tests using a new empty application and this works. 
> My current application uses a customdb auth table and its using 
>
> auth.settings.on_failed_authentication = lambda url: redirect(url)
>
>
> but with custom tables settings do not apply.
>
> This are my auth.settings: 'on_failed_authentication':  
> at 0x7ff0d5f81758>.
> The setting is set correctly but still redirects to user/login.
>
>
> Regards,
>
>
>
> El jueves, 22 de agosto de 2019, 19:01:04 (UTC-5), Dave S escribió:
>>
>> On Thursday, August 22, 2019 at 4:32:02 PM UTC-7, Patito Feo wrote:
>>>
>>> Hi,
>>>
>>> This does not worked.
>>> Redirecting still goes to user/login.html.
>>>
>>> Any ideas?
>>>
>>> Cheers,
>>>
>>
>>
>> For a little more context, here's a larger quote form the book:
>>
>> If the visitor is not logger in, and calls a function that requires 
>>> authentication, the user is redirected to auth.settings.login_url which 
>>> defaults to URL('default', 'user/login'). One can replace this behavior by 
>>> redefining:
>>>
>>> auth.settings.on_failed_authentication = lambda url: redirect(url)
>>> This is the function called for the redirection. The argument url` 
>>> passed to this function is the url for the login page.
>>>
>>> If the visitor does not have permission to access a given function, the 
>>> visitor is redirect to the URL defined by
>>>
>>> auth.settings.on_failed_authorization = URL('user', 
>>> args='on_failed_authorization')
>>> You can change this variable and redirect the user elsewhere.
>>>
>>> Often on_failed_authorization is a URL but it can be a function that 
>>> returns the URL and it will be called on failed authorization.
>>>
>>
>>
>> from > http://web2py.com/books/default/chapter/29/09/access-control#Auth-Settings-and-messages
>> >
>>
>> Good luck!
>>
>> /dps
>>  
>>
>>>
>>> El jueves, 22 de agosto de 2019, 0:44:39 (UTC-5), Annet escribió:

 What about:

 auth.settings.on_failed_authentication = lambda url: redirect(url)


 That is what the book says changing the default behaviour.


 Kind regards,

 Annet





-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d0510ea8-34de-43fa-902f-d6ccea840dbc%40googlegroups.com.


[web2py] Not Anable To Start Web2py to Access Admin & IDE Site

2019-09-17 Thread dangeo
Hello, I'm new to Web2py and just getting started with it. I downloaded 
python 2.7 and also Web2py from gighub and extracted the files. Using 
windows command line i tried launching Web2py with the following line: 
C:\Users\xxx> python27\web2py web2py.py but i get this message: The system 
cannot find the path specified.
Please, would someone help me understand what i am doing wrong and what 
would be the best way to do it that the admin and IDE site launches. I 
greatly appreciate your help.

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8accc219-a4fc-46b5-9c47-673443546623%40googlegroups.com.


[web2py] Re: AWS Lambda Deployment Recipe

2019-09-17 Thread App Jar
Unfortunately no. I access the admin from localhost (my dev machine)

I also have an AWS CloudWatch alarm to trigger on an error in the 
CloudWatch logs and invoke a different lambda (running a python script) 
that writes the ticket to an error table in the DB so I can see those error 
tickets. 


On Tuesday, September 17, 2019 at 7:24:03 AM UTC-5, Jaime Sempere wrote:
>
> Hi Mike,
>
> I've been following your recipe, but I have an 'read-only file system 
> issue' (I think is due that I did not set up a database and web2py is 
> trying to create the datatables files)
>
>
> So, can you give me some clues about it? Also, how should i set up and 
> configure my rds to work with web2py? I have not noticed anything about it 
> on the recipe.
>
> Check my log error from Zappa:
>
> [1568721920013] [ERROR] 2019-09-17T12:05:20.12Z 
> 75fc21f1-e92e-4c80-ada1-a3e042112bf3 Traceback (most recent call last):
>   File "/var/task/gluon/restricted.py", line 219, in restricted
>   exec(ccode, environment)
>   File "/var/task/applications/zerca_maps/models/db.py", line 179, in 
> 
>   Field('registered', 'boolean', default=False),
>   File "/var/task/gluon/packages/dal/pydal/base.py", line 590, in 
> define_table
>   table = self.lazy_define_table(tablename, *fields, **kwargs)
>   File "/var/task/gluon/packages/dal/pydal/base.py", line 624, in 
> lazy_define_table
>   polymodel=polymodel)
>   File "/var/task/gluon/packages/dal/pydal/adapters/base.py", line 798, in 
> create_table
>   return self.migrator.create_table(*args, **kwargs)
>   File "/var/task/gluon/packages/dal/pydal/migrator.py", line 318, in 
> create_table
>   fake_migrate=fake_migrate
>   File "/var/task/gluon/packages/dal/pydal/migrator.py", line 463, in 
> migrate_table
>   self.save_dbt(table, sql_fields_current)
>   File "/var/task/gluon/packages/dal/pydal/migrator.py", line 472, in 
> save_dbt
>   tfile = self.file_open(table._dbt, 'wb')
>   File "/var/task/gluon/packages/dal/pydal/migrator.py", line 495, in 
> file_open
>   fileobj = portalocker.LockedFile(filename, mode)
>   File "/var/task/gluon/packages/dal/pydal/contrib/portalocker.py", line 
> 185, in __init__
>   self.file = open_file(filename, mode.replace('w', 'a'))
>   File "/var/task/gluon/packages/dal/pydal/contrib/portalocker.py", line 
> 170, in open_file
>   f = open(filename, mode)
> IOError: [Errno 30] Read-only file system: 
> '/var/task/applications/zerca_maps/databases/c
> *8b669d15150d7109e5f7ab36744a5b7_retailers.table*'
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e2ee7c69-a27d-47d2-abfc-01d7d2d31032%40googlegroups.com.


Re: [web2py] Not Anable To Start Web2py to Access Admin & IDE Site

2019-09-17 Thread Nico Zanferrari
Hi,

the error you're getting is because you've installed python 2.7 without
adding it to the system's path - and so Windows cannot find it. See here
 or the second step here

in
order to fix it.

Also, (if you don't have any specific reason) for newbie I suggest to go
directly with Python 3 because Python 2.x is on its end of life ;-)

Cheers,
Nico

Il giorno mer 18 set 2019 alle ore 05:05 dangeo  ha
scritto:

> Hello, I'm new to Web2py and just getting started with it. I downloaded
> python 2.7 and also Web2py from gighub and extracted the files. Using
> windows command line i tried launching Web2py with the following line:
> C:\Users\xxx> python27\web2py web2py.py but i get this message: The system
> cannot find the path specified.
> Please, would someone help me understand what i am doing wrong and what
> would be the best way to do it that the admin and IDE site launches. I
> greatly appreciate your help.
>
> --
> 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 web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/8accc219-a4fc-46b5-9c47-673443546623%40googlegroups.com
> 
> .
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAAE8D_DAyS2d2RixoTLgjmALLs%2BfNf9Otk6QDeFAVwL0amko%2BQ%40mail.gmail.com.


[web2py] How to hide address/tool bar when going mobile

2019-09-17 Thread Maurice Waka
Hello
I'm testing my app on mobile sites and noticed that the address bad messes 
up the screen estate when going mobile.
I'd like to auto-hide it as soon as a user logs in.
Tried these below but noted that the address bar does not disappear form 
the screen. I want the app to go full screen on mobile browser.


  html, body {margin: 0; height: 100%; overflow: hidden}


$(function() {
$(window).scrollTo(0,1);
}

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e5c8e607-87f7-4131-ae7f-b7598a390adb%40googlegroups.com.