[web2py] Re: Web2py locks row at auth_user and web2py_session_* tables and doesn't unlock them

2018-04-20 Thread Lisandro
Sorry to bother you again with this, but I think I've found the problem.
*The problem is apparently with Redis integration. *It had nothing to do 
with connections, database, sessions, none of that. Here is what I've found.

Remember, the line where my app hangs is this:

*session.important_messages = cache.redis('important-messages-%s' % 
auth.user.id ,*
*  lambda: 
get_important_messages(), *
* time_expire=180)*


As the problem only presented in production, on the website of my customer, 
I asked him to allow me to play a little with the code. 
So, first thing I did was to cache request.now instead of calling the 
function "get_important_messages()", but the problem remained.
Then I thought "maybe if I change the key..." and I changed the original 
code to this:

*session.important_messages = cache.redis('important-messages',*
* lambda: get_important_messages(),*
* time_expire=180)*


*Notice that only thing I changed was the key to store in Redis. And it 
worked! *I thought that maybe "auth.user.id" was some large number, but I 
checked and the user ID is 3. Tried to pass it like int(auth.user.id) but I 
had no success. *App still hangs when I try to retrieve that specific key*. 
Only that key.

I've connected to redis-cli and it tells me that the key isn't there.
So I set a "hello" value for the key, I get it, then I deleted it:

$ redis-cli
127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
(nil)
127.0.0.1:6379> SET w2p:myapp:important-messages-3 "hello"
OK
127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
"\x00\x05hello\x06\x00\xf5\x9f\xb7\xf6\x90a\x1c\x99"
127.0.0.1:6379> DEL w2p:myapp:important-messages-3
(integer) 1127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
(nil)


But event after that, web2py hangs with this simple code:

*r = cache.redis('important-messages-3', **lambda: request.now, *
*time_expire=30)*

This happens only with that specific key. I can set the key to 
"important-messages-2", "important-messages-999", "important-messages-A", 
anything I can think, but with that specific key it hangs.

We have several websites (around 200), and this problem has happened about 
5 o 6 times in different websites, but it was always the same problem. The 
only solution I had (until now) was to create a new account for the user 
(that explains why it worked with a new account, that is because the new 
account had a different auth.user.id, so the key to store in redis was 
different).

Could this be a bug in the redis_cache.py integration?
Maybe I should open a new thread about this, right?


