I'm resubmitting as this has not been fixed. I understand the problem
better and have a workaround.
My application runs on GAE and has been stuck on 2.9.12.
Runs fine in web2py test environment and with 2.9.12 (pre pyDAL)
In both production and SDK GAE various pages fail.
This failure relates to using a set in a validator:
...
banks = db(db.CoA.Type == 'Bank')
form=SQLFORM.factory(
Field('bank', 'reference CoA', requires=IS_EMPTY_OR(IS_IN_DB(banks,
'CoA.id','%(Name)s'))),
...
In the model:
db.define_table('CoA',
Field('Type', 'string', default='Expense', requires = IS_IN_SET(['Bank',
'Asset/Liability', 'Revenue/Expense'])),
Field('Name', 'string', unique = True),
Field('Balance', 'decimal(9,2)'), #used to maintain PayPal and Bank balances
Field('Notes', 'text'),
format='%(Name)s')
db.CoA.Name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'CoA.Name')]
GAE SDK log error attached.
Note IS_IN_DB works fine with IS_IN_SET(db, ...) - I use it all over the
place.
In validators.py line 584 is in an if...else construct that tries to check
for 'gae'. This test is wrong, the adapter name would be 'google:datastore'
which would run the else clause. I tried this and established that the else
clause also fails. It looks to me as if this historical work around in
validators.py is broken, quite apart from how to fix the test. Perhaps the
implementation of 'set' can be changed to be agnostic?
The workaround for me was to use IS_IN_SET instead:
...
banks = []
coa = db(db.CoA.id > 0).select(orderby=db.CoA.Name)
for c in coa:
if c.Type == 'Bank':
banks.append((c.id, c.Name))
...
form=SQLFORM.factory(
Field('bank', 'reference CoA',
requires=IS_EMPTY_OR(IS_IN_SET(banks))),
...
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
ERROR 2016-04-22 13:50:26,631 restricted.py:174] Traceback (most recent call
last):
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\applications\init\controllers/default.py", line 2415, in
<module>
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\globals.py",
line 417, in <lambda>
self._caller = lambda f: f()
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\applications\init\controllers/default.py", line 1883, in
transearch
Field('bank', 'reference CoA', requires=IS_EMPTY_OR(IS_IN_DB(banks,
'CoA.id','%(Name)s'))))
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\sqlhtml.py",
line 1809, in factory
**attributes)
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\sqlhtml.py",
line 1295, in __init__
inp = self.widgets.options.widget(field, default)
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\sqlhtml.py",
line 313, in widget
options = requires[0].options()
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\validators.py", line 2650, in _options
options = self.other.options(*args, **kwargs)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\validators.py", line 598, in options
self.build_set()
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\validators.py", line 584, in build_set
records = self.dbset(table).select(*fields, **dd)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\objects.py", line 2020, in select
return adapter.select(self.query, fields, attributes)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
500, in select
(items, tablename, fields) = self.select_raw(query,fields,attributes)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
390, in select_raw
filters = self.expand(query)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
246, in expand
return expression.op(expression.first, expression.second)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
266, in AND
return ndb.AND(first, second)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\ndb\query.py", line 574, in
__new__
' received a non-Node instance %r' % node)
TypeError: ConjunctionNode() expects Node instances as arguments; received a
non-Node instance None
INFO 2016-04-22 13:50:26,632 gaehandler.py:75] **** Request:
219.00ms/218.22ms (real time/cpu time)
ERROR 2016-04-22 13:50:26,632 restricted.py:174] Traceback (most recent call
last):
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\applications\init\controllers/default.py", line 2415, in
<module>
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\globals.py",
line 417, in <lambda>
self._caller = lambda f: f()
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\applications\init\controllers/default.py", line 1883, in
transearch
Field('bank', 'reference CoA', requires=IS_EMPTY_OR(IS_IN_DB(banks,
'CoA.id','%(Name)s'))))
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\sqlhtml.py",
line 1809, in factory
**attributes)
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\sqlhtml.py",
line 1295, in __init__
inp = self.widgets.options.widget(field, default)
File "C:\Users\David\Google Drive\My Documents\Ocsnedb52\gluon\sqlhtml.py",
line 313, in widget
options = requires[0].options()
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\validators.py", line 2650, in _options
options = self.other.options(*args, **kwargs)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\validators.py", line 598, in options
self.build_set()
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\validators.py", line 584, in build_set
records = self.dbset(table).select(*fields, **dd)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\objects.py", line 2020, in select
return adapter.select(self.query, fields, attributes)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
500, in select
(items, tablename, fields) = self.select_raw(query,fields,attributes)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
390, in select_raw
filters = self.expand(query)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
246, in expand
return expression.op(expression.first, expression.second)
File "C:\Users\David\Google Drive\My
Documents\Ocsnedb52\gluon\packages\dal\pydal\adapters\google_adapters.py", line
266, in AND
return ndb.AND(first, second)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\ndb\query.py", line 574, in
__new__
' received a non-Node instance %r' % node)
TypeError: ConjunctionNode() expects Node instances as arguments; received a
non-Node instance None