[web2py] Re: Thank you Web2py community - I have completed a live application, ViewBase.com, using Web2py

2019-04-06 Thread Massimo Di Pierro
Congratulations William

On Friday, 5 April 2019 09:44:56 UTC-7, William wrote:
>
> Just writing to thank Massimo and the Web2py community, for answering all 
> my questions here and also building this awesome framework. 
>
> I'm proud to say my application, https://www.viewbase.com, is live! I was 
> a total beginner and literally learnt everything about web development 
> while building this project. I was and still am amazed by how user-friendly 
> and well thought out this web framework is. 
>
> Cheers to the community and I hope to give back to the community if I 
> achieve success. Thanks again guys. 
>
> Regards,
> William
>

-- 
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: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-06 Thread Massimo Di Pierro
we will fix the backward incompatibility asap. Not intentional.

On Saturday, 6 April 2019 12:12:47 UTC-7, David Manns wrote:
>
> PS this is not backward compatible to 2.17.2
>
> On Thursday, April 4, 2019 at 4:52:37 PM UTC-4, David Manns wrote:
>>
>> The table in question has a field:
>>
>> Field('Paiddate', 'date', requires = [IS_EMPTY_OR(IS_DATE()), 
>> IS_EMPTY_OR(IS_MEMBERSHIP_YEAR_END())]),
>>
>> The custom validator is:
>>
>> class IS_MEMBERSHIP_YEAR_END(object):
>> def __init__(self, error_message='Not a membership year end'):
>> self.error_message = error_message
>> def __call__(self, value):
>> yearend = datetime.date(2018,9,30)
>> if value.month==yearend.month and value.day==yearend.day:
>> return (value, None)
>> return (value, self.error_message)
>>
>> This works in 2.17.2
>>
>> I updated my test environment to 2.18.4 and it fails.
>>
>> On the console I see:
>>
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2019
>> Version 2.18.4-stable+timestamp.2019.03.13.05.27.54
>> Database drivers available: sqlite3, imaplib, pyodbc, pymysql
>> please visit:
>> ('\t', 'http://127.0.0.1:8000/')
>> starting browser...
>> Traceback (most recent call last):
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 1890, in _validate
>> (value, errors) = validator(value)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 144, in 
>> __call__
>> return self.validate(value), None
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 2754, in 
>> validate
>> return self.other.validate(value)
>> AttributeError: 'IS_MEMBERSHIP_YEAR_END' object has no attribute 
>> 'validate'
>>
>> The ticket shows:
>>
>> Error ticket for "init" Ticket ID 
>>
>> 127.0.0.1.2019-04-04.16-41-08.0dce185d-d8d2-4d36-9e47-8c82bc1d54f5
>>  Validation error, field:Paiddate 
>>  Version 
>> web2py™ Version 2.18.4-stable+timestamp.2019.03.13.05.27.54 
>> Python Python 2.7.14: C:\Python27\python.exe (prefix: C:\Python27) 
>> Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>> 27.
>> 28.
>> 29.
>> 30.
>>
>> Traceback (most recent call last):
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\restricted.py", line 219, in restricted
>> exec(ccode, environment)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 1747, in 
>> 
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\globals.py", line 421, in 
>> self._caller = lambda f: f()
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\applications\init\models\db.py", line 109, in wrapped_f
>> return f(*args)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 214, in 
>> memberform
>> deletable = dltbl, onvalidation=setmodified, onaccept=modmember, 
>> ondelete=delmember)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\tools.py", line 4322, in update
>> detect_record_change=self.settings.detect_record_change):
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\sqlhtml.py", line 1758, in accepts
>> **kwargs
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 2149, in accepts
>> status = self._traverse(status, hideerror)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
>> newstatus = c._traverse(status, hideerror) and newstatus
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
>> newstatus = c._traverse(status, hideerror) and newstatus
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
>> newstatus = c._traverse(status, hideerror) and newstatus
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
>> newstatus = c._traverse(status, hideerror) and newstatus
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 917, in _traverse
>> newstatus = self._validate()
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 1895, in _validate
>> raise Exception(msg)
>> Exception: Validation error, field:Paiddate > object at 0x04878048>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book 