El jueves, 19 de abril de 2018, 10:27:46 (UTC-3), Lisandro escribió:
>
> Hi there,
> I've found the issue but I still don't know how is it produced.
> Anthony was right from the begining when he said "the app is not hanging 
> because the locks are being held, but rather the locks are being held 
> because the app is hanging"
> Since that comment, I was waiting for the problem to happen again to 
> decompile the app and print some logs to see exactly the line of code where 
> the application hangs. 
>
> So that's what I did, and *I've found that my app indeed hangs in an 
> specific line of code of models/db.py:*
> This is my models/db.py resumed:
>
>
> if auth.is_logged_in() and auth.user.responsable:
>
> 
>
> *# --- THIS IS THE LINE WHERE THE CODE HANGS --*
> *session.important_messages = cache.redis('important_messages-%s' % 
> auth.user.id ,*
> * lambda: 
> get_important_messages(), *
> * time_expire=180)*
>
>
>
>
> So I checked what the function "get_important_messages()" does, and I see 
> that it connects to a webservice (also developed with web2py):
>
>
> def get_important_messages():
> from gluon.contrib.simplejsonrpc import ServerProxy
>
> webservice = ServerProxy('
> https://main-app-domain.com/ws/call/jsonrpc?token=XXX1')
> try:
> result = webservice.get_account_info(CONFIG.customer_id)
> except Exception as e:
> result = []
> return result
>
>
>
> Then I went to double check my nginx error.log, this time looking for 
> errors in the URL that the app uses to connect to the webservice. 
> Surprisingly, I'm seeing a few timeouts everyday for that URL:
>
> 2018/04/17 15:08:22 [error] 23587#23587: *93711423 upstream timed out 
> (110: Connection timed out) while reading response header from upstream, 
> client: MY.OWN.SERVER.IP, server: main-app-domain.com, request: "POST 
> /ws/call/jsonrpc?token=XXX1 HTTP/1.1", upstream: 
> "uwsgi://unix:///tmp/medios.socket", host: "main-app-domain.com"
> 2018/04/17 15:08:22 [error] 23587#23587: *93711449 upstream timed out 
> (110: Connection timed out) while rea

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-20 Thread dirman
db.define_table('articles',
Field('article_date', 'date'),
Field('article_title'),
Field('article_link', compute=lambda r: r.article_title.replace(' ', 
'-')),   
Field('image', 'upload'),  
Field('body', 'text'))

def index():
return dict()

def articles()
 article = db(db.articles.article_link==request.args[0]).select()[0]
 return dict(article=article)

I want to use manage and grid functions to edited the articles table
so records should to editable after insertion.

@auth.requires_membership('admin')
def manage():
 grid=SQLFORM.grid(db.articles, 
editargs=dict(fields=['article_date','article_title','article_link','image','body']))
 return grid

@auth.requires_membership('admin')
def grid():
response.view = 'generic.html' 
tablename = request.args(0)
if not tablename in db.tables: raise HTTP(403)
grid = SQLFORM.smartgrid(db[tablename], args=[tablename], 
deletable=False, editable=True)
return dict(grid=grid)

With the compute function on the table the SQLFORM.grid or smartgrid 
records can not be updated.

On Friday, April 20, 2018 at 12:27:07 AM UTC, Anthony wrote:
>
> On Thursday, April 19, 2018 at 3:43:02 PM UTC-4, dirman wrote:
>>
>> The page reloads the same SQLFORM edit form page with edited field not 
>> submited
>>
>
> Works for me. Please show all your code and describe the exact workflow.
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Richard
Hello,

I was under the impression that IS_DECIMAL_IN_RANGE(2.25, 5.25) would 
validate and prevent input having more places the number of places of min 
and max...

I am I wrong? Did it use to work like that in the past??

How can we make sure there is only a given number of places in an input?

Thanks

Richard

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py locks row at auth_user and web2py_session_* tables and doesn't unlock them

2018-04-20 Thread Anthony
When you set up the Redis cache, do you set with_lock=True? If so, I wonder 
if an error here 

 
could be causing the key to be locked and never released. I guess you can 
check for a key named "w2p:myapp:important-messages-3:__lock".

Anthony

On Friday, April 20, 2018 at 7:28:28 AM UTC-4, Lisandro wrote:
>
> Sorry to bother you again with this, but I think I've found the problem.
> *The problem is apparently with Redis integration. *It had nothing to do 
> with connections, database, sessions, none of that. Here is what I've found.
>
> Remember, the line where my app hangs is this:
>
> *session.important_messages = cache.redis('important-messages-%s' % 
> auth.user.id ,*
> *  lambda: 
> get_important_messages(), *
> * time_expire=180)*
>
>
> As the problem only presented in production, on the website of my 
> customer, I asked him to allow me to play a little with the code. 
> So, first thing I did was to cache request.now instead of calling the 
> function "get_important_messages()", but the problem remained.
> Then I thought "maybe if I change the key..." and I changed the original 
> code to this:
>
> *session.important_messages = cache.redis('important-messages',*
> * lambda: 
> get_important_messages(),*
> * time_expire=180)*
>
>
> *Notice that only thing I changed was the key to store in Redis. And it 
> worked! *I thought that maybe "auth.user.id" was some large number, but I 
> checked and the user ID is 3. Tried to pass it like int(auth.user.id) but 
> I had no success. *App still hangs when I try to retrieve that specific 
> key*. Only that key.
>
> I've connected to redis-cli and it tells me that the key isn't there.
> So I set a "hello" value for the key, I get it, then I deleted it:
>
> $ redis-cli
> 127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
> (nil)
> 127.0.0.1:6379> SET w2p:myapp:important-messages-3 "hello"
> OK
> 127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
> "\x00\x05hello\x06\x00\xf5\x9f\xb7\xf6\x90a\x1c\x99"
> 127.0.0.1:6379> DEL w2p:myapp:important-messages-3
> (integer) 1127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
> 127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
> (nil)
>
>
> But event after that, web2py hangs with this simple code:
>
> *r = cache.redis('important-messages-3', **lambda: request.now, *
> *time_expire=30)*
>
> This happens only with that specific key. I can set the key to 
> "important-messages-2", "important-messages-999", "important-messages-A", 
> anything I can think, but with that specific key it hangs.
>
> We have several websites (around 200), and this problem has happened about 
> 5 o 6 times in different websites, but it was always the same problem. The 
> only solution I had (until now) was to create a new account for the user 
> (that explains why it worked with a new account, that is because the new 
> account had a different auth.user.id, so the key to store in redis was 
> different).
>
> Could this be a bug in the redis_cache.py integration?
> Maybe I should open a new thread about this, right?
>
>
> El jueves, 19 de abril de 2018, 10:27:46 (UTC-3), Lisandro escribió:
>>
>> Hi there,
>> I've found the issue but I still don't know how is it produced.
>> Anthony was right from the begining when he said "the app is not hanging 
>> because the locks are being held, but rather the locks are being held 
>> because the app is hanging"
>> Since that comment, I was waiting for the problem to happen again to 
>> decompile the app and print some logs to see exactly the line of code where 
>> the application hangs. 
>>
>> So that's what I did, and *I've found that my app indeed hangs in an 
>> specific line of code of models/db.py:*
>> This is my models/db.py resumed:
>>
>>
>> if auth.is_logged_in() and auth.user.responsable:
>>
>> 
>>
>> *# --- THIS IS THE LINE WHERE THE CODE HANGS --*
>> *session.important_messages = cache.redis('important_messages-%s' % 
>> auth.user.id ,*
>> * lambda: 
>> get_important_messages(), *
>> * time_expire=180)*
>>
>>
>>
>>
>> So I checked what the function "get_important_messages()" does, and I see 
>> that it connects to a webservice (also developed with web2py):
>>
>>
>> def get_important_messages():
>> from gluon.contrib.simplejsonrpc import ServerProxy
>>
>> webservice = ServerProxy('
>> https://main-app-domain.com/ws/call/jsonrpc?token=XXX1')
>> try:
>> result = webservice.get_account_info(CONFIG.customer_id)
>> except Exception as e:
>> result = []
>> return result
>>
>>
>>
>> Then I went to double check my nginx error.log, this time looking 

Re: [web2py] web2py, nginx and big files

2018-04-20 Thread Carlos Cesar Caballero Díaz


El 19/04/18 a las 16:21, Richard Vézina escribió:
Ah ok, make sens then. Are you storing the file in database or on file 
system at web2py level??



In the file system, I think that storing big (or so many) files in the 
database can overload it.




There is surely a way to make the copy only once at the right place, 
but I am pretty sure it mean writting some customization at uwsgi 
level and most probably some conf in nginx to bypass it usual mechanism.


I have being reading and found this 
https://stackoverflow.com/a/44751210/1818267 its interesting, besides it 
carries some new issues to solve.




I try to make some research and get back to you if I can fin anything 
that could help.


Good luck


Thanks, I'll be very grateful (more grateful :D).

Greetings



Richard

On Wed, Apr 18, 2018 at 10:37 PM, Carlos Cesar Caballero Díaz 
> wrote:



El 18/04/18 a las 13:54, Richard Vézina escribió:

That big... Hope it could work for you...


Well, right now is working with your suggestion, but not perfect,
is really slow because nginx uploads the file to a tmp file, next
seems to copy the file to another place (I assume to uwsgi) and
next is copied to web2py uploads, really annoying. I think that
there should be a better way to do that.



Are you trying to make El packet transiting the island faster or
what...

:D


Not exactly, but I like how you think :D

I am working with Joven Club, a "company" that provides technical
and learning services throughout the country, and I am building a
tool for helping with the software installation service, it's
really simple, basically a software installers repository where
people can search and download (and certain people upload the
files, of course).




Richard

On Wed, Apr 18, 2018 at 1:45 PM, Carlos Cesar Caballero Díaz
mailto:carlos.caball...@cfg.jovenclub.cu>> wrote:

Thanks Richard, It seems to be working now. The files can be
several Gigabytes.


Greetings.


El 17/04/18 a las 13:10, Richard Vézina escribió:

How big?

https://www.bookstackapp.com/docs/admin/upload-limits/



https://www.nginx.com/resources/wiki/modules/upload/#upload-max-file-size



Quote from the above link:
For “hard” limit client_max_body_size directive must be
used. The value of zero for this directive specifies that no
restrictions on file size should be applied.


Have a look at your nginx config upload_max_file_size and
client_max_body_size

I can't find the default nginx limit, but I think upload are
around 5 mg, I recall having issue long time ago about
upload limit and the attachement was a little over 5 meg, so...

In the link you provide there not seems to have limit
overriding default, so my guess is that your file is bigger
than the client_max_body_size

Good luck

Richard

On Tue, Apr 17, 2018 at 12:10 PM, Carlos Cesar Caballero
Díaz mailto:carlos.caball...@cfg.jovenclub.cu>> wrote:

Hi, I have a web2py + nginx setup

(https://github.com/arisobel/web2py_scripts/blob/master/setup-web2py-nginx-p3-uwsgi-ubuntu.sh

)
and I need to upload big files to my application, the
app is working ok with the built in server, but with
nginx the form submission fails with no response when
there are big files.

Any tip for solving this?


Greetings.

-- 
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
.
For more options, visit
https://groups.google.com/d/optout
.


-- 
Resources:

- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py
 (Source code)
- https://code.google.com/p/web2py/issues/list
  

[web2py] Re: Web2py locks row at auth_user and web2py_session_* tables and doesn't unlock them

2018-04-20 Thread Lisandro
Thank you very much for your time Anthony.

Yes, I use Redis with_lock=True.
I checked but there is no *__lock key stored in Redis. I double checked 
that.

But, giving you mentioned with_lock, I tried to set with_lock=False, and it 
worked. 
Then I set with_lock=True again, and it worked too.
*Apparently, the problem went away after executing the request one time 
with_lock=False, and then I could set it back to True and it kept working 
ok*.

I'm using an old version of web2py (2.10). 
I already have plans to upgrade next month.
I've checked the difference between the redis_cache.py file of my version 
and the current stable one: https://www.diffchecker.com/owJ67Slp
But I'm not able to see if the new version could help on this. It is indeed 
a weird problem.


In the book I've read that with_lock=True is good to avoid that two 
different threads write the same key value. In my case, I suppose it won't 
hurt if that happens (my app uses cache in order to increase performance).
Should I consider setting it to False?



El viernes, 20 de abril de 2018, 10:54:20 (UTC-3), Anthony escribió:
>
> When you set up the Redis cache, do you set with_lock=True? If so, I 
> wonder if an error here 
> 
>  
> could be causing the key to be locked and never released. I guess you can 
> check for a key named "w2p:myapp:important-messages-3:__lock".
>
> Anthony
>
> On Friday, April 20, 2018 at 7:28:28 AM UTC-4, Lisandro wrote:
>>
>> Sorry to bother you again with this, but I think I've found the problem.
>> *The problem is apparently with Redis integration. *It had nothing to do 
>> with connections, database, sessions, none of that. Here is what I've found.
>>
>> Remember, the line where my app hangs is this:
>>
>> *session.important_messages = cache.redis('important-messages-%s' % 
>> auth.user.id ,*
>> *  lambda: 
>> get_important_messages(), *
>> * time_expire=180)*
>>
>>
>> As the problem only presented in production, on the website of my 
>> customer, I asked him to allow me to play a little with the code. 
>> So, first thing I did was to cache request.now instead of calling the 
>> function "get_important_messages()", but the problem remained.
>> Then I thought "maybe if I change the key..." and I changed the original 
>> code to this:
>>
>> *session.important_messages = cache.redis('important-messages',*
>> * lambda: 
>> get_important_messages(),*
>> * time_expire=180)*
>>
>>
>> *Notice that only thing I changed was the key to store in Redis. And it 
>> worked! *I thought that maybe "auth.user.id" was some large number, but 
>> I checked and the user ID is 3. Tried to pass it like int(auth.user.id) 
>> but I had no success. *App still hangs when I try to retrieve that 
>> specific key*. Only that key.
>>
>> I've connected to redis-cli and it tells me that the key isn't there.
>> So I set a "hello" value for the key, I get it, then I deleted it:
>>
>> $ redis-cli
>> 127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
>> (nil)
>> 127.0.0.1:6379> SET w2p:myapp:important-messages-3 "hello"
>> OK
>> 127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
>> "\x00\x05hello\x06\x00\xf5\x9f\xb7\xf6\x90a\x1c\x99"
>> 127.0.0.1:6379> DEL w2p:myapp:important-messages-3
>> (integer) 1127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
>> 127.0.0.1:6379> DUMP w2p:myapp:important-messages-3
>> (nil)
>>
>>
>> But event after that, web2py hangs with this simple code:
>>
>> *r = cache.redis('important-messages-3', **lambda: request.now, *
>> *time_expire=30)*
>>
>> This happens only with that specific key. I can set the key to 
>> "important-messages-2", "important-messages-999", "important-messages-A", 
>> anything I can think, but with that specific key it hangs.
>>
>> We have several websites (around 200), and this problem has happened 
>> about 5 o 6 times in different websites, but it was always the same 
>> problem. The only solution I had (until now) was to create a new account 
>> for the user (that explains why it worked with a new account, that is 
>> because the new account had a different auth.user.id, so the key to 
>> store in redis was different).
>>
>> Could this be a bug in the redis_cache.py integration?
>> Maybe I should open a new thread about this, right?
>>
>>
>> El jueves, 19 de abril de 2018, 10:27:46 (UTC-3), Lisandro escribió:
>>>
>>> Hi there,
>>> I've found the issue but I still don't know how is it produced.
>>> Anthony was right from the begining when he said "the app is not hanging 
>>> because the locks are being held, but rather the locks are being held 
>>> because the app is hanging"
>>> Since that comment, I was waiting for the problem to happen again to 
>>> decompile the app and print some logs to see exactly 

[web2py] Re: Web2py locks row at auth_user and web2py_session_* tables and doesn't unlock them

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 10:47:10 AM UTC-4, Lisandro wrote:
>
> Thank you very much for your time Anthony.
>
> Yes, I use Redis with_lock=True.
> I checked but there is no *__lock key stored in Redis. I double checked 
> that.
>
> But, giving you mentioned with_lock, I tried to set with_lock=False, and 
> it worked. 
> Then I set with_lock=True again, and it worked too.
> *Apparently, the problem went away after executing the request one time 
> with_lock=False, and then I could set it back to True and it kept working 
> ok*.
>
> I'm using an old version of web2py (2.10).
>

Looking at the code 

 
under 2.10, it is not clear what the problem could be, as the locking code 
is in a try block and there is a "finally" clause that deletes the lock key 
if there is an exception.

The current code in master looks like it could result in a lock being stuck 
if an exception occurs while storing or retrieving a cache item.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-20 Thread Anthony
Sorry, using your exact code, I cannot reproduce the problem. I am able to 
edit records (including the article_link field) using the grid.

Anthony

On Friday, April 20, 2018 at 9:03:50 AM UTC-4, dirman wrote:
>
> db.define_table('articles',
> Field('article_date', 'date'),
> Field('article_title'),
> Field('article_link', compute=lambda r: r.article_title.replace(' ', 
> '-')),   
> Field('image', 'upload'),  
> Field('body', 'text'))
>
> def index():
> return dict()
>
> def articles()
>  article = db(db.articles.article_link==request.args[0]).select()[0]
>  return dict(article=article)
>
> I want to use manage and grid functions to edited the articles table
> so records should to editable after insertion.
>
> @auth.requires_membership('admin')
> def manage():
>  grid=SQLFORM.grid(db.articles, 
> editargs=dict(fields=['article_date','article_title','article_link','image','body']))
>  return grid
>
> @auth.requires_membership('admin')
> def grid():
> response.view = 'generic.html' 
> tablename = request.args(0)
> if not tablename in db.tables: raise HTTP(403)
> grid = SQLFORM.smartgrid(db[tablename], args=[tablename], 
> deletable=False, editable=True)
> return dict(grid=grid)
>
> With the compute function on the table the SQLFORM.grid or smartgrid 
> records can not be updated.
>
> On Friday, April 20, 2018 at 12:27:07 AM UTC, Anthony wrote:
>>
>> On Thursday, April 19, 2018 at 3:43:02 PM UTC-4, dirman wrote:
>>>
>>> The page reloads the same SQLFORM edit form page with edited field not 
>>> submited
>>>
>>
>> Works for me. Please show all your code and describe the exact workflow.
>>
>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 9:38:47 AM UTC-4, Richard wrote:
>
> Hello,
>
> I was under the impression that IS_DECIMAL_IN_RANGE(2.25, 5.25) would 
> validate and prevent input having more places the number of places of min 
> and max...
>

No, it just ensures that the value is greater than or equal to the min and 
less than or equal to the max. This validator has nothing to do with the 
number of decimal places.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py locks row at auth_user and web2py_session_* tables and doesn't unlock them

2018-04-20 Thread Lisandro
I see what you mean. 
But still, if my interpretation is correct, in those cases we should see 
the *__lock key stored.
What is weird about my specific issue is that there was no *__lock key.

Anyway, regardless upgrading web2py, now I'm wondering if I should set 
with_lock True or False. Do you have any suggestion? The book says:
"*Redis cache subsystem allows you to prevent the infamous "thundering herd 
problem": this is not active by default because usually you choose redis 
for speed, but at a negligible cost you can make sure that only one 
thread/process can set a value concurrently.*" 

I haven't found comments regarding when is best to use with_lock=True and 
when to use with_lock=False. I'm guessing with_lock=True is best when the 
process that generates the data that is going to be cached takes long time 
or uses much resources. That's not my case, so I'm tempted to change it to 
False, but I'm not sure about the decision. If you have any experience or 
suggestion about that, I'll appreciate you comment about it.

Thanks again.
Regards,
Lisandro.


El viernes, 20 de abril de 2018, 12:19:11 (UTC-3), Anthony escribió:
>
> On Friday, April 20, 2018 at 10:47:10 AM UTC-4, Lisandro wrote:
>>
>> Thank you very much for your time Anthony.
>>
>> Yes, I use Redis with_lock=True.
>> I checked but there is no *__lock key stored in Redis. I double checked 
>> that.
>>
>> But, giving you mentioned with_lock, I tried to set with_lock=False, and 
>> it worked. 
>> Then I set with_lock=True again, and it worked too.
>> *Apparently, the problem went away after executing the request one time 
>> with_lock=False, and then I could set it back to True and it kept working 
>> ok*.
>>
>> I'm using an old version of web2py (2.10).
>>
>
> Looking at the code 
> 
>  
> under 2.10, it is not clear what the problem could be, as the locking code 
> is in a try block and there is a "finally" clause that deletes the lock key 
> if there is an exception.
>
> The current code in master looks like it could result in a lock being 
> stuck if an exception occurs while storing or retrieving a cache item.
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Login not working on smartphone - no the same menu layout

2018-04-20 Thread Andrea Fae'
Please help me...

Il giorno mercoledì 18 aprile 2018 20:31:38 UTC+2, Andrea Fae' ha scritto:
>
> this is my application
>
> https://andfae.pythonanywhere.com/tcf/default/index
>
> I can't login with android. I don't know. I see in the upper right of the 
> smartphone 3 lines but when I click nothing happens...How to fix it?
> I didn't find anything about this problem it. 
> Maybe is it regarding bootstrap 4 in web2py?
> Thank you
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Richard Vézina
Realize that, though I am sure it use to managed it...

Anyway, I find it curious that even if I have field of type decimal(10, 2)
for instance, if I insert 1.304, and submit the form it ends up with 1.304
in the read form (backend has 3 places).

How do we validated the number of places??

Richard

On Fri, Apr 20, 2018 at 11:32 AM, Anthony  wrote:

> On Friday, April 20, 2018 at 9:38:47 AM UTC-4, Richard wrote:
>>
>> Hello,
>>
>> I was under the impression that IS_DECIMAL_IN_RANGE(2.25, 5.25) would
>> validate and prevent input having more places the number of places of min
>> and max...
>>
>
> No, it just ensures that the value is greater than or equal to the min and
> less than or equal to the max. This validator has nothing to do with the
> number of decimal places.
>
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py locks row at auth_user and web2py_session_* tables and doesn't unlock them

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 11:58:47 AM UTC-4, Lisandro wrote:
>
> I see what you mean. 
> But still, if my interpretation is correct, in those cases we should see 
> the *__lock key stored.
> What is weird about my specific issue is that there was no *__lock key.
>
> Anyway, regardless upgrading web2py, now I'm wondering if I should set 
> with_lock True or False. Do you have any suggestion? The book says:
> "*Redis cache subsystem allows you to prevent the infamous "thundering 
> herd problem": this is not active by default because usually you choose 
> redis for speed, but at a negligible cost you can make sure that only one 
> thread/process can set a value concurrently.*" 
>
> I haven't found comments regarding when is best to use with_lock=True and 
> when to use with_lock=False.
>

Probably safest to set it to True unless that slows things down noticeably. 
Or go with False if you can tolerate the occasional race condition.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Docker Image for CentOS and Alpine

2018-04-20 Thread David Sperling
We have been using Web2py for several years and are now Dockerizing our 
solution for a cloud deployment.

After looking through the existing Docker solutions, we did not find a 
project that met our requirements:

   - Based on CentOS (Alpine is supported as well)
   - Void of HTTPS support - we handle this with a separate Docker 
   container running nginx
   - Supports both uWSGI for deployment and HTTP for developer testing
   - Supports all Web2py versions
   - Minimalistic with very few layers and following Dockerfile best 
   practices

If anyone has similar requirements or would like to help us test these new 
images, you can find them here.

https://github.com/smithmicro/web2py

or

docker run -p 8080:8080 smithmicro/web2py

Many thanks to the Web2py community!

Cheers,
Dave Sperling
Smith Micro

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] self-reference parter autoupdate

2018-04-20 Thread JSalvat
Hello,

Why on update/insert a record with a non-empty partner, the partner does 
not get updated as well with the backwards reference?

db.define_table('person',
Field('name', requires=IS_NOT_EMPTY()),
Field('partner', 'reference person', 
requires=IS_EMPTY_OR(IS_IN_DB(db,'person.id'

db.person.insert(name='John')
1
>>> for person in db().select(db.person.ALL):
... print person.id, ' - ', person.name, ' - ', person.partner
...
1  -  John  -  None

db.person.insert(name='Maria', partner=1)
2
>>> for person in db().select(db.person.ALL):
... print person.id, ' - ', person.name, ' - ', person.partner
...
1  -  John  -  None
2  -  Maria  -  1

Should not be this the result, since is a reciprocal relation?

1  -  John  -  2
2  -  Maria  -  1

I'll appreciate any help to clarify this. Thanks

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Richard Vézina
It appears that it get silently "cropped/rounded" by the backend field type
configuration... If I have field with 2 places in the backend and 3 places
defined in the models and input 0.647, it will be stored as 0.65.

Do we have control over the rounding in web2py or it configure in the
database engine??

Richard

On Fri, Apr 20, 2018 at 2:30 PM, Richard Vézina  wrote:

> Realize that, though I am sure it use to managed it...
>
> Anyway, I find it curious that even if I have field of type decimal(10, 2)
> for instance, if I insert 1.304, and submit the form it ends up with 1.304
> in the read form (backend has 3 places).
>
> How do we validated the number of places??
>
> Richard
>
> On Fri, Apr 20, 2018 at 11:32 AM, Anthony  wrote:
>
>> On Friday, April 20, 2018 at 9:38:47 AM UTC-4, Richard wrote:
>>>
>>> Hello,
>>>
>>> I was under the impression that IS_DECIMAL_IN_RANGE(2.25, 5.25) would
>>> validate and prevent input having more places the number of places of min
>>> and max...
>>>
>>
>> No, it just ensures that the value is greater than or equal to the min
>> and less than or equal to the max. This validator has nothing to do with
>> the number of decimal places.
>>
>> 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 web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 2:30:22 PM UTC-4, Richard wrote:
>
> Realize that, though I am sure it use to managed it...
>

Not going back to at least web2py 2.02, as far as I can tell.
 

> Anyway, I find it curious that even if I have field of type decimal(10, 2) 
> for instance, if I insert 1.304, and submit the form it ends up with 1.304 
> in the read form (backend has 3 places).
>

As far as I can tell, the decimal specification in the "type" argument to 
Field() is used only for migrations -- that is, when the DAL is creating 
the column in the database. If the backend is pre-existing with 3 decimal 
places and the DAL does not run any migrations, then the decimal 
specification will have no effect. It is not used for transforming input or 
output.
 

> How do we validated the number of places??
>

You could create a custom validator. If the inputs are strings, you'll have 
to count the number of digits after the decimal point. If the inputs are 
Decimal objects, value.as_tuple().exponent will give you the significant 
digits (as a negative number).

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] web2py, nginx and big files

2018-04-20 Thread Richard Vézina
You seems to have found good information...

I don't have much time to investigate that subject and realize it could be
quite complexe...

And involve security issue :
https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/


Although, I thought that you might have a read that code base of apps like
these listing :

https://opensource.com/life/15/12/5-open-source-web-apps-self-hosted

This kind of apps surely had to workaround large file issue that you have...

Richard

On Fri, Apr 20, 2018 at 10:39 AM, Carlos Cesar Caballero Díaz <
carlos.caball...@cfg.jovenclub.cu> wrote:

>
> El 19/04/18 a las 16:21, Richard Vézina escribió:
>
> Ah ok, make sens then. Are you storing the file in database or on file
> system at web2py level??
>
>
>
> In the file system, I think that storing big (or so many) files in the
> database can overload it.
>
>
> There is surely a way to make the copy only once at the right place, but I
> am pretty sure it mean writting some customization at uwsgi level and most
> probably some conf in nginx to bypass it usual mechanism.
>
>
> I have being reading and found this https://stackoverflow.com/a/
> 44751210/1818267 its interesting, besides it carries some new issues to
> solve.
>
>
> I try to make some research and get back to you if I can fin anything that
> could help.
>
> Good luck
>
>
> Thanks, I'll be very grateful (more grateful :D).
>
> Greetings
>
>
> Richard
>
> On Wed, Apr 18, 2018 at 10:37 PM, Carlos Cesar Caballero Díaz <
> carlos.caball...@cfg.jovenclub.cu> wrote:
>
>>
>> El 18/04/18 a las 13:54, Richard Vézina escribió:
>>
>> That big... Hope it could work for you...
>>
>>
>> Well, right now is working with your suggestion, but not perfect, is
>> really slow because nginx uploads the file to a tmp file, next seems to
>> copy the file to another place (I assume to uwsgi) and next is copied to
>> web2py uploads, really annoying. I think that there should be a better way
>> to do that.
>>
>>
>> Are you trying to make El packet transiting the island faster or what...
>>
>> :D
>>
>>
>> Not exactly, but I like how you think :D
>>
>> I am working with Joven Club, a "company" that provides technical and
>> learning services throughout the country, and I am building a tool for
>> helping with the software installation service, it's really simple,
>> basically a software installers repository where people can search and
>> download (and certain people upload the files, of course).
>>
>>
>>
>> Richard
>>
>> On Wed, Apr 18, 2018 at 1:45 PM, Carlos Cesar Caballero Díaz <
>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>
>>> Thanks Richard, It seems to be working now. The files can be several
>>> Gigabytes.
>>>
>>>
>>> Greetings.
>>>
>>> El 17/04/18 a las 13:10, Richard Vézina escribió:
>>>
>>> How big?
>>>
>>> https://www.bookstackapp.com/docs/admin/upload-limits/
>>>
>>> https://www.nginx.com/resources/wiki/modules/upload/#upload-
>>> max-file-size
>>>
>>> Quote from the above link:
>>> For “hard” limit client_max_body_size directive must be used. The value
>>> of zero for this directive specifies that no restrictions on file size
>>> should be applied.
>>>
>>>
>>> Have a look at your nginx config upload_max_file_size and
>>> client_max_body_size
>>>
>>> I can't find the default nginx limit, but I think upload are around 5
>>> mg, I recall having issue long time ago about upload limit and the
>>> attachement was a little over 5 meg, so...
>>>
>>> In the link you provide there not seems to have limit overriding
>>> default, so my guess is that your file is bigger than the
>>> client_max_body_size
>>>
>>> Good luck
>>>
>>> Richard
>>>
>>> On Tue, Apr 17, 2018 at 12:10 PM, Carlos Cesar Caballero Díaz <
>>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>>
 Hi, I have a web2py + nginx setup (https://github.com/arisobel/w
 eb2py_scripts/blob/master/setup-web2py-nginx-p3-uwsgi-ubuntu.sh) and I
 need to upload big files to my application, the app is working ok with the
 built in server, but with nginx the form submission fails with no response
 when there are big files.

 Any tip for solving this?


 Greetings.

 --
 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.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> 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

Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 2:36:58 PM UTC-4, Richard wrote:
>
> It appears that it get silently "cropped/rounded" by the backend field 
> type configuration... If I have field with 2 places in the backend and 3 
> places defined in the models and input 0.647, it will be stored as 0.65.
>
> Do we have control over the rounding in web2py or it configure in the 
> database engine??
>

web2py has no control over what the database does (other than its ability 
to initially define the precision of the database column if web2py is used 
for a migration to create the database table). So, first make sure your 
database column is defined with the decimal precision you want.

On the web2py side, you can control the precision of the inputs however you 
want -- web2py will simply pass those inputs to the database.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Richard Vézina
There seems to have some thing related to gae :
https://github.com/web2py/pydal/blob/a7b7e4c11604d0b8b2de46e832469b78bfd7a1cf/pydal/helpers/gae.py#L16

I guess custom validator with quantize decimal parameters would do it.

I recall having use that for report porpuses, but was on the impression
that web2py was validating places... But it clearly not doing it anymore

Richard

On Fri, Apr 20, 2018 at 2:55 PM, Anthony  wrote:

> On Friday, April 20, 2018 at 2:30:22 PM UTC-4, Richard wrote:
>>
>> Realize that, though I am sure it use to managed it...
>>
>
> Not going back to at least web2py 2.02, as far as I can tell.
>
>
>> Anyway, I find it curious that even if I have field of type decimal(10,
>> 2) for instance, if I insert 1.304, and submit the form it ends up with
>> 1.304 in the read form (backend has 3 places).
>>
>
> As far as I can tell, the decimal specification in the "type" argument to
> Field() is used only for migrations -- that is, when the DAL is creating
> the column in the database. If the backend is pre-existing with 3 decimal
> places and the DAL does not run any migrations, then the decimal
> specification will have no effect. It is not used for transforming input or
> output.
>
>
>> How do we validated the number of places??
>>
>
> You could create a custom validator. If the inputs are strings, you'll
> have to count the number of digits after the decimal point. If the inputs
> are Decimal objects, value.as_tuple().exponent will give you the
> significant digits (as a negative number).
>
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Richard Vézina
It maybe just me, but I kind of think that if my models says decimal(10, 2)
it means that I don't want to store more than 2 places... Since my models
should behave like the database table and column as they are just an
abstraction of the later...

I know web2py offer alot of granularity control and flexibility over all
this aspect, but I feel that there is a missing component to handle this
particular aspect (rounding and enforcing "length" of numeric fields).

Richard

On Fri, Apr 20, 2018 at 2:59 PM, Anthony  wrote:

> On Friday, April 20, 2018 at 2:36:58 PM UTC-4, Richard wrote:
>>
>> It appears that it get silently "cropped/rounded" by the backend field
>> type configuration... If I have field with 2 places in the backend and 3
>> places defined in the models and input 0.647, it will be stored as 0.65.
>>
>> Do we have control over the rounding in web2py or it configure in the
>> database engine??
>>
>
> web2py has no control over what the database does (other than its ability
> to initially define the precision of the database column if web2py is used
> for a migration to create the database table). So, first make sure your
> database column is defined with the decimal precision you want.
>
> On the web2py side, you can control the precision of the inputs however
> you want -- web2py will simply pass those inputs to the database.
>
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: self-reference parter autoupdate

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 2:32:45 PM UTC-4, JSalvat wrote:
>
> Hello,
>
> Why on update/insert a record with a non-empty partner, the partner does 
> not get updated as well with the backwards reference?
>
> db.define_table('person',
> Field('name', requires=IS_NOT_EMPTY()),
> Field('partner', 'reference person', 
> requires=IS_EMPTY_OR(IS_IN_DB(db,'person.id'
>
> db.person.insert(name='John')
> 1
> >>> for person in db().select(db.person.ALL):
> ... print person.id, ' - ', person.name, ' - ', person.partner
> ...
> 1  -  John  -  None
>
> db.person.insert(name='Maria', partner=1)
> 2
> >>> for person in db().select(db.person.ALL):
> ... print person.id, ' - ', person.name, ' - ', person.partner
> ...
> 1  -  John  -  None
> 2  -  Maria  -  1
>
> Should not be this the result, since is a reciprocal relation?
>

No, neither web2py nor the database know this is a symmetric relationship 
(what if the self reference field was something like "manager"?). You got 
exactly what you inserted.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 3:00:16 PM UTC-4, Richard wrote:
>
> There seems to have some thing related to gae : 
> https://github.com/web2py/pydal/blob/a7b7e4c11604d0b8b2de46e832469b78bfd7a1cf/pydal/helpers/gae.py#L16
>

That's just the means of storing and retrieving decimal data in the GAE 
datastore according to the field specification. It doesn't do any 
validating. GAE obviously works differently from an RDBMS, which has a 
schema.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] IS_DECIMAL_IN_RANGE

2018-04-20 Thread Anthony
On Friday, April 20, 2018 at 3:06:59 PM UTC-4, Richard wrote:
>
> It maybe just me, but I kind of think that if my models says decimal(10, 
> 2) it means that I don't want to store more than 2 places... Since my 
> models should behave like the database table and column as they are just an 
> abstraction of the later...
>

Well, if you let the DAL create the table in the database, then you do get 
values with the specified number of places. If not, there is nothing web2py 
can do to affect what is stored in the database. I suppose web2py could 
round the data once selected from the database. Maybe submit a Github issue.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Problem: Sum total price and total quantity of a product

2018-04-20 Thread Ayron Rangel

I am developing an Inventory Control and am having difficulty calculating 
the sum of the values ​​of a given product type and calculating the 
quantity of products with the same model

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Login not working on smartphone - no the same menu layout

2018-04-20 Thread Dave S


On Friday, April 20, 2018 at 11:15:52 AM UTC-7, Andrea Fae' wrote:
>
> Please help me...
>
>
I'm not going to be much help, but I can confirm that the "hamburger" 
doesn't appear to have any life, where as the "<" and ">" buttons in the 
regular part of the page do change the date displayed.  This is with Chrome 
on a Samsung G8.

Opening the page in Firefox on my desktop has a conventional menu that 
drops down the two login options.

I don't know too much about website developer tools on Android itself, but 
perhaps you can use a simulator environment to watch more closely what the 
JS is doing.

Some sites have an "m." variant of the address to signal "mobile 
environment" and you can use that address on a desktop browser to play with 
the mobile interface, but I don't think web2py has that built-in.  
PythonAnywhere might have that as a feature, but that wouldn't help because 
web2py would still see the desktop user agent.

Oooh, I just tried narrowing the desktop window, and the menu bar switched 
to hamburger, and the hamburger is silent.  Turning on FF inspector, I see 
two errors on the console:

Error: Bootstrap tooltips require Tether (http://tether.io/)
bootstrap.min.js:7:3482

Source map error: request failed with status 404
Resource URL: https:
//andfae.pythonanywhere.com/tcf/static/css/bootstrap.min.css
Source Map URL: bootstrap.min.css.map[Learn More]


The second error may be relevant.

Dave S
/dps




Il giorno mercoledì 18 aprile 2018 20:31:38 UTC+2, Andrea Fae' ha scritto:
>>
>> this is my application
>>
>> https://andfae.pythonanywhere.com/tcf/default/index
>>
>> I can't login with android. I don't know. I see in the upper right of the 
>> smartphone 3 lines but when I click nothing happens...How to fix it?
>> I didn't find anything about this problem it. 
>> Maybe is it regarding bootstrap 4 in web2py?
>> Thank you
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Pass a query from form to another function

2018-04-20 Thread Yoel Benitez Fonseca
Umm... sorry took long to answer, i have put on issue on PyDAL repo and a 
pull request with a posible fix:

https://github.com/web2py/pydal/pull/531

El martes, 10 de abril de 2018, 22:20:04 (UTC-4), Anthony escribió:
>
> On Tuesday, April 10, 2018 at 6:14:06 PM UTC-4, Yoel Benitez Fonseca wrote:
>>
>> Is this not working any more ?
>>
>> >>> q = (db.photo.id == 1)
>> >>> db(q.as_dict(flat=True)).select()
>>   File "", line unknown
>> SyntaxError: Operator not supported: eq
>>
>> That is in a web2py shell,i mean is the same thing passing around the 
>> query in the session as a dict, is not ?
>>
>
> Looks like it could be broken now. Feel free to file an issue with the 
> PyDAL repository.
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Problem: Sum total price and total quantity of a product

2018-04-20 Thread Alby Cartner
I have just worked through it myself.
My solution is below - I did a small test app to sort it.
I am sure there are more elegant ways to solve it but this worked for me.

*Model*
db.define_table('additup',
Field('number1','integer', default = 0),
Field('number2','integer',default = 0),
Field('number3','integer', default = 0),
Field('total','integer'))

*Controller*

def index():
form = SQLFORM(db.additup)
return locals()

*View*

{{extend 'layout.html'}}

{{=form}}


jQuery("input[name='number1'],input[name='number2'],input[name='number2']").change(function()
{
jQuery("input[name='total']").val(parseInt(jQuery("input[name='number1']").val())+parseInt(jQuery("input[name='number2']").val())+parseInt(jQuery("input[name='number3']").val()));
});


On Saturday, April 21, 2018 at 7:35:22 AM UTC+12, Ayron Rangel wrote:
>
>
> I am developing an Inventory Control and am having difficulty calculating 
> the sum of the values ​​of a given product type and calculating the 
> quantity of products with the same model
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Problem: Sum total price and total quantity of a product

2018-04-20 Thread pbreit
Something like this?

http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len

sum = db(db.product.type=='large').select(sum).first()[sum]

count = db(db.product.type=='large').count()


On Friday, April 20, 2018 at 12:35:22 PM UTC-7, Ayron Rangel wrote:
>
>
> I am developing an Inventory Control and am having difficulty calculating 
> the sum of the values ​​of a given product type and calculating the 
> quantity of products with the same model
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: 'Column table.id not found (SQLTABLE)'

2018-04-20 Thread Brian M
Thank you for mentioning this - just wasted an hour plus trying to figure 
out why my code had stopped working only to find that it was because I'd 
done pip install pydal for something else and foolishly not used a venv. 
Uninstalled pydal and everything was good again. So warning to others, 
avoid globally installing pydal

On Saturday, June 3, 2017 at 11:33:17 AM UTC-5, Najtsirk wrote:
>
> I checked this and I had pydal installed as a global module. 
> When I removed it web2py's DAL works ok.
>
>
>
> On Saturday, 3 June 2017 18:30:05 UTC+2, Najtsirk wrote:
>>
>> +1
>> Have this problem too!
>>
>> On Saturday, 3 June 2017 18:13:18 UTC+2, Maurice Waka wrote:
>>>
>>> Hi did anyone get to solve this error? I seem to be locked in it also
>>> Regards
>>>
>>> On Monday, March 20, 2017 at 4:39:13 PM UTC+3, Santiago Cartasegna wrote:

 Are you trying to use a table that you have defined in your database 
 and not in web2py? 
 If it is the case you must add an id field with autoincremental

 El domingo, 12 de marzo de 2017, 20:27:08 (UTC-3), LoveWeb2py escribió:
>
> Keep getting this error for all of my tables!! What is going on?
>
> What information would be helpful for me to post to get 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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py 2.16.1 is OUT

2018-04-20 Thread lyn2py
I just git cloned the latest web2py and started it up with *python3*
Version 2.16.1-stable+timestamp.2018.03.08.10.23.01
Database drivers available: sqlite3, imaplib, pymysql, pyodbc

I got this error in console
ERROR:root:New installation error: unable to create welcome.w2p file

When I quit the python server and restart with python2 or python3, the 
error does not come up anymore.




On Tuesday, November 14, 2017 at 1:59:52 PM UTC+8, Massimo Di Pierro wrote:
>
> web2py 2.16.1 is OUT
>
> Lots of bugs fixes contributed by the community. Thanks Leonel, Paolo, 
> Giovanni, and all those who contributed.
>
> the most visible changes are:
>
> - welcome now defaults to bootstrap 4
> - lots of cleanup in the welcome app and new examples in default.py
> - simplified layout.html
>
> Massimo 
>
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] _href to URL()

2018-04-20 Thread 黄祥
it seems, the db/menu.py and views/layout.html must be match each other 
when modified it (list length and list index). 
never thought that the scaffolding menu can be modified too.
*e.g.*
*models/menu.py*
response.menu += [
(T('Home'), False, URL('default', 'index')*, T('Title'), 'a',* []),
(T('Community'), False, URL('default', 'index')*, T('Title'), 's'*, [
(T('Twitter'), False, 'http://twitter.com/web2py'*, T('Title'), 'd'*
),
(T('Live Chat'), False, 
'http://webchat.freenode.net/?channels=web2py'*, T('Title'), 'f'*),
]),
]

*views/layout.html*

  {{for _item in response.menu or []:}}
  {{if *len(_item)<6 or not _item[5]*:}}
  
{{=_item[0]}}
  
  {{else:}}
  
{{=_item[0]}}

  {{for _subitem in *_item[5]:*}}
  {{=_subitem[0]}}
  {{pass}}

  
  {{pass}}
  {{pass}}  


best regards,
stifan

On Wednesday, March 7, 2018 at 9:46:53 PM UTC+7, Anthony wrote:
>
> On Wednesday, March 7, 2018 at 12:39:42 AM UTC-5, 黄祥 wrote:
>>
>> agree, so what is the best way to make a menu in web2py that can contain 
>> a href with it's attribute like accesskey and title?
>>
>
> Here's the code currently used in the layout to generate the menu from 
> response.menu: 
> https://github.com/web2py/web2py/blob/f6d2f8a2a14bd8931fb571c9795d55fed1f4fe0d/applications/welcome/views/layout.html#L45
>
> If you want to specify something other than just the href and the text of 
> the menu item, you'll need to edit that code accordingly.
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.