Re: [web2py] Re: "TypeError: sequence of byte string values expected, value of type str found" when accessing admin

2020-05-01 Thread João Matos

Hello,

Nope. What I did was use another port with HTTPS (not 443, eg. 8000) for 
the client's application.



Best regards,

João Matos

On 01/05/2020 19:15, Ian W. Scott wrote:

Did you ever solve this problem? I'm running into the same thing.

On Monday, April 8, 2019 at 12:56:49 PM UTC-4, João Matos wrote:

When using Apache 2.4 (HTTPS using port 443) with web2py the
application works fine, but the admin interface always returns and
error "Internal Server Error".

This only happens if using port 443 (if I change the HTTPS port to
eg. 8000, it all works).

I checked that I don't have any other program/process using port 443.


The Apache error.log shows this

|[Mon Apr 08 00:36:13.551971 2019] [wsgi:error] [pid 4448:tid
924] [client 192.168.1.119:61409 <http://192.168.1.119:61409>]
mod_wsgi (pid=4448): Exception occurred processing WSGI script
'C:/web2py/wsgihandler.py'. [Mon Apr 08 00:36:13.551971 2019]
[wsgi:error] [pid 4448:tid 924] [client 192.168.1.119:61409
<http://192.168.1.119:61409>] TypeError: sequence of byte
string values expected, value of type str found\r |

I searched for this and found this article

https://stackoverflow.com/questions/34838443/typeerror-sequence-of-byte-string-values-expected-value-of-type-str-found

<https://stackoverflow.com/questions/34838443/typeerror-sequence-of-byte-string-values-expected-value-of-type-str-found>

Apparently this has to do with Python3.
Maybe web2py is sending str instead of bytes to Apache when
accessing the admin interface?


My env

Windows 7 Pro x64 SP1+all upd
Firefox 66.0.2 x64
Python 3.7.1 x86
web2py 2.18.4
Apache 2.4 (httpd-2.4.39-win32-VC14)
mod_wsgi-4.5.24+ap24vc14-cp37-cp37m-win32.whl


--
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 a topic in the 
Google Groups "web2py-users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/OXyGJcA_TU4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com 
<mailto:web2py+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1bc6d551-020a-43b9-89fd-cfc936f5aa97%40googlegroups.com 
<https://groups.google.com/d/msgid/web2py/1bc6d551-020a-43b9-89fd-cfc936f5aa97%40googlegroups.com?utm_medium=email_source=footer>.


--
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/bd9dc462-d790-e18f-4003-2a039b0e7e38%40gmail.com.


[web2py] How can I save the row.id of each grid selection when the user changes grid page?

2019-07-05 Thread João Matos
Hello,

How can I save the row.id of each grid selection when the user changes grid 
page (using grid pagination)?

Thanks,

JM

-- 
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/17a4679c-6a0e-4c6f-a581-38671c6fd56b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How to disable grid pagination but keep the "selectable" option buttons visible?

2019-07-05 Thread João Matos
Hello,

How to disable grid pagination but keep the "selectable" option buttons 
visible?

Thanks,

JM

-- 
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/e18183ed-f85b-46d0-a9a4-7eeaa1f0b3e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: OperationalError: no such table: contacts

2019-05-31 Thread João Matos
If you don't need any data in the db, delete everything in databases and 
check that in models\db.py the DAL creation has migrate=True.
Then restart your app.
All tables should be recreated.


quarta-feira, 29 de Maio de 2019 às 20:13:07 UTC+1, karthikeyan p escreveu:
>
> i am running my web2py app in pythonanywhere.com ( cloud machine )
> i have configured git in my *welcome* folder . i have not initalised 
> .ignore file to avoid anything like database , errors , sessions ,uploads .
> so when i like to backup my app in pythonanywhere , i just used -> git add 
> . -> git commit -> git push to my cloud repo  (github).
> so finally i got all my data ( including db , uploads , sessions ,errors 
> etc ) in to my cloud repo .
>
> i use git pull in local machine to pull all contents took from 
> pythonanywhere.
>
> if i changed something in my local repo ( laptop) , i will send it to 
> cloud repo (github) .
>
> this is my technique .
>
>
> i have created a database called *contact *in my local machine . 
> i pushed it to github . 
> i pulled it to pythonanywhere.com
>
>
>
> finally i found this error , 
>  no such table: contacts
>
> but it is found in db.py (model)
>
>
> db.define_table('contacts',
> Field('usr_n','string'),
> Field('email_id',requires=IS_EMPTY_OR(IS_EMAIL()))
> )
>
>
> i did this technique :
> i deleted all *.database ( except sql.log and storage.sqlite)
> i used "fake_migrate_all=True" 
>
>
> any other best practise to work  for updating the things include db in 
> cloud machine ??
>
> i mostly worried about the db problems.
>
>
>
>
>

-- 
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/f5a7957a-ab68-436f-8602-8fcdec86a10c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: https and apache

2019-05-29 Thread João Matos
Do you have an error?

quarta-feira, 15 de Maio de 2019 às 06:29:02 UTC+1, Cris Fad escreveu:
>
> Dear all, 
>
> I have problems to access web2py on apache throught https. I run 
> setup-web2py-ubuntu.sh, in the folder web2py/scripts and while the http is 
> responding correctly the https is not. In this way I cannot start the admin 
> page. 
> The server is running Ubuntu 18.04.
>
> Thanks in advance
> Cristina
>

-- 
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/561e512b-a8d3-4a38-9e69-e752ea27796b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How can I generate hash for user password like web2py

2019-05-29 Thread João Matos
I use Python's hashlib module. It contains pbkdf2.

segunda-feira, 27 de Maio de 2019 às 12:13:54 UTC+1, Константин Комков 
escreveu:
>
> Can somebody told about free library for windows (.dll) which can generate 
> hash of password like web2py (pbkdf2 + sha512)?
>

-- 
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/8155e38e-8a25-479f-b8b8-73dc31a6d0a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Https Apache Problem

2019-05-22 Thread João Matos
I use Apache with HTTPs on Windows systems.
Do you have an error?


quarta-feira, 15 de Maio de 2019 às 06:28:55 UTC+1, Cris Fad escreveu:
>
> Hello, 
>
> I am trying to run w2p on apache. I do so by running the script 
> setup-web2py-ubuntu.sh in the folder web2py/scripts. It works fine for the 
> address http: but not for the https. Furthermore, due to this situation I 
> cannot access the admin page.
> I am using server with Ubuntu 18.04 installed.
>
> Please help me! 
> Thanks in advance
> Cristina
>

-- 
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/972a5541-63de-4afe-9fcf-55a3c1e0d14c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: production - db migration issue. Works in sqlite but not mysql

2019-05-22 Thread João Matos
Don't use MySQL but try setting the migrate=False in the DAL creation 
(usually in models/db.py).
And add migrate=True to all your own tables (eg. products).


quarta-feira, 15 de Maio de 2019 às 12:53:05 UTC+1, Ron Chatterjee escreveu:
>
>
> Hello all,
>
> In PA I am running this app with an existing mysql database and I am 
> having migration issue. 
>
> If I run the db.py with db.migrate, it says 
> 1050, "Table 'auth_user' already exists
>
> If I run the table with migrate=False, and fake_migrate = True I get 
> another error:
>
> mytable.products' doesn't exist"
>
>
> Products table below is not being generated in the mysql database. I did 
> show tables and its not being populated. 
>
>
>  db.py
> -
> db = DAL(configuration.get('db.uri'),
>  pool_size=configuration.get('db.pool_size'),
>  migrate_enabled=configuration.get('db.migrate'),
>  check_reserved=['all'])
>
>
>
>
> db.define_table("products",
> Field("product_title", "string", requires=IS_NOT_EMPTY() 
> ,label='Product Title'),
> Field('Product_discription', 
> 'text',requires=IS_NOT_EMPTY(),label='Product Discription'),
> Field("product_image", 'upload', label="Product Image"),
> Field("product_document", "upload", label='Product PDF 
> Document'),
> Field('product_video', requires=IS_EMPTY_OR(IS_URL())),
> auth.signature)
>
>

-- 
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/744f67b3-2dc7-45f1-97a4-8a96253081f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: More then one buttons on form

2019-05-22 Thread João Matos
See the doc
http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=Adding+buttons+to+FORMs#Adding-buttons-to-FORMs


quarta-feira, 22 de Maio de 2019 às 09:12:19 UTC+1, Константин Комков 
escreveu:
>
> Web2py automatically add event listeners and class="btn" for button. What 
> if my form contain more then one button or I don't want use that class? 
> Usually I have used input type="button" *without form* in that case, but 
> now text in my button may contain 2 rows and I can't use input becouse it 
> inline element. How can I delete all web2py event listeners for buttons?
> For class I do next:
> el = document.getElementById("bak");
> el.classList.remove("btn");
> In my case I want use form with two button which redirect user on one page 
> but that buttons have different values. Hm.. may I use two forms?
>

-- 
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/473ab3a7-ea5d-4e5b-abcd-1ab0538cd1fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQL ALL & ANY operators - ?

2019-05-22 Thread João Matos
That ALL (
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#_lastsql)
 

 
is web2py specific and has nothing to do with the ALL that Vlad is asking.

quarta-feira, 22 de Maio de 2019 às 14:15:05 UTC+1, Константин Комков 
escreveu:
>
> I don't know about ANY, but it was told about ALL 
> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#_lastsql
>

-- 
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/9a5addcc-be4b-452b-99db-eb1e7e125c8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-16 Thread João Matos
Have you considered base64 encoding/decoding?

quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>
> the reason I use url+= to pass parameters instead of using args in the URL 
> helper is because the parameters are coming from the html itself - they are 
> not known in the controller py. 
>
> now the problem is that it changes the description and I have no way to 
> recover its original value. for example, when description is "askjdf d  
>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
> it needs to do this conversion in order to pass  the parameter, but I need 
> to be able to recreate the original string, entered by the user. 
>
> Is there a better way of doing this? I.e. a better way of passing a 
> parameter in  a way that it could be "recreated" and stored in the database 
> exactly as typed by the user? 
>

-- 
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/71b98711-3c60-46c3-b421-5609a450bd7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Future of web2py

2019-05-13 Thread João Matos
You are correct. I though you meant keeping the app open and trying to use 
the database or loading another page.
In the case you close the app then you would need some kind of embedded 
server (as I already mentioned) or serviceWorker (which I think is 
something lighter but similar).

For the case where you don't close the app and only lose Internet 
connection and/or db connection you can check using JS. It was in this 
scenario that I meant any web app could do that.

segunda-feira, 13 de Maio de 2019 às 11:19:36 UTC+1, Val K escreveu:
>
> 'That could be done by every web app (web2py or otherwise).'
>
> it is not quite so,  if you close regular web  page  (without embedded 
> serviceWorker) and  try to open it again when offline you will get nothing, 
> I suppose.
>

-- 
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/3b0361d2-bf53-4904-b8c7-f38ddab57a6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Future of web2py

2019-05-13 Thread João Matos

That is only checking if the Internet connection/db connection exists.
That could be done by every web app (web2py or otherwise).
That is not the definition of a PWA.
>From wikipedia
"
Progressive web applications (PWAs) are web applications that load like regular 
web pages or websites but can offer the user functionality such as working 
offline, push notifications, and device hardware access traditionally available 
only to native applications. PWAs combine the flexibility of the web with the 
experience of a native application.
"

Showing an error message is not the same as working offline (which requires an 
embedded server as I mentioned in the previous message) and the same goes to 
the hardware access.

-- 
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/9621e3be-02ef-43a4-8302-681ea50ce6e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Future of web2py

2019-05-12 Thread João Matos
I dont' think web2py can support PWA because PWA is a web app that can run 
online and offline in a mobile device.
Someone would have to build an embedded server to include in the mobile app 
(PWA) and that raises several questions due to the nature of the majority 
of web2py apps which depend on a database of some sort.
It isn't impossible but I don't see it happening in the near future.


sábado, 11 de Maio de 2019 às 08:40:35 UTC+1, mweissen escreveu:

> I think, progessive web applications are a very important way to create 
> native-like apps and it would be nice, if web3py could support pwas. There 
> is an interesting article about the future of pwas:
>
> https://enonic.com/progressive-web-apps 
>  
> Regards, Martin
>
> Am Sa., 11. Mai 2019 um 05:45 Uhr schrieb 黄祥  >:
>
>> What is pwa?
>>
>>
>> ref:
>> https://en.wikipedia.org/wiki/Progressive_web_applications
>> https://developers.google.com/web/progressive-web-apps/
>> https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps
>>
>> best regards,
>> stifan 
>>
>> -- 
>> 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 web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/d4d39e2f-0ab5-400b-b46a-ceaa9ef3da18%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/26d79828-d48b-488b-82d0-2880e19a06ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Why my form is not working

2019-05-12 Thread João Matos
Why not create a simple condition using

# The form should have the same name in both conditions.
if request.now.time().hour < 12:
# Show morning form including the edit and submit buttons.
else:
# Show afternoon form including the edit and submit buttons.

# If you want to validate anything use the following line.
if form.process(onvalidation=on_validation).accepted:
# Or use the next line if you don't.
# if form.process().accepted:
   # Do whatever you want when success
elif form.errors:
  # Do whatever you want when there are form errors.

domingo, 12 de Maio de 2019 às 08:17:20 UTC+1, Maurice Waka escreveu:
>
> I i'm trying to use one chart to alternate between two forms. A user logs 
> in data in the morning hrs, meaning the form should be active and the 
> evening form inactive. When the time comes after 12 pm the morning form 
> is inactive and the evening form is active.
> While trying out this morning, both are inactive all through.
> Here is the code:
>
> def mg_sugar_chart():
> response.files.append(URL('e_dextrose',
> 'static/js/pygal-tooltips.min.js'))
> response.headers['Content-Type']='image/svg+xml'
>
>
> custom_style = Style(
> background='transparent',
> plot_background='transparent',
> foreground='#53E89B',
> foreground_strong='#53A0E8',
> foreground_subtle='#630C0D',
> opacity='.6',
> opacity_hover='.9',
> transition='400ms ease-in',
> colors=('#E853A0', '#E8537A', '#E95355', '#E87653', '#E89B53')
> )
> chart = pygal.Line(fill=True, interpolate='cubic', style=BlueStyle, 
> x_label_rotation=45, print_values=True, show_y_guides=False, 
> print_values_position='top')
> data = db(db.amg_sugar).select()
> data1 = db(db.pmg_sugar).select()
> 
> chart.x_labels = al_date
> chart.x_labels = pl_date
> chart.add('AM', [i.am_dext for i in data])
> chart.add('PM', [i.pm_dext for i in data1])
>
> return chart.render()
>
>
> #***sugar***
> @auth.requires_login()
> def mgSugar():
> db.amg_sugar.modified_on.readable = db.amg_sugar.modified_on.writable 
> =False
> db.pmg_sugar.modified_on.readable = db.pmg_sugar.modified_on.writable 
> =False
> chart= URL('e_dextrose', 'mg_sugar_chart')
> row = db(db.amg_sugar.author == auth.user_id).select().first()
>
>
> #***open and close for sugar logs***
> early_str = '05::00::00'
> late_str = '22::00::00'
> am_str = '11::59::00'
> pm_str = '12::00::00'
> am_line = dt.strptime(am_str, '%H::%M::%S').time()#deadline to post 
> sugar
> pm_line = dt.strptime(pm_str, '%H::%M::%S').time()#deadline to post 
> sugar
> early_line = dt.strptime(early_str, '%H::%M::%S').time()#deadline to 
> post sugar
> late_line = dt.strptime(late_str, '%H::%M::%S').time()#deadline to 
> post sugar
>
>
> #***check if row is empty***
> am_row = [r.am_dext for r in db(db.amg_sugar.author == auth.user.id).
> select(db.amg_sugar.ALL)[-1:]]
> pm_row = [r.pm_dext for r in db(db.pmg_sugar.author == auth.user.id).
> select(db.pmg_sugar.ALL)[-1:]]
> #***AM logs***
> if request.now.date():# == amd.date():
> form = SQLFORM(db.amg_sugar)
> form.add_button('Edit', URL('edit_amgSugar'))
> am_row1 = [r.am_dext for r in db(db.amg_sugar.author == auth.user.
> id).select(db.amg_sugar.ALL)[-1:]]
> if request.now.time() >= early_line and am_row1[0] == None:   
>  
> form = SQLFORM(db.amg_sugar, submit_button=T('Submit')).
> process()
> form.add_button('Edit', URL('edit_amgSugar'))
> else:
> session.flash = ''.join(str(item) for item in ["Your next sugar 
> log is in the next morning. "])
> form = session.flash
>
>
> if request.now.date():# == amd.date():
> form1 = SQLFORM(db.pmg_sugar)
> form1.add_button('Edit', URL('edit_pmgSugar'))
> pm_row1 = [r.pm_dext for r in db(db.pmg_sugar.author == auth.user.
> id).select(db.pmg_sugar.ALL)[-1:]]
> if request.now.time() >= pm_line and pm_row1[0] ==None:
> form1 = SQLFORM(db.pmg_sugar, submit_button=T('Submit')).
> process()
> form1.add_button('Edit', URL('edit_pmgSugar'))
> else:
> session.flash = ''.join(str(item) for item in ["Your next sugar 
> log is in the next afternoon. "])
> form1 = session.flash
>
> return dict(chart = chart,form=form, form1=form1)
>
>
> Could someone give me a better idea/solution.
> Much appreciated
>

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

[web2py] Re: Compiled pack always includes databases and private dirs. Is there any way to pack w/o those?

2019-05-12 Thread João Matos
I was just pressing the checkbox and nothing happened.
I pressed the app name and now the tree struc appears.

Thanks.


domingo, 12 de Maio de 2019 às 13:01:42 UTC+1, Anthony escreveu:
>
> Click on the folder to expand.

-- 
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/56e059b6-f910-445d-af94-794f45747e35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Compiled pack always includes databases and private dirs. Is there any way to pack w/o those?

2019-05-11 Thread João Matos


[image: PackCustom.png]
Tried that, but there is only the option to select either w2p or exe. No 
folder selection (onyl the app name in the checkbox).
I enclose an image of the options available in Pack custom.
I tried source and compiled. Both show the same options.
I tried Firefox and Chrome.

My env
web2py 2.18.5
Python 3.7.1 x86
Firefox 66.0.5 x64
Windows 7 Pro x64 SP1+all upd

-- 
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/dc1cf78c-fb2f-4cd7-b0a4-94ce0aeec251%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to change the time zone in web2py under PythonAnywhere?

2019-05-10 Thread João Matos
Thanks Massimo. In this case that is exactly what I want.


sexta-feira, 10 de Maio de 2019 às 02:59:24 UTC+1, Massimo Di Pierro 
escreveu:
>
>
> Mind os.eviron is not thread safe. You are changing not your one app, but 
> for all your installed web2py apps.
>
> On Tuesday, 7 May 2019 11:06:21 UTC-7, jcrm...@gmail.com  
> wrote:
>>
>> I was able to solve it by adding
>> time.tzset()
>> after the 
>> os.environ["TZ"] = "Europe/Lisbon"
>> in the wsgi configuration file (it's accessible in the Web tab).
>>
>> terça-feira, 7 de Maio de 2019 às 14:21:07 UTC+1, jcrm...@gmail.com 
>> escreveu:
>>>
>>> Hello,
>>>
>>> I was able to change the time zone of the consoles to UTC+1 in 
>>> PythonAnywhere, but the web2py apps are still in UTC.
>>>
>>> Does anyone know how I can change make the web2py apps comply?
>>>
>>> I was told to add this
>>> os.environ["TZ"] = "Europe/Lisbon"
>>> to the start of wsgi adapter (located at /var/www), but that didn't work.
>>>
>>> Thanks,
>>>
>>> JM
>>>
>>>

-- 
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/60cc1e52-3217-4de9-8dd9-6b8021dcf8ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Compiled pack always includes databases and private dirs. Is there any way to pack w/o those?

2019-05-09 Thread João Matos
Hello,

Compiled pack always includes databases and private dirs.
Is there any way to create a compiled pack without including those dirs?

Thanks,

JM

-- 
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/fa5a5433-ab07-4b7e-9502-05fda91183d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: custom search

2019-04-25 Thread João Matos
You don't have the standard buttons, but have a search button created by 
you?


quinta-feira, 25 de Abril de 2019 às 15:21:41 UTC+1, Andrea Fae' escreveu:
>
> I create a custom search, so not standard field with "Search" and "reset" 
> button standard. How to click the button "Search" programmatically?
> 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: datepicker preserve selecred date after postback

2019-04-25 Thread João Matos
Is the selected date in a db field? Then when editing the same field, the 
date picker should show the selected date.

If the date is still not saved to a db field but only in js, then you can 
send it using something similar to this







quinta-feira, 25 de Abril de 2019 às 20:40:25 UTC+1, Andrea Fae' escreveu:
>
> How to preserve datepicker selected date after postback using web2py in a 
> javascript view... I think it's a javascript problem but I don't know how 
> to fix it.
> 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: 2.18.5 admin UnicodeDecodeError

2019-04-25 Thread João Matos
Did you change the Python version? Check your path.
Also, if clearing the sessions and errors doesn't work, try to delete all 
*.pyc in the web2py tree.

Another possible origin are the databases if using SQLite.


quinta-feira, 25 de Abril de 2019 às 10:00:49 UTC+1, Jacinto Parga escreveu:
>
> Hi, It suddenly appeared. Version downloaded from source web. The same 
> with github version.
>
> Error ticket for "admin" Ticket ID 
>
> 127.0.0.1.2019-04-25.10-45-30.ec4c021c-532a-46c7-a8cd-6f9356fc7ab7
>  'ascii' codec can't decode byte 0x8b in 
> position 1: ordinal not in range(128) Versión 
> web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 
> Python Python 3.7.3: /usr/bin/python3.7 (prefix: /usr) Rastreo 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
>
> Traceback (most recent call last):
>   File "/home/jacinto/web2py2185/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
> , line 2021, 
> in 
>   File "/home/jacinto/web2py2185/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
> , line 1627, 
> in errors
> error = pickle.load(fullpath_file)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: 
> ordinal not in range(128)
>
> Error snapshot [image: help] 
> 
>  
>
> UnicodeDecodeError('ascii' codec can't decode byte 0x8b in position 1: 
> ordinal not in range(128)) 
>
> inspeccionar atributos 
> Frames 
>
>- 
>
>*File /home/jacinto/web2py2185/gluon/restricted.py in restricted at 
>line 219* código argumentos variables 
>Code listing 
>
>214.
>215.
>216.
>217.
>218.
>219.
>220.
>221.
>222.
>223.
>
>if environment is None:
>environment = {}
>environment['__file__'] = layer
>environment['__name__'] = '__restricted__'
>try:
>exec(ccode, environment)
>except HTTP:
>raise
>except RestrictedError:
># do not encapsulate (obfuscate) the original RestrictedError
>
>- 
>
>*File 
>/home/jacinto/web2py2185/applications/admin/controllers/default.py in 
> at line 2021* código argumentos variables 
>Code listing 
>
>2010.
>2011.
>2012.
>2013.
>2014.
>2015.
>2016.
>2017.
>2018.
>2019.
>
>else:
>filename = "web2py.plugin.%s.w2p" % cleanpath(plugin)
>if plugin_install(app, urlopen(source),
>  request, filename):
>session.flash = T('New plugin installed: %s', filename)
>else:
>session.flash = \
>T('unable to install plugin "%s"', filename)
>redirect(URL(f="plugins", args=[app, ]))
>return dict(form=form, app=app, plugin=plugin, source=source)
>
>- 
>
>*File /home/jacinto/web2py2185/gluon/globals.py in  at line 
>421* código argumentos variables 
>Code listing 
>
>416.
>417.
>418.
>419.
>420.
>421.
>422.
>423.
>424.
>425.
>
>self.flash = ''# used by the default view layout
>self.meta = Storage()  # used by web2py_ajax.html
>self.menu = [] # used by the default view layout
>self.files = []# used by web2py_ajax.html
>self._vars = None
>self._caller = lambda f: f()
>self._view_environment = None
>self._custom_commit = None
>self._custom_rollback = None
>self.generic_patterns = ['*']
>
>- 
>
>*File 
>/home/jacinto/web2py2185/applications/admin/controllers/default.py in 
>errors at line 1627* código argumentos variables 
>Function argument list 
>
>()
>Code listing 
>
>1622.
>1623.
>1624.
>1625.
>1626.
>1627.
>1628.
>1629.
>1630.
>1631.
>
>if not os.path.isfile(fullpath):
>continue
>try:
>fullpath_file = safe_open(fullpath, 'rb')
>try:
>error = pickle.load(fullpath_file)
>finally:
>fullpath_file.close()
>except IOError:
>continue
>
>Variables
>
>

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

[web2py] Re: How to build onvalidation routine for unique within location

2019-04-25 Thread João Matos
You shouldn't create a field called id. Check the recommendations on the 
docs. web2py creates an id (auto-increment) field automatically.

Anyway, form.vars.* are only available on onvalidation if the field is 
editable.

Check your grid config. Maybe adding field_id=db.brix_test.id would help.
Check request.vars.id.


quinta-feira, 25 de Abril de 2019 às 00:50:22 UTC+1, Jim S escreveu:
>
> Give the following table:
>
> db.define_table('brix_test',
> Field('id', 'id', readable=False),
> Field('site', 'reference site',
>   requires=IS_IN_DB(self.db, 'site',
> '%(siteNumber)s - %(name)s',
> zero='..')),
> Field('mixer_tech', 'reference mixerTech',
>   requires=IS_IN_DB(self.db, 'mixerTech', '%(name)s', zero='..')),
> Field('sampled', 'datetime', requires=IS_DATE('%m/%d/%Y %I:%M %p')),
> Field('sample_id', length=20, requires=IS_NOT_EMPTY()),
> Field('source', length=50, requires=IS_NOT_EMPTY()),
> Field('water_weight', 'integer', requires=IS_INT_IN_RANGE(100, 300)))
>
>
> I want to create an onvalidation function to be run when saving from by 
> SQLFORM.grid that will ensure that the 'source' field is unique within each 
> site.  
>
> Ex:
>
> A record for Site 1 can have a sample_id of 'Tank 1'
> A record for Site 2 can have a sample_id of 'Tank 1'
>
> But you cannot have more than 1 record for Site 1 where sample_id is 'Tank 
> 1'
>
> My problem is that I can't get my 'id' field to be recognized in my 
> onvalidation function:
>
> def validate_brix_test(form):
> brix_test_id = form.vars.id
> site_id = form.vars.site
> mixer_tech_id = form.vars.mixer_tech
> sample_id = form.vars.sample_id
>
>
> site = db.site(site_id)
>
>
> #  mixer tech must belong to the site specified
> mt = db.mixerTech(mixer_tech_id)
> if not mt:
> form.errors.mixer_tech = 'Mixer Tech was not found'
> else:
> if mt.siteId != site_id:
> form.errors.mixer_tech = 'Mixer Tech does not belong to %s.' % 
> site.name
>
>
> #  sample id must be unique within the site
> if brix_test_id and brix_test_id > 0:
> sample_id_count = db((db.brix_test.id != brix_test_id) &
>  (db.brix_test.sample_id == sample_id) &
>  (db.brix_test.site == site_id)).count()
> else:
> sample_id_count = db((db.brix_test.sample_id == sample_id) &
>  (db.brix_test.site == site_id)).count()
>
>
> if sample_id_count > 0:
> form.errors.sample_id = 'This sample ID has already been used at 
> %s.' % site.name
>
>
> return
>
> The problem is that form.vars.id is always None regardless of whether or 
> not I have db.brix_test.id.readable = db.brix_test.id.writable = True or 
> False
>
> Any idea how I can get the ID of the record in the form into the 
> onvalidation function?
>
> -Jim
>
>
>

-- 
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] Re: SSL on Windows / Python 3.6.5 not working

2019-04-23 Thread João Matos
Yes, I think so.
Try disabling the Windows Firewall.

In my case, when I disable my antivirus (which includes a firewall) the 
error goes away.

-- 
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: SSL on Windows / Python 3.6.5 not working

2019-04-23 Thread João Matos
Try disabling the antivirus.


segunda-feira, 22 de Abril de 2019 às 11:33:40 UTC+1, clara escreveu:
>
> Hello,
>
> I am trying to run Web2py 2.18.5 on Windows 10. I am using Python 3.6.5
>
> python web2py.py -a passw -k server.key -c server.crt -p 443 -i 0.0.0.0
>
> Upon loading a web2py page, I get socket errors continuously, and pages do 
> not load. This is the trace:
>
> -p 443 -c server.crt -k server.key -a passwException in thread Thread-2:
> Traceback (most recent call last):
>   File "c:\Python36\Lib\threading.py", line 916, in _bootstrap_inner
> self.run()
>   File "C:\Users\Clara\projects\connectcap2\web2py\gluon\rocket.py", line 
> 1268, in run
> conn = Connection(*conn)
>   File "C:\Users\Clara\projects\connectcap2\web2py\gluon\rocket.py", line 
> 105, in __init__
> self.socket.settimeout(SOCKET_TIMEOUT)
> OSError: [WinError 10038] An operation was attempted on something that is 
> not a socket
>
> Exception in thread Thread-4:
> Traceback (most recent call last):
>   File "c:\Python36\Lib\threading.py", line 916, in _bootstrap_inner
> self.run()
>   File "C:\Users\Clara\projects\connectcap2\web2py\gluon\rocket.py", line 
> 1268, in run
> conn = Connection(*conn)
>   File "C:\Users\Clara\projects\connectcap2\web2py\gluon\rocket.py", line 
> 105, in __init__
> self.socket.settimeout(SOCKET_TIMEOUT)
> OSError: [WinError 10038] An operation was attempted on something that is 
> not a socket
>
> I tried running Python 2.7 and pages load, so the issue is aparently 
> strictly related to python 3.6...
>
> Has anyone been able to run SSL on windows with Python 3.6? Any help will 
> be appreciated.
>
> Regards,
>
> Clara
>
>
>

-- 
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: Unable to edit grid record if I add @auth.requires_signature() to action. Is this normal?

2019-04-23 Thread João Matos
Thanks for the workaround Anthony.

I believe it should be the other way around. Grid should have the option 
hash_vars=True.

I'm using these security measures:
HTTPS and requires_login

-- 
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: Unable to edit grid record if I add @auth.requires_signature() to action. Is this normal?

2019-04-22 Thread João Matos
It is called from the menu (models\menu.py). This is the code:

...
if auth.is_logged_in():
response.menu = [
(T('Home'), False, URL('default', 'index', user_signature=True)),
(T('Open work orders'), False, URL('open_wo', 'index', 
user_signature=True)),
(T('Tables'),
 False,
 None,
 [
(db.opt_cat._plural, False, URL('opt_cat', 'index', vars={'sid': 
request.vars.sid}, user_signature=True)),
...

Didn't test the sorting or search then, but I tested now and they also 
don't work, returning the same Not Authorized message.


segunda-feira, 22 de Abril de 2019 às 12:59:34 UTC+1, Anthony escreveu:
>
> When using signed URLs, how do users get to that function (given that the 
> URL requires a signature)? How do you construct the URL?
>
> When using @auth.requires_signature(), does sorting and searching the grid 
> work? Only edit fails?
>
> Anthony
>
> On Sunday, April 21, 2019 at 12:30:29 PM UTC-4, João Matos wrote:
>>
>> Here is the correct version (my previous post, which I deleted, was 
>> another version):
>>
>> #@auth.requires_signature()
>> @auth.requires_login()
>> def index():
>> # type: () -> Dict[str, gluon.DIV]
>> """Index page.
>>
>> :return: Dict with grid.
>> """
>> if session.return_to:
>> del session.return_to
>>
>> session.table = 'opt_cat'
>>
>> # Hidden fields in grid and edit/view form.
>> db.opt_cat.id.readable = False
>>
>> db.opt_cat.one_opt_only.show_if = db.opt_cat.mandatory == False
>>
>> if SUPERVISOR_ROLE_ID in auth.user_groups:
>> # Uses covering index opt_cat_is_active_name_en.
>> # Uses auto index sqlite_autoindex_opt_cat_1.
>> grid = SQLFORM.grid(
>> db.opt_cat,
>> csv=False,
>> details=False,
>> # Disable delete checkbox in edit form.
>> editargs=dict(deletable=False),
>> maxtextlength=GRID_COL_LEN_FOR_TEXT,
>> ondelete=on_delete,  # Grid only.
>> onvalidation=on_validation,  # And onupdate are form only.
>> orderby=db.opt_cat.name,
>> paginate=session.auth.user.pagination,
>> # represent_none='',  # Grid and view form only.
>> )  # type: gluon.DIV
>> else:
>> # Hidden fields in grid and edit/view form.
>> db.opt_cat.canceled_on.readable = False
>> db.opt_cat.canceled_by.readable = False
>> db.opt_cat.cancel_approved_by.readable = False
>>
>> # Uses covering index opt_cat_is_active_name_en (is_active=?).
>> # Uses index opt_cat_is_active_name (is_active=?).
>> grid = SQLFORM.grid(
>> db.opt_cat.is_active == True,
>> create=False,
>> csv=False,
>> deletable=False,
>> details=False,
>> editable=False,
>> maxtextlength=GRID_COL_LEN_FOR_TEXT,
>> orderby=db.opt_cat.name,
>> paginate=session.auth.user.pagination,
>> # represent_none='',  # Grid and view form only.
>> )
>>
>> # Remove icons from default buttons.
>> grid.elements('span.icon', replace=None)
>>
>> if request.args:
>> # Remove delete button.
>> grid.element('#delete_with_approval', replace=None)
>>
>> if not request.args:
>> # Sort grid's search fields list.
>> grid.element('#w2p_query_fields').components = 
>> sort_grid_search_fields_list(grid)
>>
>> if session.opt_cat_modified_on:
>> del session.opt_cat_modified_on
>> elif 'edit' in request.args:
>> # Edit uses opt_cat Pk.
>>
>> form = grid.update_form  # type: gluon.sqlhtml.SQLFORM
>> # form['hidden'].update(mon=form.record.modified_on)
>> # Solves the record changed while editing, but doesn't solve it
>> # if the user 1st tries something that returns form.errors (eg.
>> # changing a unique field to something that already exists) and
>> # only after that he tries to save the record (which was changed
>> # by another user). For this the only solution I've found was
>> # using a session var.
>>
>> if not session.opt_cat_modified_on:
>> session.opt_cat_modified_on = form.record.modified_on
>>
>> if not form.record.is_active and not SUPERVISOR_ROLE_ID in aut

[web2py] Re: Unable to edit grid record if I add @auth.requires_signature() to action. Is this normal?

2019-04-21 Thread João Matos
Here is the correct version (my previous post, which I deleted, was another 
version):

#@auth.requires_signature()
@auth.requires_login()
def index():
# type: () -> Dict[str, gluon.DIV]
"""Index page.

:return: Dict with grid.
"""
if session.return_to:
del session.return_to

session.table = 'opt_cat'

# Hidden fields in grid and edit/view form.
db.opt_cat.id.readable = False

db.opt_cat.one_opt_only.show_if = db.opt_cat.mandatory == False

if SUPERVISOR_ROLE_ID in auth.user_groups:
# Uses covering index opt_cat_is_active_name_en.
# Uses auto index sqlite_autoindex_opt_cat_1.
grid = SQLFORM.grid(
db.opt_cat,
csv=False,
details=False,
# Disable delete checkbox in edit form.
editargs=dict(deletable=False),
maxtextlength=GRID_COL_LEN_FOR_TEXT,
ondelete=on_delete,  # Grid only.
onvalidation=on_validation,  # And onupdate are form only.
orderby=db.opt_cat.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
)  # type: gluon.DIV
else:
# Hidden fields in grid and edit/view form.
db.opt_cat.canceled_on.readable = False
db.opt_cat.canceled_by.readable = False
db.opt_cat.cancel_approved_by.readable = False

# Uses covering index opt_cat_is_active_name_en (is_active=?).
# Uses index opt_cat_is_active_name (is_active=?).
grid = SQLFORM.grid(
db.opt_cat.is_active == True,
create=False,
csv=False,
deletable=False,
details=False,
editable=False,
maxtextlength=GRID_COL_LEN_FOR_TEXT,
orderby=db.opt_cat.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
)

# Remove icons from default buttons.
grid.elements('span.icon', replace=None)

if request.args:
# Remove delete button.
grid.element('#delete_with_approval', replace=None)

if not request.args:
# Sort grid's search fields list.
grid.element('#w2p_query_fields').components = 
sort_grid_search_fields_list(grid)

if session.opt_cat_modified_on:
del session.opt_cat_modified_on
elif 'edit' in request.args:
# Edit uses opt_cat Pk.

form = grid.update_form  # type: gluon.sqlhtml.SQLFORM
# form['hidden'].update(mon=form.record.modified_on)
# Solves the record changed while editing, but doesn't solve it
# if the user 1st tries something that returns form.errors (eg.
# changing a unique field to something that already exists) and
# only after that he tries to save the record (which was changed
# by another user). For this the only solution I've found was
# using a session var.

if not session.opt_cat_modified_on:
session.opt_cat_modified_on = form.record.modified_on

if not form.record.is_active and not SUPERVISOR_ROLE_ID in auth.
user_groups:
session.flash = T('Record was deleted while you were viewing 
the grid.')
redirect(URL(user_signature=True))

return dict(grid=grid)




domingo, 21 de Abril de 2019 às 17:22:44 UTC+1, Anthony escreveu:
>
> On Sunday, April 21, 2019 at 10:53:08 AM UTC-4, João Matos wrote:
>>
>> I wanted to have signed URL everywhere.
>> For that, I added user_signature=True to all my URL(). The grid has that 
>> as a default.
>> At this point everything worked with @requires_login() except one special 
>> case (I believe this special case may be related to the same issue I'm 
>> facing with this I describe here).
>>
>> Then I added a var called sid (for session id) to every URL() which I use 
>> to identify the session (this way I'm able to distinguish ebetween 2 
>> browser tabs).
>> At this point everything worked with @requires_login() except the special 
>> case I mentioned above.
>>
>> Then I replaced @auth.requires_login() with @auth.requires_signature() 
>> and I'm able to access the grid but not the edit form. I receive a Not 
>> Authorized message.
>>
>> In all these tests I'm logged in.
>>
>> If I remove the sid var and keep the @auth.requires_signature() 
>> everything works.
>>
>> If I replace the@auth.requires_signature() with @auth.requires_login() 
>> and keep the sid var everything works.
>>
>> Only the combination of both doesn't work.
>>
>
> Need to see the code.
>

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

[web2py] Re: Unable to edit grid record if I add @auth.requires_signature() to action. Is this normal?

2019-04-21 Thread João Matos
 Here it is:

@auth.requires_login()
# @auth.requires_signature()
def index():
# type: () -> Dict[str, gluon.DIV]
"""Index page.

:return: Dict with grid.
"""
if not request.vars.sid:
redirect(URL('default', 'index'))

if session.sids[request.vars.sid].return_to:
del session.sids[request.vars.sid].return_to

session.sids[request.vars.sid].table = 'opt_cat'

# Hidden fields in grid and edit/view form.
db.opt_cat.id.readable = False

db.opt_cat.one_opt_only.show_if = db.opt_cat.mandatory == False

if SUPERVISOR_ROLE_ID in auth.user_groups:
# Uses covering index opt_cat_is_active_name_en.
# Uses auto index sqlite_autoindex_opt_cat_1.
grid = SQLFORM.grid(
db.opt_cat,
csv=False,
details=False,
# Disable delete checkbox in edit form.
editargs=dict(deletable=False),
maxtextlength=GRID_COL_LEN_FOR_TEXT,
ondelete=on_delete,  # Grid only.
onvalidation=on_validation,  # And onupdate are form only.
orderby=db.opt_cat.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
user_signature=False,
)  # type: gluon.DIV
else:
# Hidden fields in grid and edit/view form.
db.opt_cat.canceled_on.readable = False
db.opt_cat.canceled_by.readable = False
db.opt_cat.cancel_approved_by.readable = False

# Uses covering index opt_cat_is_active_name_en (is_active=?).
# Uses index opt_cat_is_active_name (is_active=?).
grid = SQLFORM.grid(
db.opt_cat.is_active == True,
create=False,
csv=False,
deletable=False,
details=False,
editable=False,
maxtextlength=GRID_COL_LEN_FOR_TEXT,
orderby=db.opt_cat.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
user_signature=False,
)

# Remove icons from default buttons.
grid.elements('span.icon', replace=None)

if request.args:
# Remove delete button.
grid.element('#delete_with_approval', replace=None)

if not request.args:
# Sort grid's search fields list.
grid.element('#w2p_query_fields').components = 
sort_grid_search_fields_list(grid)

if session.sids[request.vars.sid].modified_on:
del session.sids[request.vars.sid].modified_on
elif 'edit' in request.args:
# Edit uses opt_cat Pk.

form = grid.update_form  # type: gluon.sqlhtml.SQLFORM
# form['hidden'].update(mon=form.record.modified_on)
# Solves the record changed while editing, but doesn't solve it
# if the user 1st tries something that returns form.errors (eg.
# changing a unique field to something that already exists) and
# only after that he tries to save the record (which was changed
# by another user). For this the only solution I've found was
# using a session var.

if not session.sids[request.vars.sid].modified_on:
session.sids[request.vars.sid].modified_on = form.record.
modified_on

if not form.record.is_active and not SUPERVISOR_ROLE_ID in auth.
user_groups:
session.flash = T('Record was deleted while you were viewing 
the grid.')
redirect(URL(vars={'sid': request.vars.sid}))

return dict(grid=grid)


-- 
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: Where do I find the user/profiel and user/change_password forms?

2019-04-21 Thread João Matos
Thanks Anthony.

domingo, 21 de Abril de 2019 às 13:54:32 UTC+1, Anthony escreveu:
>
> On Sunday, April 21, 2019 at 7:32:50 AM UTC-4, João Matos wrote:
>>
>> I'd like to make changes to the user/profile and user/change_password 
>> forms, but I can't find them.
>>
>
> In the associated methods in tools.py:
>
> https://github.com/web2py/web2py/blob/master/gluon/tools.py#L3646 
>

-- 
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: Unable to edit grid record if I add @auth.requires_signature() to action. Is this normal?

2019-04-21 Thread João Matos

I wanted to have signed URL everywhere.
For that, I added user_signature=True to all my URL(). The grid has that as 
a default.
At this point everything worked with @requires_login() except one special 
case (I believe this special case may be related to the same issue I'm 
facing with this I describe here).

Then I added a var called sid (for session id) to every URL() which I use 
to identify the session (this way I'm able to distinguish ebetween 2 
browser tabs).
At this point everything worked with @requires_login() except the special 
case I mentioned above.

Then I replaced @auth.requires_login() with @auth.requires_signature() and 
I'm able to access the grid but not the edit form. I receive a Not 
Authorized message.

In all these tests I'm logged in.

If I remove the sid var and keep the @auth.requires_signature() everything 
works.

If I replace the@auth.requires_signature() with @auth.requires_login() and 
keep the sid var everything works.

Only the combination of both doesn't work.


domingo, 21 de Abril de 2019 às 14:07:42 UTC+1, Anthony escreveu:
>
> Can you show your code? I cannot reproduce this exact behavior.
>
> Note, because the default behavior of @auth.requires_signature() is to 
> include the query string when creating the signature, any functionality of 
> the grid that uses the query string should not work, as the grid does not 
> generate signatures for those links.
>
> In any case, the grid already has built-in support for signed URLs for any 
> write operations -- do you need more than that?
>
> Anthony
>
> On Saturday, April 20, 2019 at 4:03:17 PM UTC-4, João Matos wrote:
>>
>> If I replace @auth_requires_login() with @auth.requires_signature() to my 
>> index function (controller's main function) where a grid is created, the 
>> grid shows up without any issue, but if I try to edit a row, I get a Not 
>> Authorized message.
>>
>> Anyone has any idea why this is happening?
>>
>> If I replace @auth.requires_signature() with @auth.requires_login() 
>> everything works.
>>
>

-- 
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] Where do I find the user/profiel and user/change_password forms?

2019-04-21 Thread João Matos
I'd like to make changes to the user/profile and user/change_password 
forms, but I can't find them.

-- 
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: Unable to edit grid record if I add @auth.requires_signature() to action. Is this normal?

2019-04-21 Thread João Matos
You didn't understand. In both cases I'm logged in.
If I have @requires_login() it all works. If I replace it with 
@requires_signature() the grid opens OK, but I'm unable to edit a record.

The menu option I created to open the grid has the user_signature=True and 
the grid has the default of user_signature=True.


domingo, 21 de Abril de 2019 às 00:53:07 UTC+1, Massimo Di Pierro escreveu:
>
> It is intentional. The grid requires a valid user to make field editable. 
> You can override this with:
>
> grid(..., user_signature=False)
>
> In any case if the user is not logged if you tables require a user 
> signature, those fields will not be automatically filled.
>
> On Saturday, 20 April 2019 13:03:17 UTC-7, João Matos wrote:
>>
>> If I replace @auth_requires_login() with @auth.requires_signature() to my 
>> index function (controller's main function) where a grid is created, the 
>> grid shows up without any issue, but if I try to edit a row, I get a Not 
>> Authorized message.
>>
>> Anyone has any idea why this is happening?
>>
>> If I replace @auth.requires_signature() with @auth.requires_login() 
>> everything works.
>>
>

-- 
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] Unable to edit grid record if I add @auth.requires_signature() to action. Is this normal?

2019-04-20 Thread João Matos

If I replace @auth_requires_login() with @auth.requires_signature() to my 
index function (controller's main function) where a grid is created, the 
grid shows up without any issue, but if I try to edit a row, I get a Not 
Authorized message.

Anyone has any idea why this is happening?

If I replace @auth.requires_signature() with @auth.requires_login() 
everything works.

-- 
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: Does web2py support SSE (server sent events) from HTML5?

2019-04-17 Thread João Matos
Thanks Anthony.

quarta-feira, 17 de Abril de 2019 às 03:23:50 UTC+1, Anthony escreveu:
>
> On Tuesday, April 16, 2019 at 11:14:10 AM UTC-4, João Matos wrote:
>>
>> Thanks Anthony, but I'm using Apache. 
>>
>> Do you know any current solution for Apache?
>>
>
> You should be able to run Centrifugo or Pushpin side-by-side with Apache 
> (on a different port). You could even run Nginx alongside Apache, or even 
> proxy from Nginx to Apache.
>  
>
>> Do you recommend Nginx over Apache? If so, why?
>>
>
> Nginx + uWSGI seems to be a common combination for web2py (and other 
> Python frameworks) these days. Do some searches for pros and cons of each 
> web server. I believe Nginx will be faster for serving static files, and of 
> course it can serve as a reverse proxy, so it can serve both your Python 
> app via uWSGI as well as proxy to something like Nchan or Centrifugo for 
> real-time push connections.
>
> 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: Is it possible to update a Rows object with another Rows object?

2019-04-16 Thread João Matos
Thanks Anthony. I found out about belongs after posting.


terça-feira, 16 de Abril de 2019 às 21:51:03 UTC+1, Anthony escreveu:
>
> On Tuesday, April 16, 2019 at 11:11:09 AM UTC-4, João Matos wrote:
>>
>> Is it possible to update a Rows object with another Rows object?
>>
>> I would like to do something similar to this (except that update does not 
>> exist in Rows)
>>
>> rows = db(db.wo.id == int(request.args[0])).select()
>> if len(request.args) > 1:
>> for id_ in request.args[1:]:
>> rows.update(db(db.wo.id == int(id_)).select()
>>
>>
> Why not a single query to get all records:
>
> rows = db(db.wo.id.belongs(request.args)).select()
>
> 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: Is it possible to update a Rows object with another Rows object?

2019-04-16 Thread João Matos
The solution is simply to add them :)
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Combining-rows

Got help in the Telegram Web2py International Support Group at 
https://t.me/web2py_world/


terça-feira, 16 de Abril de 2019 às 16:11:09 UTC+1, João Matos escreveu:
>
> Is it possible to update a Rows object with another Rows object?
>
> I would like to do something similar to this (except that update does not 
> exist in Rows)
>
> rows = db(db.wo.id == int(request.args[0])).select()
> if len(request.args) > 1:
> for id_ in request.args[1:]:
> rows.update(db(db.wo.id == int(id_)).select()
>
>

-- 
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: Does anyone know if web2py supports the IN operator in a query?

2019-04-16 Thread João Matos
Found the solution using .belongs()

terça-feira, 16 de Abril de 2019 às 16:07:48 UTC+1, João Matos escreveu:
>
> Does anyone know if web2py supports the IN operator in a query?
>
> Doesn't seem to accept this
>
> db(db.wo.id in [1,2,3]).select()
>
> that would translate to SQL like this
>
> SELECT * FROM wo WHERE id IN (1, 2, 3)
>
>

-- 
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: Does web2py support SSE (server sent events) from HTML5?

2019-04-16 Thread João Matos
Thanks Anthony, but I'm using Apache. 

Do you know any current solution for Apache?

Do you recommend Nginx over Apache? If so, why?

-- 
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 it possible to update a Rows object with another Rows object?

2019-04-16 Thread João Matos
Is it possible to update a Rows object with another Rows object?

I would like to do something similar to this (except that update does not 
exist in Rows)

rows = db(db.wo.id == int(request.args[0])).select()
if len(request.args) > 1:
for id_ in request.args[1:]:
rows.update(db(db.wo.id == int(id_)).select()

-- 
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] Does anyone know if web2py supports the IN operator in a query?

2019-04-16 Thread João Matos
Does anyone know if web2py supports the IN operator in a query?

Doesn't seem to accept this

db(db.wo.id in [1,2,3]).select()

that would translate to SQL like this

SELECT * FROM wo WHERE id IN (1, 2, 3)

-- 
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: Duplicates in SQLgrid

2019-04-15 Thread João Matos
My bad. distinct only works in select. But a grid doesn't accept a select 
only a query.

I see 3 options:
1. Don't use the grid and you can use the distinct=True in the select;
2. Use the grid and use groupby as a replacement of distinct (this is not a 
recommend use, but for some situations it works);
3. Create a view with distinct in the database (bypassing the DAL) and 
create a table for the view in web2py. Then you can use a grid.


segunda-feira, 15 de Abril de 2019 às 01:23:52 UTC+1, Jacob escreveu:
>
> Unfortunately the alternative isn't enough, I've looked into distinct = 
> True, but as I mentioned earlier I couldn't get it to work with the 
> SQLFORM.grid sorry again I'm still very new to python and web2py.
>
> My code looks like this
> controller contains:
>
> def car_records():
>
> fields =[db.car.vehicle_name, db.car.number_plate,]
>
> query = ( (db.car.id == db.number_plate.id) & (db.reg_date == 02-15-18) )
>
> grid = SQLFORM.grid(query=query, fields=fields, distinct = True) 
>
> return dict(grid=grid, fields=fields)
>
> view contains:
> {{extend 'layout.html'}}
> {{=grid}}
>
> On Sunday, April 14, 2019 at 5:17:34 PM UTC+1, Jacob wrote:
>>
>>
>> Thank you for replying couldn't get it to work with the grid but found an 
>> alternative for now.
>> On Sunday, April 14, 2019 at 9:26:18 AM UTC+1, João Matos wrote:
>>>
>>> Check distinct=True in the book.
>>>
>>> domingo, 14 de Abril de 2019 às 04:27:33 UTC+1, Jacob escreveu:
>>>>
>>>> Hello I'm new to web2py and I have a query which joins tables and 
>>>> displays the results in an SQLgrid. Within the grid of results there 
>>>> values 
>>>> which are appearing more than once due to many to many relationships is 
>>>> there a way to make it so that there are no repeating values.
>>>>
>>>

-- 
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: I would like to log of all SQL commands web2py sends to SQLite. Is it possible?

2019-04-15 Thread João Matos
Thanks Anthony.

I went with a simple solution that serves my purpose (it's a temporary 
need).

I added this code starting with # JM to the 
gluon\packages\dal\pydal\adapters\base.py at line 413.
@with_connection_or_raise
def execute(self, *args, **kwargs):
command = self.filter_sql_command(args[0])
handlers = self._build_handlers_for_execution()
for handler in handlers:
handler.before_execute(command)

# JM
with open('c:\\web2py\\logs\\sql.log', 'a', encoding='utf-8') as 
f_out:  # type: TextIO
if str(command) == 'PRAGMA foreign_keys=ON;':
f_out.write('***' + '\r\n')
f_out.write(command + '\r\n')
else:
f_out.write(command + '\r\n')

# if str(command) == 'PRAGMA foreign_keys=ON;':
# print('***')
# print(command)
# else:
# print(command)



domingo, 17 de Março de 2019 às 18:18:00 UTC, Anthony escreveu:
>
> See http://web2py.com/books/default/chapter/29/04/the-core#Logging. For 
> the logging.conf file format, see 
> https://docs.python.org/2/library/logging.config.html#logging-config-fileformat.
>  
> You'll need to set up a handler for the "pyDAL" logger, which is what the 
> DAL uses for logging.
>
> On Sunday, March 17, 2019 at 4:39:26 AM UTC-4, João Matos wrote:
>>
>> Thanks Anthony, I activated debug=True in DAL but I can't find any log 
>> file.
>> Do you have any idea where it is created?
>>
>>
>> domingo, 17 de Março de 2019 às 00:26:54 UTC, Anthony escreveu:
>>>
>>> Also, if you set DAL(..., debug=True), I believe all SQL commands will 
>>> be logged to the "pyDAL" logger.
>>>
>>> Anthony
>>>
>>> On Saturday, March 16, 2019 at 5:57:47 PM UTC-4, Anthony wrote:
>>>>
>>>> Commands issued during migration operations are already saved to 
>>>> /databases/sql.log. If you want all commands (i.e., queries), note that on 
>>>> each request, there is db._timings, which is a list of tuples, where the 
>>>> first element of each tuple is the SQL command issued and the second 
>>>> element is the amount of time it took to execute. At the end of every 
>>>> request, you could dump the contents of db._timings to a log. You can do 
>>>> that by assigning a callback function to response._caller(), which wraps 
>>>> all calls to controller actions. Note, it will therefore miss any queries 
>>>> that are run in views, but it's probably not a good idea to run queries in 
>>>> views anyway. You could also set up middleware to do the logging: 
>>>> http://web2py.com/books/default/chapter/29/04/the-core?search=_caller#WSGI
>>>> .
>>>>
>>>> Anthony
>>>>
>>>> On Saturday, March 16, 2019 at 4:54:52 PM UTC-4, João Matos wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I would like to log of all SQL commands web2py sends to SQLlite. Is it 
>>>>> possible?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> JM
>>>>>
>>>>

-- 
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: Duplicates in SQLgrid

2019-04-14 Thread João Matos
Check distinct=True in the book.

domingo, 14 de Abril de 2019 às 04:27:33 UTC+1, Jacob escreveu:
>
> Hello I'm new to web2py and I have a query which joins tables and displays 
> the results in an SQLgrid. Within the grid of results there values which 
> are appearing more than once due to many to many relationships is there a 
> way to make it so that there are no repeating values.
>

-- 
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: Is it possible to send all args & vars from a view/controller to another using POST instead of GET?

2019-04-14 Thread João Matos
Thanks.

sábado, 13 de Abril de 2019 às 22:32:20 UTC+1, Anthony escreveu:
>
> On Saturday, April 13, 2019 at 3:00:06 PM UTC-4, João Matos wrote:
>>
>> What I would like is to "hide" all the args and vars from the end user.
>> Couldn't the browser send the args and vars using POST to the web2py 
>> server? I believe so.
>>
>
> Of course, via a form post or an Ajax request -- but not via a redirect.
>
> 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: Does anyone know if it's possible & how I can distinguish, from web2py perspective, 2 browser tabs?

2019-04-14 Thread João Matos
Ok, thanks Anthony and Massimo.

domingo, 14 de Abril de 2019 às 08:20:37 UTC+1, Massimo Di Pierro escreveu:
>
> yes but do not use random() use str(uuid.uuid4())
>
> On Saturday, 13 April 2019 14:03:27 UTC-7, João Matos wrote:
>>
>> I think I found a way.
>> Without even using HTML5 sessionStorage.
>>
>> On the index action of the default controller I insert at the beggining
>> if 'ssid' not in request.vars:
>> redirect(URL(vars={'ssid': random()}, user_signature=True))
>>
>> Using this I have a different id (random number) for each tab.
>>
>> Now I just have to add that id (request var) to all redirects in my app.
>>
>> Could this work?
>>
>>
>> sábado, 13 de Abril de 2019 às 16:36:45 UTC+1, Anthony escreveu:
>>>
>>> What are you trying to do?
>>>
>>> On Friday, April 12, 2019 at 6:10:47 PM UTC-4, João Matos wrote:
>>>>
>>>> Does anyone know if it is possible and how I can distinguish, from 
>>>> web2py perspective, 2 tabs or windows (not Firefox containers) from the 
>>>> same browser?
>>>>
>>>

-- 
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: Does anyone know if it's possible & how I can distinguish, from web2py perspective, 2 browser tabs?

2019-04-13 Thread João Matos
I have several tables that use common controllers. To do that I must pass 
the table name using a request var in the 1st call, which I save to session 
(I must do this because that controller calls others and I don't want to 
have to pass the table var every time).
And there is other state vars I save to session.

Because of this and to allow the users to have several tabs, I must be able 
to distinguish between them.


sábado, 13 de Abril de 2019 às 22:23:40 UTC+1, Anthony escreveu:
>
> On Saturday, April 13, 2019 at 2:57:43 PM UTC-4, João Matos wrote:
>>
>> After authenticating to my web2py app a user can open different tabs and 
>> use any of them or all of them to access the app.
>> I want to be able to distinguish between the tabs.
>>
>
> Yes, but why do you need to distinguish between the tabs? What are you 
> trying to achieve?
>
> 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: How can I get the value from the hidden input field (outside the grid) while in the view?

2019-04-13 Thread João Matos
I think I found an even better way. Without even using HTML5 sessionStorage.

On the index action of the default controller I insert at the beginning
if 'ssid' not in request.vars:
redirect(URL(vars={'ssid': random()}, user_signature=True))

Using this I have a different id (random number) for each tab.

Now I just have to add that id (request var) to all redirects in my app.

Could this work?

sábado, 13 de Abril de 2019 às 16:28:15 UTC+1, Massimo Di Pierro escreveu:
>
> You cannot do whet you ask because a line like this:
>
> {{session[str(random_number)] = random_number}}
>
> would be executed by the server before the code is sent to the client and 
> before the js is executed by the client.
>
> What is the purpose? What are you trying to achieve?
>
> On Friday, 12 April 2019 17:01:10 UTC-7, João Matos wrote:
>>
>> I wrote this
>>
>> {{extend 'layout.html'}}
>>
>> 
>>
>> <!--
>> if (typeof ss_session_id == 'undefined') {
>> sessionStorage.setItem("ss_session_id", Math.random());
>> }
>> var ss_session_id = sessionStorage.getItem("ss_session_id");
>> document.getElementById("ss_session_id").value = ss_session_id;
>> //-->
>>
>> {{=db.notification._plural}}
>>
>> {{=grid}}
>>
>> and it works (it fills the hidden input value with a random number).
>>
>> But now I need to use save the random number generated in javascript and 
>> stored in the hidden input valur (which is outside the grid)
>> {{session[str(random_number)] = random_number}}
>>
>> How can I do that?
>>
>

-- 
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: How can I get the value from the hidden input field (outside the grid) while in the view?

2019-04-13 Thread João Matos
I was able to solve this by using javascript to reload the page with the 
generated random number as a request var.
Then the action will save it to the web2py session.


sábado, 13 de Abril de 2019 às 16:28:15 UTC+1, Massimo Di Pierro escreveu:
>
> You cannot do whet you ask because a line like this:
>
> {{session[str(random_number)] = random_number}}
>
> would be executed by the server before the code is sent to the client and 
> before the js is executed by the client.
>
> What is the purpose? What are you trying to achieve?
>
> On Friday, 12 April 2019 17:01:10 UTC-7, João Matos wrote:
>>
>> I wrote this
>>
>> {{extend 'layout.html'}}
>>
>> 
>>
>> <!--
>> if (typeof ss_session_id == 'undefined') {
>> sessionStorage.setItem("ss_session_id", Math.random());
>> }
>> var ss_session_id = sessionStorage.getItem("ss_session_id");
>> document.getElementById("ss_session_id").value = ss_session_id;
>> //-->
>>
>> {{=db.notification._plural}}
>>
>> {{=grid}}
>>
>> and it works (it fills the hidden input value with a random number).
>>
>> But now I need to use save the random number generated in javascript and 
>> stored in the hidden input valur (which is outside the grid)
>> {{session[str(random_number)] = random_number}}
>>
>> How can I do that?
>>
>

-- 
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: Does anyone know if it's possible & how I can distinguish, from web2py perspective, 2 browser tabs?

2019-04-13 Thread João Matos
I think I found a way.
Without even using HTML5 sessionStorage.

On the index action of the default controller I insert at the beggining
if 'ssid' not in request.vars:
redirect(URL(vars={'ssid': random()}, user_signature=True))

Using this I have a different id (random number) for each tab.

Now I just have to add that id (request var) to all redirects in my app.

Could this work?


sábado, 13 de Abril de 2019 às 16:36:45 UTC+1, Anthony escreveu:
>
> What are you trying to do?
>
> On Friday, April 12, 2019 at 6:10:47 PM UTC-4, João Matos wrote:
>>
>> Does anyone know if it is possible and how I can distinguish, from web2py 
>> perspective, 2 tabs or windows (not Firefox containers) from the same 
>> browser?
>>
>

-- 
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: Does web2py support SSE (server sent events) from HTML5?

2019-04-13 Thread João Matos
It would be great if web3py would support SSE.

For now, the websocket solution would work with Apache?

sábado, 13 de Abril de 2019 às 16:26:13 UTC+1, Massimo Di Pierro escreveu:
>
> No. we do provide a web2py/gluon/contrib/websocket_messaging.py which uses 
> tornado and webocket for the same purpose.
> web3py may provide this functionality.
>
> On Friday, 12 April 2019 15:36:38 UTC-7, João Matos wrote:
>>
>> Does web2py support SSE (server sent events) from HTML5?
>> https://www.w3schools.com/html/html5_serversentevents.asp
>>
>

-- 
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: How can I get the value from the hidden input field (outside the grid) while in the view?

2019-04-13 Thread João Matos
This is related to another question I posted about being able to 
distinguish between 2 browser tabs.
I saw your response that web2py cannot distinguish between the 2 (I'm 
assuming this happens because session is shared).

I as told that using HTML5 sessionStorage
https://www.w3schools.com/html/html5_webstorage.asp
it would be possible.

What the code above is doing is creating a random number per tab and 
storing it in the sessionStorage, it also is stored in the hidden HTML 
input field.
Now I just need a way to get the value stored in the hidden HTML input 
field and save it to a web2py's session dict var.


sábado, 13 de Abril de 2019 às 16:28:15 UTC+1, Massimo Di Pierro escreveu:
>
> You cannot do whet you ask because a line like this:
>
> {{session[str(random_number)] = random_number}}
>
> would be executed by the server before the code is sent to the client and 
> before the js is executed by the client.
>
> What is the purpose? What are you trying to achieve?
>
> On Friday, 12 April 2019 17:01:10 UTC-7, João Matos wrote:
>>
>> I wrote this
>>
>> {{extend 'layout.html'}}
>>
>> 
>>
>> <!--
>> if (typeof ss_session_id == 'undefined') {
>> sessionStorage.setItem("ss_session_id", Math.random());
>> }
>> var ss_session_id = sessionStorage.getItem("ss_session_id");
>> document.getElementById("ss_session_id").value = ss_session_id;
>> //-->
>>
>> {{=db.notification._plural}}
>>
>> {{=grid}}
>>
>> and it works (it fills the hidden input value with a random number).
>>
>> But now I need to use save the random number generated in javascript and 
>> stored in the hidden input valur (which is outside the grid)
>> {{session[str(random_number)] = random_number}}
>>
>> How can I do that?
>>
>

-- 
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: Is it possible to send all args & vars from a view/controller to another using POST instead of GET?

2019-04-13 Thread João Matos
What I would like is to "hide" all the args and vars from the end user.
Couldn't the browser send the args and vars using POST to the web2py 
server? I believe so.

sábado, 13 de Abril de 2019 às 16:41:16 UTC+1, Anthony escreveu:
>
> On Friday, April 12, 2019 at 7:41:43 PM UTC-4, João Matos wrote:
>>
>> So no option for redirect with POST. That is a shame.
>>
>
> That's just how browsers work. A redirect is simply a response sent to the 
> browser with a 303 HTTP code and a new URL location -- the browser then 
> requests the new URL. You could handle this via Javascript and Ajax, but 
> there may be a simpler option, depending on your goal.
>  
>
>> The book mentions request.post_vars. In what situation would one use it?
>>
>
> When a post request comes in, the post data are stored in 
> request.post_vars, allowing you code to access the data. FORM and SQLFORM, 
> for example, read data from request.post_vars.
>
> 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: Does anyone know if it's possible & how I can distinguish, from web2py perspective, 2 browser tabs?

2019-04-13 Thread João Matos

After authenticating to my web2py app a user can open different tabs and 
use any of them or all of them to access the app.
I want to be able to distinguish between the tabs.
I know that web2py cannot do this (Massimo confirmed above) because session 
is shared, but I've been told that using HTML5 sessionStorage would solve 
this.
https://www.w3schools.com/html/html5_webstorage.asp


sábado, 13 de Abril de 2019 às 16:36:45 UTC+1, Anthony escreveu:
>
> What are you trying to do?
>
> On Friday, April 12, 2019 at 6:10:47 PM UTC-4, João Matos wrote:
>>
>> Does anyone know if it is possible and how I can distinguish, from web2py 
>> perspective, 2 tabs or windows (not Firefox containers) from the same 
>> browser?
>>
>

-- 
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] Re: How to add a read-only field to a SQLFORM.factory

2019-04-13 Thread João Matos
Had to revert to my old code

form.element('#no_table_sn')['_readonly'] = 'readonly'

instead of

widget=lambda field, value:
SQLFORM.widgets.string.widget(field, value), _readonly=True
),

because otherwise after onvalidation web2py would remove "form-control " 
from the field's class and the appearence of the field would change.
Is this a bug?



sábado, 30 de Março de 2019 às 03:01:27 UTC, Anthony escreveu:
>
> On Friday, March 29, 2019 at 5:42:10 PM UTC-4, João Matos wrote:
>>
>> Found a solution (more like a kludge) :)
>>
>> form.element('#no_table_sn')['_readonly'] = 'readonly' 
>>
> I even tried adding 
>>
>> _readonly='readonly'
>>
>> to the Field, but didn't work.
>>
>> Only works after the form exists.
>>
>
> Field('sn', widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, 
> _readonly=True))
>
>
>> Is there a better way?
>>
>
> As noted earlier, you can use the "fields" argument.
>
> 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: Is it possible to send all args & vars from a view/controller to another using POST instead of GET?

2019-04-13 Thread João Matos
Thanks.

sábado, 13 de Abril de 2019 às 03:34:21 UTC+1, Dave S escreveu:
>
>
>
> On Friday, April 12, 2019 at 4:41:43 PM UTC-7, João Matos wrote:
>>
>> So no option for redirect with POST. That is a shame.
>>
>>
> It's up to the client how an HTTP 303 is handled.  It's usually the case 
> that a GET is used to retrieve a response that is ultimately from a POST 
> request.
>
> If 2 controller functions need to share data, use the session or a 
> database entry.
>  
>
>> The book mentions request.post_vars. In what situation would one use it?
>>
>>
> To retrieve the data the client sent in a POST request.
>
> Logging in with AUTH often involves the following sequence:
>
> client: GET resourceX
> server: 303 pointing to user/login and setting an arg for _next [points to 
> resourceX or a relevant object]
> client: GET user/login
> server 200 + page contents (login form)
> client: POST login data (generally credentials in some form), arg _next in 
> URL  [server sees this in request.post_vars]
> server: 200 + page contents of resourceX
>
> This description is like those arrow diagrams with client on the left, 
> server on the right, and time flowing downwards; I've simplified the 
> description, but 
> I'm cribbing from my NginX logs; I think you've said you're stuck with 
> Apache, which should show similar interactions in the form it's logs use.
>
> The above exchange was with a browser for a client, but I have clients 
> that use libcurl, and libcurl offers a choice of how to deal with 303's:  
> follow automatically,  or just report the new URL (or URI these days).  
> With the latter option, the URL can be examined (for validation, perhaps), 
> and the client decides to request the new page based on its processing.
>
> /dps
>
>
> sábado, 13 de Abril de 2019 às 00:33:56 UTC+1, Dave S escreveu:
>>
>>
>>
>> On Friday, April 12, 2019 at 4:25:48 PM UTC-7, João Matos wrote:
>>>
>>> redirect
>>>
>>
>>
>> Then it is actually the client (browser?) that accesses the  other 
>> function, you're just telling it where to make the new request (you can put 
>> vars and args in the URL, but you don't control the method).  Can you put 
>> something in the session (with pickle restrictions)?  Other thought:  a db 
>> table just for the handing over of request data, and the redirect URL has a 
>> single arg that specifies the row being handed over.  The number of rows 
>> can be small because the consumer can delete a row when complete.
>>
>> /dps
>>
>>
>>
>>> sexta-feira, 12 de Abril de 2019 às 23:59:46 UTC+1, Dave S escreveu:
>>>>
>>>>
>>>>
>>>> On Friday, April 12, 2019 at 3:12:55 PM UTC-7, João Matos wrote:
>>>>>
>>>>> Is it possible to send all args and vars from a view/controller to 
>>>>> another view/controller using POST instead of GET?
>>>>>
>>>>
>>>> Is this as a redirect or a fetch?  fetch's 2nd argument, data, selects 
>>>> for POST if not null, and urlencodes data's value.
>>>>
>>>> The redirect code doesn't seem to have a way change method, but then it 
>>>> is primarily just for returning an HTTP 303 status.
>>>>
>>>> (See gluon/tools.py and gluon/http.py respectively)
>>>>
>>>> /dps
>>>>  
>>>>
>>>

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


[web2py] How can I get the value from the hidden input field (outside the grid) while in the view?

2019-04-12 Thread João Matos
I wrote this

{{extend 'layout.html'}}





{{=db.notification._plural}}

{{=grid}}

and it works (it fills the hidden input value with a random number).

But now I need to use save the random number generated in javascript and 
stored in the hidden input valur (which is outside the grid)
{{session[str(random_number)] = random_number}}

How can I do that?

-- 
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: Is it possible to send all args & vars from a view/controller to another using POST instead of GET?

2019-04-12 Thread João Matos
So no option for redirect with POST. That is a shame.

The book mentions request.post_vars. In what situation would one use it?


sábado, 13 de Abril de 2019 às 00:33:56 UTC+1, Dave S escreveu:
>
>
>
> On Friday, April 12, 2019 at 4:25:48 PM UTC-7, João Matos wrote:
>>
>> redirect
>>
>
>
> Then it is actually the client (browser?) that accesses the  other 
> function, you're just telling it where to make the new request (you can put 
> vars and args in the URL, but you don't control the method).  Can you put 
> something in the session (with pickle restrictions)?  Other thought:  a db 
> table just for the handing over of request data, and the redirect URL has a 
> single arg that specifies the row being handed over.  The number of rows 
> can be small because the consumer can delete a row when complete.
>
> /dps
>
>
>
>> sexta-feira, 12 de Abril de 2019 às 23:59:46 UTC+1, Dave S escreveu:
>>>
>>>
>>>
>>> On Friday, April 12, 2019 at 3:12:55 PM UTC-7, João Matos wrote:
>>>>
>>>> Is it possible to send all args and vars from a view/controller to 
>>>> another view/controller using POST instead of GET?
>>>>
>>>
>>> Is this as a redirect or a fetch?  fetch's 2nd argument, data, selects 
>>> for POST if not null, and urlencodes data's value.
>>>
>>> The redirect code doesn't seem to have a way change method, but then it 
>>> is primarily just for returning an HTTP 303 status.
>>>
>>> (See gluon/tools.py and gluon/http.py respectively)
>>>
>>> /dps
>>>  
>>>
>>

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


[web2py] Re: Is it possible to send all args & vars from a view/controller to another using POST instead of GET?

2019-04-12 Thread João Matos
redirect

sexta-feira, 12 de Abril de 2019 às 23:59:46 UTC+1, Dave S escreveu:
>
>
>
> On Friday, April 12, 2019 at 3:12:55 PM UTC-7, João Matos wrote:
>>
>> Is it possible to send all args and vars from a view/controller to 
>> another view/controller using POST instead of GET?
>>
>
> Is this as a redirect or a fetch?  fetch's 2nd argument, data, selects for 
> POST if not null, and urlencodes data's value.
>
> The redirect code doesn't seem to have a way change method, but then it is 
> primarily just for returning an HTTP 303 status.
>
> (See gluon/tools.py and gluon/http.py respectively)
>
> /dps
>  
>

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


[web2py] Re: Sorting a Rows object by a particular field

2019-04-12 Thread João Matos
In my case the first seems to be working.
Check this

rows = db(db.auth_user.id < 3).select()
print('***')
print(rows)
print('---')
print(rows.sort(lambda r: r["id"], reverse=True))

-- 
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] Does web2py support SSE (server sent events) from HTML5?

2019-04-12 Thread João Matos
Does web2py support SSE (server sent events) from HTML5?
https://www.w3schools.com/html/html5_serversentevents.asp

-- 
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: Sorting a Rows object by a particular field

2019-04-12 Thread João Matos
The orderby of the DAL or the ORDER BY of the SQL engine you use wouldn't 
do the job?


sexta-feira, 12 de Abril de 2019 às 11:03:10 UTC+1, Dave S escreveu:
>
> Pro tip:  do not call your controller function "sorted".
>
> Getting past that, I have a Rows object (call it "rowed") that I've 
> created from munching through the results of a select().  (Why?  because 
> for presentation reasons, I do an aggregation with custom logic.)  In the 
> past, ordering was done by the select and "inherited" by rowed.  Now I want 
> the option of sorting rowed by a different field (the aggregated count).  
> If I do 
>   rowed.records = sorted(rowed.records,key=lambda r: r.NumAdded)
> everything is fine.  But if I do
> rowed.sort(lambda r: r["NumAdded"])
> or
> rowed.records.sort(lambda r: ["NumAdded"])
> I don't get what I want.  The first doesn't seem to change the ordering, 
> and the second raises heck^W an exception
> (() takes exactly 1 argument (2 
> given))
>
> In the ticket, rowed.records looks like 
> [ '...xx', 'id': 26L, 'NumAdded': 31L}>,  datetime.date(2017, 1, 2), 'funkystr': 'xxx', 'id': 131L, 
> 'NumAdded': 15L}>, ]
>
> and r like
> 
>
> These suggest that my lambda is getting passed something other than what's 
> in the curly braces above.  What would be the correct way to write the 
> lambda (which would right the ship)?
>
> [OT:  I think Opera mucks up the GG formatting controls; I may edit this 
> in FF or Chrome tomorrow]
>
> PS:  thanks again to Anthony for previous help with cmp/key issues.
>
> Dave S
> /dps
>
>

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


[web2py] Is it possible to send all args & vars from a view/controller to another using POST instead of GET?

2019-04-12 Thread João Matos
Is it possible to send all args and vars from a view/controller to another 
view/controller using POST instead of GET?

-- 
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] Does anyone know if it's possible & how I can distinguish, from web2py perspective, 2 browser tabs?

2019-04-12 Thread João Matos
Does anyone know if it is possible and how I can distinguish, from web2py 
perspective, 2 tabs or windows (not Firefox containers) from the same 
browser?

-- 
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: Bug in grid's edit validation.

2019-04-11 Thread João Matos
Everytime I exchange messages with you I learn something. Thanks.

quinta-feira, 11 de Abril de 2019 às 20:13:48 UTC+1, Anthony escreveu:
>
> On Thursday, April 11, 2019 at 2:03:00 PM UTC-4, João Matos wrote:
>>
>> 'll check out the db.mytable._before_delete callback.
>>
>> You said 
>> " I would probably simply disable the "delete" checkbox in the edit form 
>> (via editargs=dict(deletable=False)
>> ), and only allow deletion via the grid buttons (which you can then 
>> intercept via the ondelete callback)."
>>
>> ondelete works but has a drawback (at least I couldn't figure out a 
>> solution). It works fine if what we have to do doesn't require a 
>> redirection to another page. If it does, it doesn't work.
>>
>
> Deletes via the grid buttons happen via Ajax, so you need a client-side 
> redirect:
>
> def ondelete(table, id):
> redirect(URL(...), client_side=True)
>
> 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: Bug in grid's edit validation.

2019-04-11 Thread João Matos

'll check out the db.mytable._before_delete callback.

You said 
" I would probably simply disable the "delete" checkbox in the edit form 
(via editargs=dict(deletable=False)
), and only allow deletion via the grid buttons (which you can then 
intercept via the ondelete callback)."

ondelete works but has a drawback (at least I couldn't figure out a 
solution). It works fine if what we have to do doesn't require a 
redirection to another page. If it does, it doesn't work.


quinta-feira, 11 de Abril de 2019 às 18:48:07 UTC+1, Anthony escreveu:
>
> On Thursday, April 11, 2019 at 11:33:16 AM UTC-4, João Matos wrote:
>>
>> I'm sorry, but I can't agree with you about the consistency.
>> I'm aware that the onvalidation is called after the validation.
>> The inconsistency is why is it sometimes called when the delete checkbox 
>> is selected and not in others?
>> If the assumption is that it has nothing to do with deletion, then it 
>> should never be called if the delete checkbox is selected. Which is not the 
>> case.
>>
>
> I agree it should never be called on deletion, but if it worked that way, 
> it would make no difference for your use case. (As an aside, the reason the 
> validation process proceeds even on deletion is likely due to the fact that 
> SQLFORM is implemented by extending FORM, so the usual FORM processing 
> happens before SQLFORM deals with the delete.)
>
> I suppose instead you would like onvalidaton to run in *all *cases (when 
> delete is checked), but I don't think that is the best solution for your 
> use cases, as it would still require custom internal logic to distinguish 
> deletions (not to mention that it would break backward compatibility). 
> Instead, if we were going to make changes to accommodate these use cases, a 
> better approach would be a separate before delete hook, and possibly an 
> after delete hook. But even without these additional hooks, it is fairly 
> easy to accommodate these cases with the DAL callbacks or simply with some 
> code that runs before or after the grid code.
>  
>
>> There is a way to distinguish an edit from a delete from within 
>> onvalidation. I use 
>>
>> if form.vars.delete_this_record: 
>>
>> and it works.
>>
>
> Yes. The point is the need for such custom logic makes onvalidation less 
> suitable for what you want to do. A separate callback would be more useful. 
> Otherwise, you might as well just put that logic outside of onvalidation.
>  
>
>> On the 2nd case, I must correct you that ondelete is run before the 
>> delete happens. I use it to mark the record inactive and stop the deletion, 
>> when the user "deletes" the record from the grid itself.
>>
>
> Yes, good point. Actually, in your case, I would probably simply disable 
> the "delete" checkbox in the edit form (via editargs=dict(deletable=False)), 
> and only allow deletion via the grid buttons (which you can then intercept 
> via the ondelete callback).
>
> An even better approach would be to use the db.mytable._before_delete 
> callback, which is exactly how the built-in record versioning works (it 
> adds a _before_delete callback that intercepts all deletes and instead 
> updates the is_active field to False). This would catch deletion via the 
> grid buttons or edit forms.
>  
>
>> There is case I mentioned and that you didn't consider which is before 
>> the delete, doing something that doesn't require a separate workflow, which 
>> is exactly my problem. I just want to mark the record inactive. From the 5 
>> scenarios I explained, all of which originate from the grid's edit form, 3 
>> go to onvalidation (and are deleting the record) and 2 don't. Again, this 
>> is an inconsistency.
>>
>
> See above -- onvalidation is not the place for that logic. Though if you 
> *must*, you can simply put that logic in both the onupdate and onfailure 
> callbacks of the grid, or specify onvalidation as a dictionary, with 
> onsuccess and onfailure callbacks that both include that logic.
>  
>
>> Thanks for the explanation about the arguments.
>>
>> I tried with
>> if SQLFORM.FIELDNAME_REQUEST_DELETE in request.post_vars:
>> and this catches the missing cases.
>>
>> But I must say it is a ugly solution. My point being that all the 
>> validation and checking is usually done in the onvalidation, ondelete, etc. 
>> And this to work must be at the top of the action instead of in one of the 
>> on* functions.
>> It works, but IMO is not a pretty solution.
>>
>
> Callbacks are necessary when you need to run some custom code in the 
> middle of some other process, but less i

[web2py] Re: Bug in grid's edit validation.

2019-04-11 Thread João Matos
a) I find it the easiest to have all the validation and checking to be done 
in onvalidation, ondelete, etc.. Unfortunately this doesn't happen in 2 
situations out of 5 for deletion (again the question of the inconsistency).
b) The asking of the password only occurs when the user decides to delete 
the record. If he enters edit to simply edit, there would be no sense in 
asking for the password. There is no extra step here.

quinta-feira, 11 de Abril de 2019 às 15:58:20 UTC+1, Anthony escreveu:
>
> On Thursday, April 11, 2019 at 7:54:46 AM UTC-4, João Matos wrote:
>>
>> They don't. I have everything working (the redirection to request for 
>> supervisor password on record deletion in the grid, using a link), the 
>> checks for record deletion in the edit form also work, except for the cases 
>> I pointed out.
>>
>
> Yes, but just because everything is working does not mean (a) that was the 
> easiest way to achieve the end goal or (b) you haven't compromised user 
> experience to stay within the bounds of the available built-in 
> functionality. For example, if a special password is needed to delete a 
> record, it would be simpler to just enter it up front rather than first 
> submitting the delete request and then having to enter the password on a 
> separate page. Not only is that an unnecessary extra step, but it may 
> surprise the user if the UI makes no indication ahead of time that a 
> special password is required.
>
> 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: Bug in grid's edit validation.

2019-04-11 Thread João Matos
I'm sorry, but I can't agree with you about the consistency.
I'm aware that the onvalidation is called after the validation.
The inconsistency is why is it sometimes called when the delete checkbox is 
selected and not in others?
If the assumption is that it has nothing to do with deletion, then it 
should never be called if the delete checkbox is selected. Which is not the 
case.

There is a way to distinguish an edit from a delete from within 
onvalidation. I use 

if form.vars.delete_this_record: 

and it works.

I agree with your 1st case.

On the 2nd case, I must correct you that ondelete is run before the delete 
happens. I use it to mark the record inactive and stop the deletion, when 
the user "deletes" the record from the grid itself.

There is case I mentioned and that you didn't consider which is before the 
delete, doing something that doesn't require a separate workflow, which is 
exactly my problem. I just want to mark the record inactive. From the 5 
scenarios I explained, all of which originate from the grid's edit form, 3 
go to onvalidation (and are deleting the record) and 2 don't. Again, this 
is an inconsistency.

Thanks for the explanation about the arguments.

I tried with
if SQLFORM.FIELDNAME_REQUEST_DELETE in request.post_vars:
and this catches the missing cases.

But I must say it is a ugly solution. My point being that all the 
validation and checking is usually done in the onvalidation, ondelete, etc. 
And this to work must be at the top of the action instead of in one of the 
on* functions.
It works, but IMO is not a pretty solution.



quinta-feira, 11 de Abril de 2019 às 15:50:55 UTC+1, Anthony escreveu:
>
> On Thursday, April 11, 2019 at 7:52:18 AM UTC-4, João Matos wrote:
>>
>> Thanks for the explanations.
>>
>> You don't understand. I don't care if the changes made at the same time 
>> the deleted checkbox is selected, are saved when submitting. That is not 
>> the problem. 
>> It is a question of consistency.
>>
>> Either web2py should call on_validation when the delete checkbox is 
>> selected or not. What happens now is that in some scenarios it is called 
>> but not in others.
>> My opinion is that it should always be called, but above all, it should 
>> be consistent.
>>
>
> The "onvalidation" function is supposed to be called "upon validation" 
> (hence the name), meaning after a successful validation of the submitted 
> field values. It is not intended to be run in order to make checks before 
> or after deletion of a record. In other words, onvalidation runs when 
> particular conditions are met, and it does so *consistently*. It just so 
> happens that you want to run it under different conditions, which is not 
> its intended purpose. Even if it did run when you want, you would still 
> need a way to distinguish a regular update request from a delete request, 
> and you can do that just as easily outside of the onvalidation function 
> (see below).
>
> I think there are three types of cases to handle regarding deletes:
>
> First, you might want to simply allow/disallow a delete, and that case is 
> handled by the "deletable" argument.
>
> Second, you might want to run some code *after* a successful delete. The 
> grid has an "ondelete" argument to handle that in case the "Delete" button 
> is clicked, but nothing for the case when a delete happens via an edit 
> form. However, this can be handled in all cases via the 
> db.mytable._after_delete callback. In any case, the onvalidation function 
> would not be the best place for this logic as it (a) runs *before *the 
> delete happens, and (b) would still require some logic to determine that a 
> delete was requested. It might be nice if SQLFORM had a separate "ondelete" 
> argument of its own.
>
> Finally, you might want to allow the user to request a delete and then 
> kick off a separate workflow, such as requiring a special password. 
> However, that is really a special case that is application specific, and it 
> is not even well accommodated by the current UI (i.e., it would be a better 
> user experience to request the special password up front rather than making 
> it a two step process). If you need something like that, you should really 
> be implementing custom logic. And again, the onvalidation function is not 
> the best place for such logic, as it would still require detection of the 
> delete request.
>
> As an aside, note that the "onvalidation" argument can actually be a 
> dictionary with separate "onsuccess", "onfailure", and "onchange" 
> callbacks. The grid also has "onupdate" (run after successful update) and 
> "onfailure" (run after failed up

[web2py] Re: Bug in grid's edit validation.

2019-04-11 Thread João Matos
They don't. I have everything working (the redirection to request for 
supervisor password on record deletion in the grid, using a link), the 
checks for record deletion in the edit form also work, except for the cases 
I pointed out.


quinta-feira, 11 de Abril de 2019 às 12:26:34 UTC+1, Anthony escreveu:
>
> I should also point out, at some point, if your requirements deviate too 
> far from the built-in functionality of the grid, it might be easier to not 
> use the grid and simply code your own solution.
>
> On Thursday, April 11, 2019 at 7:24:35 AM UTC-4, Anthony wrote:
>>
>> On Wednesday, April 10, 2019 at 4:04:35 PM UTC-4, João Matos wrote:
>>>
>>> Because in my case the record is not deleted simply deactivated.
>>>
>>
>> Whether or not the record is being permanently deleted or simply 
>> deactivated, it would not generally make sense to validate submitted 
>> changes, as the expectation would be that the changes would not be 
>> persisted. If you have a specific use case for allowing simultaneous update 
>> and deactivation (i.e., "save these changes and then immediately deactivate 
>> the record"), then you'll have to code that logic yourself (though I would 
>> recommend making the user experience more clear in that case, as the 
>> current UI and workflow does not make it clear that updates would be 
>> persisted prior to deletion). I don't think it makes sense for that to be 
>> the default behavior.
>>  
>>
>>> But there are other scenarios:
>>>  - Making additional checks before allowing the record deletion;
>>>
>>
>> That is what the "deletable" argument is for. It can be a function that 
>> receives a Row object and determines if the record is allowed to be 
>> deleted. If not allowed, (a) no delete button will appear next to that 
>> record in the grid, and (b) the "delete record" checkbox will not appear on 
>> the edit form.
>>  
>>
>>>  - Asking for the password of a supervisor before allowing the record 
>>> deletion;
>>>
>>
>> This kind of functionality would go beyond the scope of "onvalidation" 
>> anyway, as you would have to redirect elsewhere and start a new workflow. 
>> You might as well code your own logic to handle this.
>>  
>>
>>>  - Making some changes to other tables as a consequence of the record 
>>> deletion;
>>>  - Wanting to receive an email when someone deletes a record from a 
>>> special table;
>>>  - Doing some house keeping or some other task when someone deletes a 
>>> record.
>>>
>>
>> Better to use the db.mytable._after_delete callback for these cases.
>>
>> 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: Bug in grid's edit validation.

2019-04-11 Thread João Matos
Thanks for the explanations.

You don't understand. I don't care if the changes made at the same time the 
deleted checkbox is selected, are saved when submitting. That is not the 
problem. 
It is a question of consistency.

Either web2py should call on_validation when the delete checkbox is 
selected or not. What happens now is that in some scenarios it is called 
but not in others.
My opinion is that it should always be called, but above all, it should be 
consistent.

-- 
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: Bug in grid's edit validation.

2019-04-10 Thread João Matos
I wrote "Because in my case the record is not deleted simply deactivated." 
and I meant "Because in my case I want the record to be simply deactivated 
instead of deleted."

quarta-feira, 10 de Abril de 2019 às 21:04:35 UTC+1, João Matos escreveu:
>
> Because in my case the record is not deleted simply deactivated.
>
> But there are other scenarios:
>  - Making additional checks before allowing the record deletion;
>  - Asking for the password of a supervisor before allowing the record 
> deletion;
>  - Making some changes to other tables as a consequence of the record 
> deletion;
>  - Wanting to receive an email when someone deletes a record from a 
> special table;
>  - Doing some house keeping or some other task when someone deletes a 
> record.
>
> There are 5 options when entering the grid's edit:
> 1. The user checks the record and decides to delete it without making any 
> changes, selects the delete checkbox and submits.
> 2. The user makes some changes that are valid and then decides to delete 
> the record and submits both the valid changes (which don't get saved) and 
> the delete checkbox selected.
> 3. The user makes some changes that are not valid (eg. changing a unique 
> field to a value that already exists) and submits. He receives the 
> validation error message, corrects the value to a valid one and then 
> decides to delete the record and submits with the delete checkbox selected.
> 4. The user makes some changes that are not valid (eg. changing a unique 
> field to a value that already exists) and submits. He receives the 
> validation error message, doesn't correct the value and decides to delete 
> the record and submits with the delete checkbox selected.
> 5. The user makes some changes that are not valid (eg. changing a unique 
> field to a value that already exists) and then decides to delete the record 
> and submits both the invalid changes and the delete checkbox selected.
>
> In 1, 2 and 3 web2py calls onvalidation. But not on 4 and 5 (which submit 
> the same information, an invalid value and the delete checkbox selected). 
> That is the problem here.
>
>
> quarta-feira, 10 de Abril de 2019 às 20:38:17 UTC+1, Anthony escreveu:
>>
>> I found a bug in the grid's edit validation.
>>> I follow this procedure:
>>>  - Select a record to edit.
>>>  - Change one of the fields that must be unique and change it to a value 
>>> that already exists.
>>>  - web2py shows an error message (which is correct and happens before 
>>> going to onvalidation, which is also correct).
>>>  - Change the value to something that doesn't already exist in the table.
>>>  - Mark the record for deletion.
>>>  - Submit the record.
>>>
>>> The bug I found is that web2py was supposed to go to onvalidation before 
>>> deleting the record and that doesn't happen.
>>>
>>
>> If the record is being deleted, why would you need to validate the 
>> submitted values (given that they will not be applied)?
>>
>> 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: Bug in grid's edit validation.

2019-04-10 Thread João Matos
Because in my case the record is not deleted simply deactivated.

But there are other scenarios:
 - Making additional checks before allowing the record deletion;
 - Asking for the password of a supervisor before allowing the record 
deletion;
 - Making some changes to other tables as a consequence of the record 
deletion;
 - Wanting to receive an email when someone deletes a record from a special 
table;
 - Doing some house keeping or some other task when someone deletes a 
record.

There are 5 options when entering the grid's edit:
1. The user checks the record and decides to delete it without making any 
changes, selects the delete checkbox and submits.
2. The user makes some changes that are valid and then decides to delete 
the record and submits both the valid changes (which don't get saved) and 
the delete checkbox selected.
3. The user makes some changes that are not valid (eg. changing a unique 
field to a value that already exists) and submits. He receives the 
validation error message, corrects the value to a valid one and then 
decides to delete the record and submits with the delete checkbox selected.
4. The user makes some changes that are not valid (eg. changing a unique 
field to a value that already exists) and submits. He receives the 
validation error message, doesn't correct the value and decides to delete 
the record and submits with the delete checkbox selected.
5. The user makes some changes that are not valid (eg. changing a unique 
field to a value that already exists) and then decides to delete the record 
and submits both the invalid changes and the delete checkbox selected.

In 1, 2 and 3 web2py calls onvalidation. But not on 4 and 5 (which submit 
the same information, an invalid value and the delete checkbox selected). 
That is the problem here.


quarta-feira, 10 de Abril de 2019 às 20:38:17 UTC+1, Anthony escreveu:
>
> I found a bug in the grid's edit validation.
>> I follow this procedure:
>>  - Select a record to edit.
>>  - Change one of the fields that must be unique and change it to a value 
>> that already exists.
>>  - web2py shows an error message (which is correct and happens before 
>> going to onvalidation, which is also correct).
>>  - Change the value to something that doesn't already exist in the table.
>>  - Mark the record for deletion.
>>  - Submit the record.
>>
>> The bug I found is that web2py was supposed to go to onvalidation before 
>> deleting the record and that doesn't happen.
>>
>
> If the record is being deleted, why would you need to validate the 
> submitted values (given that they will not be applied)?
>
> 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] Re: The support of MongoDB is still experimental?

2019-04-10 Thread João Matos
Thanks.

quarta-feira, 10 de Abril de 2019 às 18:57:11 UTC+1, Lovedie JC escreveu:
>
> ON the localhost
>
> # coding: utf8
> from gluon import current
> from pymongo import MongoClient
> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
> from gluon.custom_import import track_changes
> track_changes(True)
> db = DAL('mongodb://localhost/"db name"')
> response.generic_patterns = ['*'] if request.is_local else []
> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>
> db.define_table('post',
> Field('author', 'reference auth_user', 
> default=auth.user_id, readable=False, writable=False),
> Field('message', 'text', requires=IS_NOT_EMPTY(),),
> auth.signature
> )
>
> controller:
> row = db(db.post.author== auth.user.id).select(db.post.id, 
> db.post.message, orderby=~db.post.id, limitby=(0,1)).first()
>
> *MongoDB*
> *# I use ubuntu 18.04LTS*
> 1. Download the mongo db browser, studio 3T from  
> https://studio3t.com/download/ 
> 2. Follow instructions after download
> 3. It will save in the homepage as folder(called robo3t)
> 4. In the folder, bin folder, find the robo3t app. Click on it, then click 
> on connect to see your db. See the images attached.
>
> N/B I noted that sometimes the error of 'Null type' comes when accessing 
> the db when no value has been entered/posted. SO post some value and see it 
> in the database with the browser.
>
>
>
>
> On Wed, 10 Apr 2019 at 19:38, João Matos > 
> wrote:
>
>> Thanks, an example would be great.
>>
>>
>> quarta-feira, 10 de Abril de 2019 às 15:33:46 UTC+1, Lovedie JC escreveu:
>>>
>>> I send you an example. Yes I use through DAL. It's nice. 
>>>
>>> On Wed, 10 Apr 2019, 17:01 João Matos  wrote:
>>>
>>>> Thanks for the feedback. 
>>>>
>>>> Do you use it through the DAL or directly?
>>>> If you use it through the DAL, are you able to select, insert, delete 
>>>> and update records without any issue?
>>>> Do you recommend it?
>>>>
>>>>
>>>>
>>>> quarta-feira, 10 de Abril de 2019 às 04:33:32 UTC+1, Lovedie JC 
>>>> escreveu:
>>>>>
>>>>> I use mongodb. It works well. I think digital Ocean.com implements it 
>>>>> nicely
>>>>>
>>>>> On Wed, 10 Apr 2019, 02:09 João Matos  wrote:
>>>>>
>>>>>> Thanks Anthony. Who can confirm this? Is ti Massimo or is there 
>>>>>> another person in charge of MongoDB in web2py?
>>>>>>
>>>>>>
>>>>>> terça-feira, 9 de Abril de 2019 às 23:59:36 UTC+1, Anthony escreveu:
>>>>>>>
>>>>>>> I don't think so -- just that the book was never updated.
>>>>>>>
>>>>>>> On Tuesday, April 9, 2019 at 6:37:04 PM UTC-4, João Matos wrote:
>>>>>>>>
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> The support of MongoDB is still experimental?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> JM
>>>>>>>>
>>>>>>> -- 
>>>>>> 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 web...@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 web...@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 web...@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] Re: The support of MongoDB is still experimental?

2019-04-10 Thread João Matos
Thanks, an example would be great.


quarta-feira, 10 de Abril de 2019 às 15:33:46 UTC+1, Lovedie JC escreveu:
>
> I send you an example. Yes I use through DAL. It's nice. 
>
> On Wed, 10 Apr 2019, 17:01 João Matos > 
> wrote:
>
>> Thanks for the feedback. 
>>
>> Do you use it through the DAL or directly?
>> If you use it through the DAL, are you able to select, insert, delete and 
>> update records without any issue?
>> Do you recommend it?
>>
>>
>>
>> quarta-feira, 10 de Abril de 2019 às 04:33:32 UTC+1, Lovedie JC escreveu:
>>>
>>> I use mongodb. It works well. I think digital Ocean.com implements it 
>>> nicely
>>>
>>> On Wed, 10 Apr 2019, 02:09 João Matos  wrote:
>>>
>>>> Thanks Anthony. Who can confirm this? Is ti Massimo or is there another 
>>>> person in charge of MongoDB in web2py?
>>>>
>>>>
>>>> terça-feira, 9 de Abril de 2019 às 23:59:36 UTC+1, Anthony escreveu:
>>>>>
>>>>> I don't think so -- just that the book was never updated.
>>>>>
>>>>> On Tuesday, April 9, 2019 at 6:37:04 PM UTC-4, João Matos wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> The support of MongoDB is still experimental?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> JM
>>>>>>
>>>>> -- 
>>>> 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 web...@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 web...@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] How to insert a button inside the web2py_console div (like the default Add Record button)?

2019-04-10 Thread João Matos
Hello,

Does anyone know how can I add "Add Record" button to a grid with 
create=False (I want the button to be in the same place of the default "Add 
Record" button if create=True was used).

I already have the button at the top left (above the search bar).

Now I just have to figure how to insert the button

Adicionar registo


into the

 

like the default "Add Record" button.

Thanks,

JM

-- 
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] Bug in grid's edit validation.

2019-04-10 Thread João Matos
Hello,

I found a bug in the grid's edit validation.
I follow this procedure:
 - Select a record to edit.
 - Change one of the fields that must be unique and change it to a value 
that already exists.
 - web2py shows an error message (which is correct and happens before going 
to onvalidation, which is also correct).
 - Change the value to something that doesn't already exist in the table.
 - Mark the record for deletion.
 - Submit the record.

The bug I found is that web2py was supposed to go to onvalidation before 
deleting the record and that doesn't happen.

Can someone confirm this behavior and that it is indeed a bug? 

Thanks,

JM


My env:
Windows 7 Pro x64 w/SP1+all upd
Firefox 66.0.2 x64
web2py 2.18.5 (2.18.4 showed the same problem)
Python 3.7.1 x86

-- 
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] Re: The support of MongoDB is still experimental?

2019-04-10 Thread João Matos
Thanks for the feedback. 

Do you use it through the DAL or directly?
If you use it through the DAL, are you able to select, insert, delete and 
update records without any issue?
Do you recommend it?



quarta-feira, 10 de Abril de 2019 às 04:33:32 UTC+1, Lovedie JC escreveu:
>
> I use mongodb. It works well. I think digital Ocean.com implements it 
> nicely
>
> On Wed, 10 Apr 2019, 02:09 João Matos > 
> wrote:
>
>> Thanks Anthony. Who can confirm this? Is ti Massimo or is there another 
>> person in charge of MongoDB in web2py?
>>
>>
>> terça-feira, 9 de Abril de 2019 às 23:59:36 UTC+1, Anthony escreveu:
>>>
>>> I don't think so -- just that the book was never updated.
>>>
>>> On Tuesday, April 9, 2019 at 6:37:04 PM UTC-4, João Matos wrote:
>>>>
>>>> Hello,
>>>>
>>>> The support of MongoDB is still experimental?
>>>>
>>>> Thanks,
>>>>
>>>> JM
>>>>
>>> -- 
>> 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 web...@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: The support of MongoDB is still experimental?

2019-04-09 Thread João Matos
Thanks Anthony. Who can confirm this? Is ti Massimo or is there another 
person in charge of MongoDB in web2py?


terça-feira, 9 de Abril de 2019 às 23:59:36 UTC+1, Anthony escreveu:
>
> I don't think so -- just that the book was never updated.
>
> On Tuesday, April 9, 2019 at 6:37:04 PM UTC-4, João Matos wrote:
>>
>> Hello,
>>
>> The support of MongoDB is still experimental?
>>
>> Thanks,
>>
>> JM
>>
>

-- 
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] The support of MongoDB is still experimental?

2019-04-09 Thread João Matos
Hello,

The support of MongoDB is still experimental?

Thanks,

JM

-- 
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: Apache AliasMatch recommendation from the web2py book is still required?

2019-04-09 Thread João Matos
The Apache access.log always (with and without the AliasMatch) shows
192.168.56.1 - - [09/Apr/2019:23:15:38 +0100] "GET 
/ajc/static/_0.0.0/css/web2py-bootstrap4.css HTTP/1.1" 200 8372
192.168.56.1 - - [09/Apr/2019:23:15:38 +0100] "GET 
/ajc/static/_0.0.0/css/bootstrap.min.css HTTP/1.1" 200 144877
192.168.56.1 - - [09/Apr/2019:23:15:38 +0100] "GET 
/ajc/static/_0.0.0/js/web2py-bootstrap4.js HTTP/1.1" 200 3029
192.168.56.1 - - [09/Apr/2019:23:15:38 +0100] "GET 
/ajc/static/_0.0.0/js/modernizr-2.8.3.min.js HTTP/1.1" 200 15514
192.168.56.1 - - [09/Apr/2019:23:15:38 +0100] "GET 
/ajc/static/_0.0.0/js/bootstrap.bundle.min.js HTTP/1.1" 200 67742
which means that web2py is doing what is supposed to be doing.

Is AliasMatch doing anything?

How can I check that the files are indeed being cached?

-- 
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] Apache AliasMatch recommendation from the web2py book is still required?