Re: [web2py] Re: web3py again....

2019-04-06 Thread Massimo Di Pierro
I like bottle because it is simpler than flask. Can you make a good case 
for why Flask over bottle?

On Tuesday, 2 April 2019 00:56:31 UTC-7, Kevin Keller wrote:
>
> Here is a project that generates swagger(openapi) documentation for 
> flask+sqlalchemy.  https://github.com/thomaxxl/safrs
> I was already wondering about changing bottle with flask, but I dont know 
> if that is heresy now :). 
>
> On Tue, Apr 2, 2019 at 9:31 AM Kevin Keller  wrote:
>
>>
>> https://editor.swagger.io/?_ga=2.227432986.689200959.1554189909-55439989.1547630410
>>  
>>
>> Swagger JSON editor + https://swagger.io/specification/. So one Swagger 
>> Json file can contain the description of all the endpoints. 
>>
>> On Tue, Apr 2, 2019 at 9:19 AM Kevin Keller  wrote:
>>
>>> I agree. 
>>>
>>> In fact, the whole client side today should be Javascript and just 
>>> communicate via REST+JWT (even though in the enerprise space you will also 
>>> need OAUTH2). 
>>>
>>>  The models need to be exposed via REST easiliy and it should be easy to 
>>> add auth to routes with JWT. Also the REST endpoints once defined, need to 
>>> generate openapi(swagger) documents automatically. 
>>>
>>> This is much like the JSON route you wanted to go, but with openapi we 
>>> would be using an actual standard and do not tie ourselves to one 
>>> Javascript framework and once specific JSON format. 
>>>
>>>  With that we could use something like this: 
>>> https://api-platform.com/docs/client-generator/ that generates Vue.js 
>>> or React.js CRUD pages basted on teh openapi documentation for the REST 
>>> endpoints. 
>>>
>>> On Tue, Apr 2, 2019 at 8:58 AM Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 Th problem with SQLFORM is that different CSS libraries require 
 different HTML stuctures. It is not as simple as selecting a class or div 
 vs span. In web2py we have code to deal with bootstrap 2 and 3. We apply 
 both classes. It is horrible. We should move away from generating html 
 server side for forms. We should pass a json description and generate it 
 client side

 On Sunday, 31 March 2019 00:54:23 UTC-7, 黄祥 wrote:
>
> Backporting SQLFORM, grid and Auth, should not be that complicated, 
>> although I think we can do better.
>>
>
> sqlform, grid and auth is a great helper to make web2py as rapid 
> application development, but please consider some of users who want to 
> use 
> another css or js framework.
> perhaps just follow the python principle 'Explicit is better than 
> implicit', something like
> sqlform(), sqlform.grid() or form() signature have style='bootstrap', 
> or class='something' or tag='div|span|table|tr|td'
> not sure just an idea
> perhaps can stick with the initial idea
> ref:
> https://groups.google.com/forum/#!msg/web2py/89a846kPeGA/nUpNJB_VCAAJ
>
> 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 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>

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


Re: [web2py] Re: Why python anywhere stuck with web2py 2.15 version

2019-04-06 Thread Massimo Di Pierro
I think web2py is predicated on backward compatibility. If they switch 
legacy apps will no longer work and that is bad. Instead we should push 
web2py for py2 and web3py for python 3. That will eliminate confusion and 
will allow to fix our mistakes and move into the future.

Massimo

