If I were you I'd log an issue over at pydal's
repo. https://github.com/web2py/pydal/issues
On Friday, April 22, 2016 at 7:11:36 PM UTC+2, David Manns wrote:
>
> 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.