2019-04-09 Thread João Matos
Hello,

The web2py book recommends changing (in my case adding) this

  AliasMatch  ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*)  
"C:/web2py/applications/$1/static/$2"

to Apache conf when caching static files with

response.static_version = '0.0.0'
response.static_version_urls = True

However, I don't see any change and everything works with or without the 
AliasMatch.

Is there a way to check if it is still required (or if it is being used) or 
not?


Thanks,

JM

-- 
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: Modules not loading in python 3

2019-04-09 Thread João Matos
Try deleting the modules/*.pyc and modules/__pycache__/*.pyc.

domingo, 7 de Abril de 2019 às 05:18:03 UTC+1, John Bannister escreveu:
>
>
>  Hi all,
>
> I have recently upgraded to python 3.6 from 2.7 running on Centos7 with 
> apache. Problem I am having is as follows:-
> 1: I have a number of apps each of which has a number of modules. Whilst 
> it seems that I can import modules from paython (such as pytz etc) and I 
> can also import modules into controllers/models what I cant seem to be able 
> to do is to import a module into another module.
>
> Example :
>
> I have 2 modules invoices and invoice in modules directory. I can import 
> either or both into a controller but I cannot import invoice module into 
> invoices module.
>
> I have tried using applications.app_name.modules.invoice as well as just 
> invoice (as both are in same directory) but not happening for me. 
>
> I get same standard import error traceback whatever I use. i.e custom 
> import error .. no module "applications.app_name.modules.module_name"  found
>
> Note:- all is working fine in python 2.7
>
> Has anyone come across this issue or does anyone have a solution? I have 
> reverted back to 2.7 for now   
>

-- 
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] "TypeError: sequence of byte string values expected, value of type str found" when accessing admin

2019-04-08 Thread João Matos


When using Apache 2.4 (HTTPS using port 443) with web2py the application 
works fine, but the admin interface always returns and error "Internal 
Server Error".

This only happens if using port 443 (if I change the HTTPS port to eg. 
8000, it all works).

I checked that I don't have any other program/process using port 443.


The Apache error.log shows this

> [Mon Apr 08 00:36:13.551971 2019] [wsgi:error] [pid 4448:tid 924] [client 
> 192.168.1.119:61409] mod_wsgi (pid=4448): Exception occurred processing WSGI 
> script 'C:/web2py/wsgihandler.py'.
> [Mon Apr 08 00:36:13.551971 2019] [wsgi:error] [pid 4448:tid 924] [client 
> 192.168.1.119:61409] TypeError: sequence of byte string values expected, 
> value of type str found\r
>
> I searched for this and found this article
https://stackoverflow.com/questions/34838443/typeerror-sequence-of-byte-string-values-expected-value-of-type-str-found

Apparently this has to do with Python3.
Maybe web2py is sending str instead of bytes to Apache when accessing the 
admin interface?


My env

Windows 7 Pro x64 SP1+all upd
Firefox 66.0.2 x64
Python 3.7.1 x86
web2py 2.18.4
Apache 2.4 (httpd-2.4.39-win32-VC14)
mod_wsgi-4.5.24+ap24vc14-cp37-cp37m-win32.whl


-- 
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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-07 Thread João Matos
Thanks Anthony. Already updated the Github issue and created a post in the 
developers.

domingo, 7 de Abril de 2019 às 20:28:26 UTC+1, Anthony escreveu:
>
> Yes, as noted, that code inverts the sort order for date/time fields when 
> the field is clicked, but there is no inversion when using the orderby 
> argument. I'm not sure why the order is inverted for such fields. Maybe 
> bring it up in the developers group.
>
> On Sunday, April 7, 2019 at 3:19:51 PM UTC-4, João Matos wrote:
>>
>> I think I found the source of the problem.
>> After following the function in the previous message, I arrived at this 
>> code inside the linsert function (line 2779) .
>>
>> exception = sort_field.type in ('date', 'datetime', 
>> 'time')
>> if exception:
>> desc_icon, asc_icon = sorter_icons
>> orderby = (order[:1] == '~' and sort_field) or ~
>> sort_field
>> else:
>> orderby = (order[:1] == '~' and ~sort_field) or 
>> sort_field
>>
>> If I change it to
>>
>> exception = sort_field.type in ('date', 'datetime', 
>> 'time')
>> # if exception:
>> #desc_icon, asc_icon = sorter_icons
>> #orderby = (order[:1] == '~' and sort_field) or 
>> ~sort_field
>> #else:
>> orderby = (order[:1] == '~' and ~sort_field) or 
>> sort_field
>>
>> Now the date sorting works fine.
>>
>> There is also another code segment in line 2641 with the same purpose 
>> that may need the same change, but that segment isn't run with my 
>> application, only the segment at line 2779.
>>
>>
>> domingo, 7 de Abril de 2019 às 19:43:50 UTC+1, João Matos escreveu:
>>>
>>> I think I found the problem (I don't have the solution).
>>>
>>> In gluon\sqlhtml.py there is this function
>>>
>>> def fix_orderby(orderby):
>>> if not auto_pagination:
>>> return orderby
>>> # enforce always an ORDER clause to avoid
>>> # pagination errors. field_id is needed anyhow,
>>> # is unique and usually indexed. See issue #679
>>> if not orderby:
>>> orderby = field_id
>>> elif isinstance(orderby, list):
>>> orderby = reduce(lambda a,b: a|b, orderby)
>>> elif isinstance(orderby, Field) and orderby is not field_id:
>>> print('inside2')
>>> # here we're with an ASC order on a field stored as 
>>> orderby
>>> orderby = orderby | field_id
>>> elif (isinstance(orderby, Expression) and
>>>   orderby.first and orderby.first is not field_id):
>>> print('inside3')
>>> # here we're with a DESC order on a field stored as 
>>> orderby.first
>>> orderby = orderby | field_id
>>> return orderby
>>>
>>> where I added the 2 prints.
>>> A field that works correct shows inside2 on the first run and inside3 on 
>>> the second.
>>> The date field always shows inside2.
>>>
>>> Any ideas?
>>>
>>> Do you use Telegram? There is an online web2py international group. It 
>>> would be great if you and others web2py core devs joined.
>>>
>>>
>>>
>>>
>>> domingo, 7 de Abril de 2019 às 19:22:34 UTC+1, Anthony escreveu:
>>>>
>>>> On Saturday, April 6, 2019 at 3:41:50 PM UTC-4, João Matos wrote:
>>>>>
>>>>> Thanks Anthony. I will open an issue (I still haven't enough know how 
>>>>> to make a PR). I hope some time in the future.
>>>>>
>>>>> I don't want to abuse your help, but I have another issue that is 
>>>>> viewable with the minimal app I sent you.
>>>>> If you create 2 records with different dates, and try to change the 
>>>>> grid's sort order you will notice that the URL changes, the page reloads 
>>>>> but the grid doesn't change.
>>>>> I checked the db stats SQL statements and they stay the same (they 
>>>>> don't change the ORDER).
>>>>> I think there is a bug with the sorting of date columns when they are 
>>>>> the predefined orderby. Can you try it and give me your input.
>>>>>
>>>>
>>>> Definitely a bug -- feel free to report on Github. May have to do with 
>>>> the fact that when clicking to sort, the grid code inverts the order for 
>>>> date/time fields, but does not appear to do so when a date/time field is 
>>>> specified in the orderby argument.
>>>>
>>>> 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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-07 Thread João Matos
I think I found the source of the problem.
After following the function in the previous message, I arrived at this 
code inside the linsert function (line 2779) .

exception = sort_field.type in ('date', 'datetime', 'time')
if exception:
desc_icon, asc_icon = sorter_icons
orderby = (order[:1] == '~' and sort_field) or ~
sort_field
else:
orderby = (order[:1] == '~' and ~sort_field) or 
sort_field

If I change it to

exception = sort_field.type in ('date', 'datetime', 'time')
# if exception:
#desc_icon, asc_icon = sorter_icons
#orderby = (order[:1] == '~' and sort_field) or 
~sort_field
#else:
orderby = (order[:1] == '~' and ~sort_field) or sort_field

Now the date sorting works fine.

There is also another code segment in line 2641 with the same purpose that 
may need the same change, but that segment isn't run with my application, 
only the segment at line 2779.


domingo, 7 de Abril de 2019 às 19:43:50 UTC+1, João Matos escreveu:
>
> I think I found the problem (I don't have the solution).
>
> In gluon\sqlhtml.py there is this function
>
> def fix_orderby(orderby):
> if not auto_pagination:
> return orderby
> # enforce always an ORDER clause to avoid
> # pagination errors. field_id is needed anyhow,
> # is unique and usually indexed. See issue #679
> if not orderby:
> orderby = field_id
> elif isinstance(orderby, list):
> orderby = reduce(lambda a,b: a|b, orderby)
> elif isinstance(orderby, Field) and orderby is not field_id:
> print('inside2')
> # here we're with an ASC order on a field stored as 
> orderby
> orderby = orderby | field_id
> elif (isinstance(orderby, Expression) and
>   orderby.first and orderby.first is not field_id):
> print('inside3')
> # here we're with a DESC order on a field stored as 
> orderby.first
> orderby = orderby | field_id
> return orderby
>
> where I added the 2 prints.
> A field that works correct shows inside2 on the first run and inside3 on 
> the second.
> The date field always shows inside2.
>
> Any ideas?
>
> Do you use Telegram? There is an online web2py international group. It 
> would be great if you and others web2py core devs joined.
>
>
>
>
> domingo, 7 de Abril de 2019 às 19:22:34 UTC+1, Anthony escreveu:
>>
>> On Saturday, April 6, 2019 at 3:41:50 PM UTC-4, João Matos wrote:
>>>
>>> Thanks Anthony. I will open an issue (I still haven't enough know how to 
>>> make a PR). I hope some time in the future.
>>>
>>> I don't want to abuse your help, but I have another issue that is 
>>> viewable with the minimal app I sent you.
>>> If you create 2 records with different dates, and try to change the 
>>> grid's sort order you will notice that the URL changes, the page reloads 
>>> but the grid doesn't change.
>>> I checked the db stats SQL statements and they stay the same (they don't 
>>> change the ORDER).
>>> I think there is a bug with the sorting of date columns when they are 
>>> the predefined orderby. Can you try it and give me your input.
>>>
>>
>> Definitely a bug -- feel free to report on Github. May have to do with 
>> the fact that when clicking to sort, the grid code inverts the order for 
>> date/time fields, but does not appear to do so when a date/time field is 
>> specified in the orderby argument.
>>
>> 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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-07 Thread João Matos
I think I found the problem (I don't have the solution).

In gluon\sqlhtml.py there is this function

def fix_orderby(orderby):
if not auto_pagination:
return orderby
# enforce always an ORDER clause to avoid
# pagination errors. field_id is needed anyhow,
# is unique and usually indexed. See issue #679
if not orderby:
orderby = field_id
elif isinstance(orderby, list):
orderby = reduce(lambda a,b: a|b, orderby)
elif isinstance(orderby, Field) and orderby is not field_id:
print('inside2')
# here we're with an ASC order on a field stored as orderby
orderby = orderby | field_id
elif (isinstance(orderby, Expression) and
  orderby.first and orderby.first is not field_id):
print('inside3')
# here we're with a DESC order on a field stored as 
orderby.first
orderby = orderby | field_id
return orderby

where I added the 2 prints.
A field that works correct shows inside2 on the first run and inside3 on 
the second.
The date field always shows inside2.

Any ideas?

Do you use Telegram? There is an online web2py international group. It 
would be great if you and others web2py core devs joined.




domingo, 7 de Abril de 2019 às 19:22:34 UTC+1, Anthony escreveu:
>
> On Saturday, April 6, 2019 at 3:41:50 PM UTC-4, João Matos wrote:
>>
>> Thanks Anthony. I will open an issue (I still haven't enough know how to 
>> make a PR). I hope some time in the future.
>>
>> I don't want to abuse your help, but I have another issue that is 
>> viewable with the minimal app I sent you.
>> If you create 2 records with different dates, and try to change the 
>> grid's sort order you will notice that the URL changes, the page reloads 
>> but the grid doesn't change.
>> I checked the db stats SQL statements and they stay the same (they don't 
>> change the ORDER).
>> I think there is a bug with the sorting of date columns when they are the 
>> predefined orderby. Can you try it and give me your input.
>>
>
> Definitely a bug -- feel free to report on Github. May have to do with the 
> fact that when clicking to sort, the grid code inverts the order for 
> date/time fields, but does not appear to do so when a date/time field is 
> specified in the orderby argument.
>
> 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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-07 Thread João Matos
Thank you for the feedback Anthony.
That was my thinking but I was hoping to be wrong.

Any idea where in the web2py code is the grid sorting? I would like to take 
a look.


domingo, 7 de Abril de 2019 às 19:22:34 UTC+1, Anthony escreveu:
>
> On Saturday, April 6, 2019 at 3:41:50 PM UTC-4, João Matos wrote:
>>
>> Thanks Anthony. I will open an issue (I still haven't enough know how to 
>> make a PR). I hope some time in the future.
>>
>> I don't want to abuse your help, but I have another issue that is 
>> viewable with the minimal app I sent you.
>> If you create 2 records with different dates, and try to change the 
>> grid's sort order you will notice that the URL changes, the page reloads 
>> but the grid doesn't change.
>> I checked the db stats SQL statements and they stay the same (they don't 
>> change the ORDER).
>> I think there is a bug with the sorting of date columns when they are the 
>> predefined orderby. Can you try it and give me your input.
>>
>
> Definitely a bug -- feel free to report on Github. May have to do with the 
> fact that when clicking to sort, the grid code inverts the order for 
> date/time fields, but does not appear to do so when a date/time field is 
> specified in the orderby argument.
>
> 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] Re: web3py again....

2019-04-07 Thread João Matos
That was the word used by Massimo.
He stated
"In web2py we do not reload the modules. we reimport them at every request. 
this causes a performance penalty and is only needed in development."
My question was if it is possible to disable module reimport at every 
request in production or it just how web2py is built.


domingo, 7 de Abril de 2019 às 18:51:09 UTC+1, Anthony escreveu:
>
> On Sunday, April 7, 2019 at 1:33:22 PM UTC-4, João Matos wrote:
>>
>> @Anthony
>>
>> I was asking about reimport not reload.
>> Does track_changes appy to both?
>>
>
> What do you mean by "reimport"?
>
> 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] Re: web3py again....

2019-04-07 Thread João Matos
@Anthony

I was asking about reimport not reload.
Does track_changes appy to both?


domingo, 7 de Abril de 2019 às 18:30:24 UTC+1, Anthony escreveu:
>
> On Sunday, April 7, 2019 at 1:19:08 PM UTC-4, João Matos wrote:
>>
>> @Massimo
>>
>> You state
>> "In web2py we do not reload the modules. we reimport them at every 
>> request. this causes a performance penalty and is only needed in 
>> development."
>>
>> Does this mean it is possible to disable module reimport at every request 
>> in web2py when in production (or did I misunderstood you)? How?
>>
>
> Unless you have the following in a model file:
>
> from gluon.custom_import import track_changes; track_changes(True)
>
>  
> modules are not reloaded. And even with the above, they are only reloaded 
> if they have changed.
>
> 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] Re: web3py again....

2019-04-07 Thread João Matos
@Massimo

You state
"In web2py we do not reload the modules. we reimport them at every request. 
this causes a performance penalty and is only needed in development."

Does this mean it is possible to disable module reimport at every request 
in web2py when in production (or did I misunderstood you)? How?


-- 
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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-06 Thread João Matos
Thanks Anthony. I will open an issue (I still haven't enough know how to 
make a PR). I hope some time in the future.

I don't want to abuse your help, but I have another issue that is viewable 
with the minimal app I sent you.
If you create 2 records with different dates, and try to change the grid's 
sort order you will notice that the URL changes, the page reloads but the 
grid doesn't change.
I checked the db stats SQL statements and they stay the same (they don't 
change the ORDER).
I think there is a bug with the sorting of date columns when they are the 
predefined orderby. Can you try it and give me your input.

Thanks.


sábado, 6 de Abril de 2019 às 20:35:13 UTC+1, Anthony escreveu:
>
> The problem is unique to the IS_*_IN_RANGE validators, all of which create 
> a translated error message at the time they are instantiated rather than at 
> validation time. For example, here is the init code for IS_INT_IN_RANGE: 
> https://github.com/web2py/pydal/blob/e973f27b69a8499e4e30e5663f3fba74bf87364c/pydal/validators.py#L817
> .
>
> So, you need to set the translation language before defining one of these 
> validators. Note, this has nothing to do with Auth extra_fields, just with 
> the point in the code at which the validators are defined.
>
> I don't see why the error message logic cannot be moved from the __init__ 
> method to the validate method in these range validators, which would push 
> the translation to validation time, as with all the other validators. So, 
> feel free to submit an issue about this in the pydal repo and refer to this 
> post (or better yet, make a pull request).
>
> Anthony
>
> On Saturday, April 6, 2019 at 2:07:16 PM UTC-4, João Matos wrote:
>>
>> The app will start in Portuguese. You can change that by uncommenting the 
>> T.force() in db1.py, but it would be good to do the testing with Portuguese 
>> first to see the problem.
>> After registering, create a new record and in the field ùltimo atribuído 
>> (last_assigned) input -1 which will return a validation error message in 
>> Portuguese (correct behavior).
>> If you go to Perfil (Profile) and to the same to one of the Paginação 
>> (Pagination) fields it will return a validation error message in English 
>> (the pagination fields are the extra_fields).
>> If you comment the T.force() from db1.py and uncomment the T.force() that 
>> is present in db.py before the extra_fields creation and redo the 2 tests, 
>> you will see that both who in Portuguese.
>>
>> I'm unable to add the app file as an attachment. It always returns an 
>> error.
>> So you can find it in WeTransfer in this link
>>
>> https://wetransfer.com/downloads/5d1a0f5303b2a61ee27f64a9ce73ed7c20190406180555/90183abbd7bf1cbaab5ab1011cbdafed20190406180555/81e5a8
>>
>>

-- 
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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-06 Thread João Matos
The app will start in Portuguese. You can change that by uncommenting the 
T.force() in db1.py, but it would be good to do the testing with Portuguese 
first to see the problem.
After registering, create a new record and in the field ùltimo atribuído 
(last_assigned) input -1 which will return a validation error message in 
Portuguese (correct behavior).
If you go to Perfil (Profile) and to the same to one of the Paginação 
(Pagination) fields it will return a validation error message in English 
(the pagination fields are the extra_fields).
If you comment the T.force() from db1.py and uncomment the T.force() that 
is present in db.py before the extra_fields creation and redo the 2 tests, 
you will see that both who in Portuguese.

I'm unable to add the app file as an attachment. It always returns an error.
So you can find it in WeTransfer in this link
https://wetransfer.com/downloads/5d1a0f5303b2a61ee27f64a9ce73ed7c20190406180555/90183abbd7bf1cbaab5ab1011cbdafed20190406180555/81e5a8

-- 
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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-06 Thread João Matos
I created a minimal app and it showed the problem.
I di some further testing and confirmed that there is a relation with the 
positioning of the T.force().
If the T.force() is after the extra_fields creation (which reside in 
db.py), the fields validation messages are always in English, even after 
changing the language (the changing language code resides in db1.py, but 
before the table defs).
If I change the language changing code to before the extra_fields. The 
extra_fields validation messages show up with the correct language.

Do you still want me to send you the minimal app?


sábado, 6 de Abril de 2019 às 17:01:24 UTC+1, Anthony escreveu:
>
> Can you post a minimal app the reproduces the problem?
>
> On Saturday, April 6, 2019 at 4:24:12 AM UTC-4, João Matos wrote:
>>
>> All my grids and forms get auto-translated validation messages correctly. 
>> Here is an example
>>
>> table = db.sn_counter  # type: Table
>>
>> grid = SQLFORM.grid(
>> table,
>> csv=False,
>> details=False,
>> ondelete=on_delete,  # Grid only.
>> onvalidation=on_validation,  # Form only.
>> orderby=db.sn_counter.name,
>> paginate=session.auth.user.pagination,
>> # represent_none='',  # Grid and view form only.
>> sortable=False,
>> )  # type: gluon.DIV
>>
>> which uses this table
>>
>> db.define_table('sn_counter',
>> Field('name', 'string', label=T('Name'), length=NAME_LEN, 
>> notnull=True,
>>   required=True, unique=True),
>> Field('last_assigned', 'integer', default=0, label=T('Last 
>> assigned'),
>>   notnull=True, required=True),
>> Field('canceled_on', 'datetime', label=T('Canceled on'), 
>> writable=False),
>> Field('canceled_by', 'reference auth_user', 
>> label=T('Canceled 
>> by'),
>>   writable=False),
>> Field('cancel_approved_by', 'reference auth_user',
>>   label=T('Cancel approved by'), writable=False),
>> auth.signature,
>> # common_filter = lambda query: db.sn_counter.is_active 
>> == True,
>> format='%(name)s',
>> # plural=T('sn counters'), singular=T('sn counter'),
>> )
>>
>> # db.sn_counter.name.requires = (IS_NOT_EMPTY(), IS_NOT_IN_DB(db, '
>> sn_counter.name'))
>> db.sn_counter.last_assigned.requires = IS_INT_IN_RANGE(0, 10)
>>
>> I give the option to the user to change the language between PT and EN. 
>> Yes, it overrides T.force('pt') with T.force('en') and update sthe page.
>> My original code didn't have a T.force('pt') before the extra_fields and 
>> so all my validation messages appeared correctly in PT or EN, except for 
>> the validation messages of the extra_fields (they always appeared in EN).
>> If I add the T.force('pt') before adding the extra_fields, all my 
>> validation messages appear correctly in PT or EN, but all the extra_fields 
>> validation messages appear only in PT.
>>
>> No, I'm using just one application.
>>
>>
>> sexta-feira, 5 de Abril de 2019 às 23:35:38 UTC+1, Anthony escreveu:
>>>
>>> Hmm, I see that the framework does add the T translator to the Validator 
>>> class, so validation messages should be getting translated. There is 
>>> nothing special about Auth extra_fields -- the validators you add there are 
>>> no different from the validators added to other fields.
>>>
>>> Can you give an example of code using the same validator where the 
>>> message is translated outside of extra_fields but not within extra_fields?
>>>
>>> Also, in your example, you mentioned when setting T.force('pt'), all 
>>> messages came out in Portuguese, even if you "change the language to 
>>> English". What do you mean by "change the language to English" there? 
>>> Setting T.force('pt') should force all translations to Portuguese unless 
>>> you override the T.force('pt').
>>>
>>> Finally, are you running/sending requests to more than one application, 
>>> not all of which have the same translation files?
>>>
>>> Anthony
>>>
>>> On Friday, April 5, 2019 at 2:03:57 PM UTC-4, João Matos wrote:
>>>>
>>>> All my other error messages (from built-in validators) are 
>>>> auto-translated. Including for the default auth_user 

[web2py] Re: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-06 Thread João Matos
All my grids and forms get auto-translated validation messages correctly. 
Here is an example

table = db.sn_counter  # type: Table

grid = SQLFORM.grid(
table,
csv=False,
details=False,
ondelete=on_delete,  # Grid only.
onvalidation=on_validation,  # Form only.
orderby=db.sn_counter.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
sortable=False,
)  # type: gluon.DIV

which uses this table

db.define_table('sn_counter',
Field('name', 'string', label=T('Name'), length=NAME_LEN, 
notnull=True,
  required=True, unique=True),
Field('last_assigned', 'integer', default=0, label=T('Last 
assigned'),
  notnull=True, required=True),
Field('canceled_on', 'datetime', label=T('Canceled on'), 
writable=False),
Field('canceled_by', 'reference auth_user', label=T('Canceled 
by'),
  writable=False),
Field('cancel_approved_by', 'reference auth_user',
  label=T('Cancel approved by'), writable=False),
auth.signature,
# common_filter = lambda query: db.sn_counter.is_active == 
True,
format='%(name)s',
# plural=T('sn counters'), singular=T('sn counter'),
)

# db.sn_counter.name.requires = (IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 
'sn_counter.name'))
db.sn_counter.last_assigned.requires = IS_INT_IN_RANGE(0, 10)

I give the option to the user to change the language between PT and EN. 
Yes, it overrides T.force('pt') with T.force('en') and update sthe page.
My original code didn't have a T.force('pt') before the extra_fields and so 
all my validation messages appeared correctly in PT or EN, except for the 
validation messages of the extra_fields (they always appeared in EN).
If I add the T.force('pt') before adding the extra_fields, all my 
validation messages appear correctly in PT or EN, but all the extra_fields 
validation messages appear only in PT.

No, I'm using just one application.


sexta-feira, 5 de Abril de 2019 às 23:35:38 UTC+1, Anthony escreveu:
>
> Hmm, I see that the framework does add the T translator to the Validator 
> class, so validation messages should be getting translated. There is 
> nothing special about Auth extra_fields -- the validators you add there are 
> no different from the validators added to other fields.
>
> Can you give an example of code using the same validator where the message 
> is translated outside of extra_fields but not within extra_fields?
>
> Also, in your example, you mentioned when setting T.force('pt'), all 
> messages came out in Portuguese, even if you "change the language to 
> English". What do you mean by "change the language to English" there? 
> Setting T.force('pt') should force all translations to Portuguese unless 
> you override the T.force('pt').
>
> Finally, are you running/sending requests to more than one application, 
> not all of which have the same translation files?
>
> Anthony
>
> On Friday, April 5, 2019 at 2:03:57 PM UTC-4, João Matos wrote:
>>
>> All my other error messages (from built-in validators) are 
>> auto-translated. Including for the default auth_user fields (eg. username). 
>> Only the extra_fields are not.
>>
>> Is there a fix?
>>
>>
>> sexta-feira, 5 de Abril de 2019 às 18:56:10 UTC+1, Anthony escreveu:
>>>
>>> Note, this is due to the recent refactoring of all built-in validators 
>>> (moved from web2py to pydal). Previously, all default error messages were 
>>> translated, but that is no longer the case. Although the automatic 
>>> translation was not documented, I would still consider this a break in 
>>> backward compatibility (particularly given that all Auth error messages are 
>>> still being translated automatically).
>>>
>>> Anthony
>>>
>>> On Thursday, April 4, 2019 at 3:25:10 PM UTC-4, João Matos wrote:
>>>>
>>>> When creating extra fields for auth_user, the validation messages for 
>>>> those fields are always in English. They don't comply with the 
>>>> translations 
>>>> available.
>>>>
>>>> This does not happen on the default fields.
>>>>
>>>>
>>>> I added this to db.py
>>>>
>>>>
>>>> auth.settings.extra_fields['auth_user'] = [Field('pagination', 
>>>> 'integer', default=9, label=T('Pagination'), notnull=True, required=
>>>> True, requires=IS_INT_IN_RANGE(5, 51))] 
>>>>
>>>>
>&

[web2py] Re: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-05 Thread João Matos
All my other error messages (from built-in validators) are auto-translated. 
Including for the default auth_user fields (eg. username). Only the 
extra_fields are not.

Is there a fix?


sexta-feira, 5 de Abril de 2019 às 18:56:10 UTC+1, Anthony escreveu:
>
> Note, this is due to the recent refactoring of all built-in validators 
> (moved from web2py to pydal). Previously, all default error messages were 
> translated, but that is no longer the case. Although the automatic 
> translation was not documented, I would still consider this a break in 
> backward compatibility (particularly given that all Auth error messages are 
> still being translated automatically).
>
> Anthony
>
> On Thursday, April 4, 2019 at 3:25:10 PM UTC-4, João Matos wrote:
>>
>> When creating extra fields for auth_user, the validation messages for 
>> those fields are always in English. They don't comply with the translations 
>> available.
>>
>> This does not happen on the default fields.
>>
>>
>> I added this to db.py
>>
>>
>> auth.settings.extra_fields['auth_user'] = [Field('pagination', 'integer', 
>> default=9, label=T('Pagination'), notnull=True, required=True, requires=
>> IS_INT_IN_RANGE(5, 51))] 
>>
>>
>> When inserting an invalid value, the returned message is always
>>
>> Enter an integer between 5 and 50
>>>
>> even when the web2py language is not English and the languages files have 
>> the correct translation available.
>>
>>
>> web2py 2.18.4
>> Python 3.7.1 x86
>> Firefox 66.0.2 x64
>> Windows 7 Pro x64 SP1+all updates
>>
>

-- 
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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-05 Thread João Matos


I have confirmed that it is indeed a bug in web2py.
If I add
T.force('pt')


before

auth.settings.extra_fields['auth_user'] = [ Field('pagination', 'integer', 
default=9, label=T('Pagination'), notnull=True, required=True, requires=
IS_INT_IN_RANGE(5, 51), ), ] 


the validation messages all come out in Portuguese (even if I change the 
language to English).

So the problem is that the code for the extra_fields is not language 
independent.


sexta-feira, 5 de Abril de 2019 às 16:43:35 UTC+1, João Matos escreveu:
>
> No, I think it is a web2py bug. I reported it in Git.
>
> sexta-feira, 5 de Abril de 2019 às 15:57:30 UTC+1, Kevin Keller escreveu:
>>
>> Wow that must be annoying. 
>>
>> Did you find any workaround? 
>>
>> On Thursday, 4 April 2019 21:25:10 UTC+2, João Matos wrote:
>>>
>>> When creating extra fields for auth_user, the validation messages for 
>>> those fields are always in English. They don't comply with the translations 
>>> available.
>>>
>>> This does not happen on the default fields.
>>>
>>>
>>> I added this to db.py
>>>
>>>
>>> auth.settings.extra_fields['auth_user'] = [Field('pagination', 'integer'
>>> , default=9, label=T('Pagination'), notnull=True, required=True, 
>>> requires=IS_INT_IN_RANGE(5, 51))] 
>>>
>>>
>>> When inserting an invalid value, the returned message is always
>>>
>>> Enter an integer between 5 and 50
>>>>
>>> even when the web2py language is not English and the languages files 
>>> have the correct translation available.
>>>
>>>
>>> web2py 2.18.4
>>> Python 3.7.1 x86
>>> Firefox 66.0.2 x64
>>> Windows 7 Pro x64 SP1+all updates
>>>
>>

-- 
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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-05 Thread João Matos
No, I think it is a web2py bug. I reported it in Git.

sexta-feira, 5 de Abril de 2019 às 15:57:30 UTC+1, Kevin Keller escreveu:
>
> Wow that must be annoying. 
>
> Did you find any workaround? 
>
> On Thursday, 4 April 2019 21:25:10 UTC+2, João Matos wrote:
>>
>> When creating extra fields for auth_user, the validation messages for 
>> those fields are always in English. They don't comply with the translations 
>> available.
>>
>> This does not happen on the default fields.
>>
>>
>> I added this to db.py
>>
>>
>> auth.settings.extra_fields['auth_user'] = [Field('pagination', 'integer', 
>> default=9, label=T('Pagination'), notnull=True, required=True, requires=
>> IS_INT_IN_RANGE(5, 51))] 
>>
>>
>> When inserting an invalid value, the returned message is always
>>
>> Enter an integer between 5 and 50
>>>
>> even when the web2py language is not English and the languages files have 
>> the correct translation available.
>>
>>
>> web2py 2.18.4
>> Python 3.7.1 x86
>> Firefox 66.0.2 x64
>> Windows 7 Pro x64 SP1+all updates
>>
>

-- 
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: How to disable _next when auto-logout? Or how do I make it maintain the var _signature?

2019-04-05 Thread João Matos
Found a solution (more a kludge).

Added
next = '/'

to login function in tools.py
Line 2831
# next = replace_id(next, form)
next = '/'
redirect(next, client_side=settings.client_side

quarta-feira, 3 de Abril de 2019 às 15:59:28 UTC+1, João Matos escreveu:
>
> Hello,
>
> How to disable _next when auto-logout occurs? Or how do I make it maintain 
> the var _signature?
>
> I have this problem.
> If a user leaves the application open, for eg. in a record editing page 
> with this URL
>
> http:
> //jmatos-p:8000/client/index/edit/client/2?_signature=b691de6ea83a3e24bb9b7f5324531406b0a6643a
>
> and the expiration time occurs, the user is logged out and shown this URL
>
> http://jmatos-p:8000/user/login?_next=/client/index/edit/client/2
>
> where web2py removed the var _signature.
>
>
> When the user logs in he receives an "Not authorized" error message 
> (session.flash) and gets redirected to URL
>
> http:
> //jmatos-p:8000/client?_signature=6b1c6d06db156eaca5aa5ecf51bf2351a97e3d53
>
> which is the parent of the original URL.
>
> I had a solution I found while searching this forum, which was to add
>
> request.vars._next = None
>
> before the auth declaration in the db.py file.
>
> That worked until I used a language changing solution given to me on 
> another topic, which is this
> db1.py file
> LANGUAGES = ('pt', 'en')
>
>
> def set_language():
> # type: () -> str
> """Set language.
>
> https://groups.google.com/forum/#!topic/web2py/6ceuUoISWGU
>
> :return: Language code.
> """
> lang_code = session.lang or 'pt'  # T.accepted_language[:2]
> if lang_code in LANGUAGES:
> T.force(lang_code)
> return lang_code
> else:
> T.force('pt')
> return 'pt'
>
>
> LANG = set_language()
>
>
> and in the block footer section of layout.html
>   
>  href="{{=URL('default', 
> 'language', args='pt', vars={'_next':URL(args=request.args, 
> vars=request.vars, user_signature=True)})}}">PT
>  href="{{=URL('default', 
> 'language', args='en', vars={'_next':URL(args=request.args, 
> vars=request.vars, user_signature=True)})}}">EN
>   
>
> Is there any way to disable the _next without using the above 
> request.vars._next = None ?
> Is there any way the _next could maintain the original var _signature?
> Any other ideas on how to solve this?
>
> Thanks,
>
> JM
>
>

-- 
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] Validation messages of extra fields in auth_user don't comply with available translations

2019-04-04 Thread João Matos


When creating extra fields for auth_user, the validation messages for those 
fields are always in English. They don't comply with the translations 
available.

This does not happen on the default fields.


I added this to db.py


auth.settings.extra_fields['auth_user'] = [Field('pagination', 'integer', 
default=9, label=T('Pagination'), notnull=True, required=True, requires=
IS_INT_IN_RANGE(5, 51))] 


When inserting an invalid value, the returned message is always

Enter an integer between 5 and 50
>
even when the web2py language is not English and the languages files have 
the correct translation available.


web2py 2.18.4
Python 3.7.1 x86
Firefox 66.0.2 x64
Windows 7 Pro x64 SP1+all updates

-- 
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: Is it possible to sort the grid search fields list?

2019-04-03 Thread João Matos
Found a solution.

In the controller, after grid creation:
# Sort grid's search fields list.
grid.element('#w2p_query_fields').components = 
sort_grid_search_fields_list(grid)


In a modules file
def sort_grid_search_fields_list(grid):
# type: (grid: gluon.DIV) -> List[gluon.OPTION]
"""Sort grid's search fields list.

:param grid: Grid.
:return: Sorted search fields list (HTML options).
"""
keys = []  # type: List[str]
elements = {}  # type: Dict[str, str]
for element in grid.element('#w2p_query_fields').components:  # type: 
gluon.OPTION
keys.append(element.flatten())
elements[element.flatten()] = element['_value']
keys.sort(key=str.lower)
return [gluon.OPTION(key, _value=elements[key]) for key in keys]


quarta-feira, 13 de Março de 2019 às 10:16:11 UTC, Leonel Câmara escreveu:
>
> No, not right now it isn't. What's possible is to make your own 
> search_widget which could do the sorting of the search fields.
>

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


  1   2   3   >