On Monday, 1 April 2019 23:51:36 UTC-7, Nico Zanferrari wrote:
>
> I think it's also time to switch to Python 3, at least as an option ;-)
>
> Nico
>
> Il giorno mar 2 apr 2019 alle ore 08:35 Massimo Di Pierro <
> massimo.dipie...@gmail.com> ha scritto:
>
>> I will talk to them. Maybe we can agree on a newer version. They do not 
>> have to change every single version but maybe every 3 months we can label a 
>> special version for deployment.
>>
>> On Monday, 1 April 2019 18:01:09 UTC-7, Ron Chatterjee wrote:
>>>
>>> I did. They said its lot of work to change from 2.14 to any newer 
>>> version and they don't have time.
>>>
>>>
>>>
>>> On Monday, April 1, 2019 at 7:27:23 PM UTC-4, Scott Hunter wrote:

 Shouldn't you ask them?

 On Monday, April 1, 2019 at 8:57:21 AM UTC-4, Ron Chatterjee wrote:
>
> Does anyone know why python anywhere only give option for 2.15 edition 
> of web2py? If I have to guess that's few years old. I asked the question 
> because I am not sure if they believe 2.15 is more stable for 2.18. Is 
> any 
> reason they use an older version of web2py?
>
 -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[web2py] concurrent queries to restful service response time issue

2019-04-06 Thread Metra Oknehcvark


Hello , All!

Hope someone can point me to right direction.

I have restfull service , with a simple def like :

...

u = storage.executesql('UPDATE mitms SET ls = "' + str(f) + '"  WHERE ls = "N" 
LIMIT 1;')

...

s = storage(mw.ls == f).select(mw.iIdL).first()

...

return response.json({})

u and s query run as expected: like for 0.001-0.005s

and everything is good when i make single queries from app.


but when i run concurrent queries (like few hundreds++ threads), while 
3-5min , i get:

u run same like 0.001-0.005.


but full call from app take like 5 to 50seconds, app just query links to 
download:

request link xxx request_time 23.19139289855957

request link xxx request_time 23.306612014770508

request link xxx request_time 23.088869094848633

request link xxx request_time 23.109781980514526

request link xxx request_time 22.863523244857788


In app i use requests py module ,simple get request. 

Db and app local  for now.

Thx in advance!

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

2019-04-06 Thread John Bannister

 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] Re: pycharm "No python interpreter selected"

2019-04-06 Thread Alex Glaros
my understanding is that it is looking for a file name python.exe but the 
binary version of windows web2py does not have that file. Do I just point 
to the gluon directory?

-- 
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: pycharm "No python interpreter selected"

2019-04-06 Thread 黄祥
pls check it out
https://geek-university.com/python/add-python-to-the-windows-path/

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


[web2py] Re: pycharm "No python interpreter selected"

2019-04-06 Thread Alex Glaros
I see this attached. What value am I supposed to specify?


-- 
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: pycharm "No python interpreter selected"

2019-04-06 Thread 黄祥
WindowsWindows 10 and Windows 8
   
   1. In Search, search for and then select: System (Control Panel)
   2. Click the *Advanced system settings* link.
   3. Click *Environment Variables*. In the section *System Variables*, 
   find the PATH environment variable and select it. Click *Edit*. If the 
   PATH environment variable does not exist, click New.
   4. In the *Edit System Variable* (or *New System Variable*) window, 
   specify the value of the PATHenvironment variable. Click *OK*. Close all 
   remaining windows by clicking *OK*.
   5. Reopen Command prompt window, and run your python code.

Windows 7
   
   1. From the desktop, right click the *Computer* icon.
   2. Choose *Properties* from the context menu.
   3. Click the *Advanced system settings* link.
   4. Click *Environment Variables*. In the section *System Variables*, 
   find the PATH environment variable and select it. Click *Edit*. If the 
   PATH environment variable does not exist, click New.
   5. In the *Edit System Variable* (or *New System Variable*) window, 
   specify the value of the PATHenvironment variable. Click *OK*. Close all 
   remaining windows by clicking *OK*.
   6. Reopen Command prompt window, and run your python code.

