[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2
The web2py book's example could use replacing, since it relies on using __init__ and returning (value, error) rather than using def validate and returning value or raising ValidationError On Sunday, 7 April 2019 05:36:13 UTC+1, Massimo Di Pierro wrote: > > 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 >>>
[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2
The original version works with 2.18.5 Thank you! 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
[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2
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
[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2
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: Custom validator broken in 2.18.4, working in 2.17.2
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
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
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: Custom validator broken in 2.18.4, working in 2.17.2
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: Custom validator broken in 2.18.4, working in 2.17.2
Though that breaks backward compatibility, as the interface for custom validators is provided in the official documentation. On Friday, April 5, 2019 at 2:07:22 PM UTC-4, Leonel Câmara wrote: > > The way validators are in 2.18.4 you need to do it like this: > > > 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)) > -- 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
The way validators are in 2.18.4 you need to do it like this: 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)) -- 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
Created a ticket: https://github.com/web2py/web2py/issues/2170 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