alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

Validator error using GAE and list:reference #145

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From cfho...@cfhowes.com on January 05, 2011 20:29:46

What steps will reproduce the problem? 1. get web2py 1.91.6, run on GAE dev server

  1. create a model like:

db.define_table('allergen', Field('allergen', length=500, notnull=True, unique=True, requires=IS_NOT_IN_DB(db, 'allergen.allergen')), migrate=migrate) db.define_table('test', Field('allergens', 'list:reference allergen'), )

  1. Try to create a record using the default SQLForm

Instead of an edit form you see the following exception trace in the logs:

File "/home/cfhowes/clients/pump/source/web2py/gluon/validators.py", line 414, in build_set orderby = self.orderby or reduce(lambda a,b:a|b,(f for f in fields if not f.name=='id')) TypeError: reduce() of empty sequence with no initial value

If you edit validators.py to replace line 414 with:

        f_list = [f for f in fields if not f.name=='id']
        orderby = self.orderby or (reduce(lambda a,b:a|b,f_list) if len(f_list) > 0 else None)

it works again. This did work in previous versions of web2py (pre-DAL upgrade was the last time i tested it)

Original issue: http://code.google.com/p/web2py/issues/detail?id=147

alfonsodg commented 10 years ago

From massimo....@gmail.com on June 20, 2011 11:28:57

This should be fixed in trunk. Please re-open if incorrect.

Status: Fixed