Windows Vista
   
   1. From the desktop, right click the *My Computer* icon.
   2. Choose *Properties* from the context menu.
   3. Click the *Advanced* tab (*Advanced system settings* link in Vista).
   4. Click *Environment Variables*. In the section *System Variables*, 
   find the PATH environment variable and select it. Click *Edit*. If the 
   PATH environment variable does not exist, click New.
   5. In the *Edit System Variable* (or *New System Variable*) window, 
   specify the value of the PATHenvironment variable. Click *OK*. Close all 
   remaining windows by clicking *OK*.
   6. Reopen Command prompt window, and run your python code.

Windows XP
   
   1. Select *Start*, select *Control Panel*. double click *System*, and 
   select the *Advanced* tab.
   2. Click *Environment Variables*. In the section *System Variables*, 
   find the PATH environment variable and select it. Click *Edit*. If the 
   PATH environment variable does not exist, click New.
   3. In the *Edit System Variable* (or *New System Variable*) window, 
   specify the value of the PATHenvironment variable. Click *OK*. Close all 
   remaining windows by clicking *OK*.
   4. Reopen Command prompt window, and run your python 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)
--- 
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] Recursive table relation

2019-04-06 Thread Carlos Cesar Caballero Díaz

That's a typo :)

El 6/4/19 a las 8:24 p.m., Leonel Câmara escribió:

Possibly because you have require instead of requires?



--
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] Recursive table relation

2019-04-06 Thread Leonel Câmara
Possibly because you have require instead of requires?

-- 
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: pycharm "No python interpreter selected"

2019-04-06 Thread Alex Glaros
same question with Wing IDE, what do I enter for python path?

-- 
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] Recursive table relation

2019-04-06 Thread Carlos Cesar Caballero Díaz

Hi, I have this table definition:

db.define_table('organization',
    Field('name', 'string', require=[IS_ALPHANUMERIC(), IS_NOT_EMPTY(), 
IS_NOT_IN_DB(db, 'organization.name')], label=T('Name')),

    Field('description', 'text', label=T('Description')),
    Field('parent', 'reference organization', label=T('Parent 
Organization')),

    format='%(name)s' )

As you can see, an organization can include a parent organization.

My issue is that the generated create/edit form is not including the 
select for choosing the parent organization, any Idea about this?


Greetings.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Thank you Web2py community - I have completed a live application, ViewBase.com, using Web2py

2019-04-06 Thread William
Thank you! I have learnt lots from this project. 

-- 
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: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-06 Thread Anthony
The book should be update, but we should also decide if we're OK breaking 
backward compatibility in this way.

Anthony

On Saturday, April 6, 2019 at 3:06:20 PM UTC-4, David Manns wrote:
>
> Changed my import to:
>
> from pydal.validators import Validator, ValidationError
>
> class IS_MEMBERSHIP_YEAR_END(Validator):
> def __init__(self, error_message='Not a membership year end'):
> self.error_message = error_message
> def validate(self, value):
> yearend =  datetime.date(2018,9,30)
> if value.month==yearend.month and value.day==yearend.day:
> return value
> else:
> raise ValidationError(self.translator(self.error_message))
>
> Now works with 2.18.4, thank you!
>
> The 'book' needs to be updated!
>
> On Thursday, April 4, 2019 at 4:52:37 PM UTC-4, David Manns wrote:
>>
>> The table in question has a field:
>>
>> Field('Paiddate', 'date', requires = [IS_EMPTY_OR(IS_DATE()), 
>> IS_EMPTY_OR(IS_MEMBERSHIP_YEAR_END())]),
>>
>> The custom validator is:
>>
>> class IS_MEMBERSHIP_YEAR_END(object):
>> def __init__(self, error_message='Not a membership year end'):
>> self.error_message = error_message
>> def __call__(self, value):
>> yearend = datetime.date(2018,9,30)
>> if value.month==yearend.month and value.day==yearend.day:
>> return (value, None)
>> return (value, self.error_message)
>>
>> This works in 2.17.2
>>
>> I updated my test environment to 2.18.4 and it fails.
>>
>> On the console I see:
>>
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2019
>> Version 2.18.4-stable+timestamp.2019.03.13.05.27.54
>> Database drivers available: sqlite3, imaplib, pyodbc, pymysql
>> please visit:
>> ('\t', 'http://127.0.0.1:8000/')
>> starting browser...
>> Traceback (most recent call last):
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 1890, in _validate
>> (value, errors) = validator(value)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 144, in 
>> __call__
>> return self.validate(value), None
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 2754, in 
>> validate
>> return self.other.validate(value)
>> AttributeError: 'IS_MEMBERSHIP_YEAR_END' object has no attribute 
>> 'validate'
>>
>> The ticket shows:
>>
>> Error ticket for "init" Ticket ID 
>>
>> 127.0.0.1.2019-04-04.16-41-08.0dce185d-d8d2-4d36-9e47-8c82bc1d54f5
>>  Validation error, field:Paiddate 
>>  Version 
>> web2py™ Version 2.18.4-stable+timestamp.2019.03.13.05.27.54 
>> Python Python 2.7.14: C:\Python27\python.exe (prefix: C:\Python27) 
>> Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>> 27.
>> 28.
>> 29.
>> 30.
>>
>> Traceback (most recent call last):
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\restricted.py", line 219, in restricted
>> exec(ccode, environment)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 1747, in 
>> 
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\globals.py", line 421, in 
>> self._caller = lambda f: f()
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\applications\init\models\db.py", line 109, in wrapped_f
>> return f(*args)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 214, in 
>> memberform
>> deletable = dltbl, onvalidation=setmodified, onaccept=modmember, 
>> ondelete=delmember)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\tools.py", line 4322, in update
>> detect_record_change=self.settings.detect_record_change):
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\sqlhtml.py", line 1758, in accepts
>> **kwargs
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 2149, in accepts
>> status = self._traverse(status, hideerror)
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
>> newstatus = c._traverse(status, hideerror) and newstatus
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
>> newstatus = c._traverse(status, hideerror) and newstatus
>>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
>> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
>> newstatus = c._traverse(status, hideerror) and newstatus
>>   File "C:\Users\David\Google Drive\Oxcamne 

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

2019-04-06 Thread Anthony
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] pycharm "No python interpreter selected"

2019-04-06 Thread Alex Glaros
I have community version of pycharm and windows 10 binary version of web2py.

Pycharm: "No python interpreter selected" 

How to resolve this?

thanks

Alex Glaros

-- 
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: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-06 Thread David Manns
PS this is not backward compatible to 2.17.2

On Thursday, April 4, 2019 at 4:52:37 PM UTC-4, David Manns wrote:
>
> The table in question has a field:
>
> Field('Paiddate', 'date', requires = [IS_EMPTY_OR(IS_DATE()), 
> IS_EMPTY_OR(IS_MEMBERSHIP_YEAR_END())]),
>
> The custom validator is:
>
> class IS_MEMBERSHIP_YEAR_END(object):
> def __init__(self, error_message='Not a membership year end'):
> self.error_message = error_message
> def __call__(self, value):
> yearend = datetime.date(2018,9,30)
> if value.month==yearend.month and value.day==yearend.day:
> return (value, None)
> return (value, self.error_message)
>
> This works in 2.17.2
>
> I updated my test environment to 2.18.4 and it fails.
>
> On the console I see:
>
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2019
> Version 2.18.4-stable+timestamp.2019.03.13.05.27.54
> Database drivers available: sqlite3, imaplib, pyodbc, pymysql
> please visit:
> ('\t', 'http://127.0.0.1:8000/')
> starting browser...
> Traceback (most recent call last):
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 1890, in _validate
> (value, errors) = validator(value)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 144, in 
> __call__
> return self.validate(value), None
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 2754, in 
> validate
> return self.other.validate(value)
> AttributeError: 'IS_MEMBERSHIP_YEAR_END' object has no attribute 'validate'
>
> The ticket shows:
>
> Error ticket for "init" Ticket ID 
>
> 127.0.0.1.2019-04-04.16-41-08.0dce185d-d8d2-4d36-9e47-8c82bc1d54f5
>  Validation error, field:Paiddate 
>  Version 
> web2py™ Version 2.18.4-stable+timestamp.2019.03.13.05.27.54 
> Python Python 2.7.14: C:\Python27\python.exe (prefix: C:\Python27) 
> Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
> 29.
> 30.
>
> Traceback (most recent call last):
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 1747, in 
> 
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\applications\init\models\db.py", line 109, in wrapped_f
> return f(*args)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 214, in 
> memberform
> deletable = dltbl, onvalidation=setmodified, onaccept=modmember, 
> ondelete=delmember)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\tools.py", line 4322, in update
> detect_record_change=self.settings.detect_record_change):
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\sqlhtml.py", line 1758, in accepts
> **kwargs
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 2149, in accepts
> status = self._traverse(status, hideerror)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 917, in _traverse
> newstatus = self._validate()
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 1895, in _validate
> raise Exception(msg)
> Exception: Validation error, field:Paiddate  object at 0x04878048>
>
>

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

[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-06 Thread David Manns
Changed my import to:

from pydal.validators import Validator, ValidationError

class IS_MEMBERSHIP_YEAR_END(Validator):
def __init__(self, error_message='Not a membership year end'):
self.error_message = error_message
def validate(self, value):
yearend =  datetime.date(2018,9,30)
if value.month==yearend.month and value.day==yearend.day:
return value
else:
raise ValidationError(self.translator(self.error_message))

Now works with 2.18.4, thank you!

The 'book' needs to be updated!

On Thursday, April 4, 2019 at 4:52:37 PM UTC-4, David Manns wrote:
>
> The table in question has a field:
>
> Field('Paiddate', 'date', requires = [IS_EMPTY_OR(IS_DATE()), 
> IS_EMPTY_OR(IS_MEMBERSHIP_YEAR_END())]),
>
> The custom validator is:
>
> class IS_MEMBERSHIP_YEAR_END(object):
> def __init__(self, error_message='Not a membership year end'):
> self.error_message = error_message
> def __call__(self, value):
> yearend = datetime.date(2018,9,30)
> if value.month==yearend.month and value.day==yearend.day:
> return (value, None)
> return (value, self.error_message)
>
> This works in 2.17.2
>
> I updated my test environment to 2.18.4 and it fails.
>
> On the console I see:
>
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2019
> Version 2.18.4-stable+timestamp.2019.03.13.05.27.54
> Database drivers available: sqlite3, imaplib, pyodbc, pymysql
> please visit:
> ('\t', 'http://127.0.0.1:8000/')
> starting browser...
> Traceback (most recent call last):
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 1890, in _validate
> (value, errors) = validator(value)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 144, in 
> __call__
> return self.validate(value), None
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 2754, in 
> validate
> return self.other.validate(value)
> AttributeError: 'IS_MEMBERSHIP_YEAR_END' object has no attribute 'validate'
>
> The ticket shows:
>
> Error ticket for "init" Ticket ID 
>
> 127.0.0.1.2019-04-04.16-41-08.0dce185d-d8d2-4d36-9e47-8c82bc1d54f5
>  Validation error, field:Paiddate 
>  Version 
> web2py™ Version 2.18.4-stable+timestamp.2019.03.13.05.27.54 
> Python Python 2.7.14: C:\Python27\python.exe (prefix: C:\Python27) 
> Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
> 29.
> 30.
>
> Traceback (most recent call last):
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 1747, in 
> 
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\applications\init\models\db.py", line 109, in wrapped_f
> return f(*args)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\applications\init\controllers/default.py", line 214, in 
> memberform
> deletable = dltbl, onvalidation=setmodified, onaccept=modmember, 
> ondelete=delmember)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\tools.py", line 4322, in update
> detect_record_change=self.settings.detect_record_change):
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\sqlhtml.py", line 1758, in accepts
> **kwargs
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 2149, in accepts
> status = self._traverse(status, hideerror)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
> newstatus = c._traverse(status, hideerror) and newstatus
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 917, in _traverse
> newstatus = self._validate()
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> 

[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-06 Thread Leonel Câmara
Did you import ValidationError as well?

-- 
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: CSS button alignment

2019-04-06 Thread 'Annet' via web2py-users
I think Bootstrap's float-right and float-left will solve this issue.

https://getbootstrap.com/docs/4.1/utilities/float/

-- 
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: Using the results of a variable returned by one function in another function

2019-04-06 Thread mostwanted
Using a session on the application in computer the one i haven't uploaded 
online works very well, it gives me the results i want but when i make 
similar updates to my online application i get an error message:
* 'NoneType' object has no attribute 'id'*
 I dont know what the problem is! Am i missing something?? Should i make a 
session declaration of some sort or is there an import i am not making???!

I have highlited where i used the session in the code below.

*CONTROLLERS*
def companies():
*session.resultsARE=db.services(request.args(0))* 
rslts=db(db.business.services==session.resultsARE.id).select(db.business
.ALL, orderby=db.business.company_name)
services=len(rslts)
form=SQLFORM.factory(Field('query', requires=IS_NOT_EMPTY(), label=SPAN(
'', _style="font-weight: bold;"), widget = lambda field, value: SQLFORM.
widgets.string.widget(field, value, _class='my-string', _id='searching', 
_placeholder='LOCATION')))
#hiding the submit button
searchBtn=form.element('input',_type='submit')
searchBtn['_style'] = 'display:none;'
if form.accepts(request):
tokens=form.vars.query.split()
query=reduce(lambda a,b:a, [db.locations.name.contains(k) for k in 
tokens])
location=db(query).select(orderby=db.locations.name)
else:
location=[]
return locals()

def Results():
results=db.locations(request.args(0))
#GET LOCATION & SERVICES FOR RESULTS
*rslts=db((db.business.place==results.id) & 
(db.business.services==session.resultsARE.id)).select()*

#rslts=db(db.business.place==results.id).select(db.business.services==serv)
services=len(rslts)
form=SQLFORM.factory(Field('query', requires=IS_NOT_EMPTY(), label=SPAN(
'', _style="font-weight: bold;"), widget = lambda field, value: SQLFORM.
widgets.string.widget(field, value, _class='my-string', _id='searching', 
_placeholder='LOCATION')))
#hiding the submit button
searchBtn=form.element('input',_type='submit')
searchBtn['_style'] = 'display:none;'
if form.accepts(request):
tokens=form.vars.query.split()
query=reduce(lambda a,b:a, [db.locations.name.contains(k) for k in 
tokens])
location=db(query).select(orderby=db.locations.name)
else:
location=[]
return locals()


Mostwanted


On Wednesday, March 27, 2019 at 9:17:34 PM UTC+2, Ben Duncan wrote:
>
> Could you not use:
>
> *session.resultsARE= *
> *to save it an reuse it and pass during the whole session ?*
>
> *Ben Duncan*
> DBA / Chief Software Architect 
> Mississippi State Supreme Court
> Electronic Filing Division
>
>
> On Wed, Mar 27, 2019 at 1:42 PM Anthony > 
> wrote:
>
>> It's not quite clear what you mean. Are these two functions two separate 
>> controller actions? If so, it's not clear how you can share that variable, 
>> as it is defined based on request.args(0) in the first function, but 
>> presumably request.args(0) has a different meaning in the context of the 
>> second function. What are you really trying to do?
>>
>> On Wednesday, March 27, 2019 at 8:11:15 AM UTC-4, mostwanted wrote:
>>>
>>> I have 2 functions and i want to use the value of the variable returned 
>>> by one function in another function, how can i achieve this?
>>> I want to use the value of *resultsARE *in *function1 *in the same way 
>>> in *function2 *as attempted in the highlighted lines below.
>>>
>>> *FUNCTION1*
>>> def companies():
>>> *resultsARE=db.services(request.args(0))*
>>> rslts=db(db.business.services==resultsARE.id).select(db.business.ALL
>>> , orderby=db.business.company_name)
>>> services=len(rslts)
>>> return locals()
>>>
>>> *FUNCTION2*
>>> def Results():
>>> results=db.locations(request.args(0))
>>> comps=companies()
>>> for services in comps:
>>> serv=services
>>> rslts=db(db.business.place==results.id).select
>>> *(db.business.services==resultsARE.id)*
>>> services=len(rslts)
>>> return locals()
>>> Mostwanted
>>>
>>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to 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: Validation messages of extra fields in auth_user don't comply with available translations

2019-04-06 Thread Anthony
Yes, post the app.

On Saturday, April 6, 2019 at 12:49:15 PM UTC-4, João Matos wrote:
>
> 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 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 

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

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

2019-04-06 Thread Anthony
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 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 

[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-06 Thread David Manns
The web2py book needs to be updated, as Anthony points out.

As suggested I changed the validator to:

class IS_MEMBERSHIP_YEAR_END(Validator):
def __init__(self, error_message='Not a membership year end'):
self.error_message = error_message
def validate(self, value):
yearend = datetime.date(2018,9,30)
if value.month==yearend.month and value.day==yearend.day:
return value
else:
raise ValidationError(self.translator(self.error_message))

Also added to the model:

from gluon.validators import Validator

If the entered value was a valid date that passed the test (9/30/) all 
was well. However the failure path produced a ticket, it looks as if the 
raised error is not being caught


Ticket ID 

127.0.0.1.2019-04-06.09-16-04.3787fce5-0056-4df3-9918-be34e83041be
 Validation error, field:Paiddate 
 Version 
web2py™ Version 2.18.4-stable+timestamp.2019.03.13.05.27.54 
Python Python 2.7.14: C:\Python27\python.exe (prefix: C:\Python27) Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.

Traceback (most recent call last):
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\applications\init\controllers/default.py", line 1747, in 

  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\globals.py", line 421, in 
self._caller = lambda f: f()
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\applications\init\models\db.py", line 110, in wrapped_f
return f(*args)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\applications\init\controllers/default.py", line 214, in 
memberform
deletable = dltbl, onvalidation=setmodified, onaccept=modmember, 
ondelete=delmember)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\tools.py", line 4322, in update
detect_record_change=self.settings.detect_record_change):
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\sqlhtml.py", line 1758, in accepts
**kwargs
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\html.py", line 2149, in accepts
status = self._traverse(status, hideerror)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\html.py", line 917, in _traverse
newstatus = self._validate()
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.2\gluon\html.py", line 1895, in _validate
raise Exception(msg)
Exception: Validation error, field:Paiddate 


On Thursday, April 4, 2019 at 4:52:37 PM UTC-4, David Manns wrote:
>
> The table in question has a field:
>
> Field('Paiddate', 'date', requires = [IS_EMPTY_OR(IS_DATE()), 
> IS_EMPTY_OR(IS_MEMBERSHIP_YEAR_END())]),
>
> The custom validator is:
>
> class IS_MEMBERSHIP_YEAR_END(object):
> def __init__(self, error_message='Not a membership year end'):
> self.error_message = error_message
> def __call__(self, value):
> yearend = datetime.date(2018,9,30)
> if value.month==yearend.month and value.day==yearend.day:
> return (value, None)
> return (value, self.error_message)
>
> This works in 2.17.2
>
> I updated my test environment to 2.18.4 and it fails.
>
> On the console I see:
>
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2019
> Version 2.18.4-stable+timestamp.2019.03.13.05.27.54
> Database drivers available: sqlite3, imaplib, pyodbc, pymysql
> please visit:
> ('\t', 'http://127.0.0.1:8000/')
> starting browser...
> Traceback (most recent call last):
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\html.py", line 1890, in _validate
> (value, errors) = validator(value)
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 144, in 
> __call__
> return self.validate(value), None
>   File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
> Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 2754, in 
> validate
> 

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


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