Thank you for this explanation and the workaround. I have found the next *problem with "common_filter"*: it seems, that a common_filter is not applied in the following situation:
db.define_table("test", Field("name"), common_filter = lambda query: db.test.id==1) def show1(): nlist = [p.name for p in db().select(db.test.name)] form = SQLFORM.factory( Field('name', 'list:reference test', requires=IS_IN_SET(nlist))) return dict(form=form) def show2(): nlist = [p.name for p in db(db.test.id==1).select(db.test.name)] form = SQLFORM.factory( Field('name', 'list:reference test', requires=IS_IN_SET(nlist))) return dict(form=form) Both functions should only show the first name for the "requires"-selection. But only the second functions works as expected, show1 allows all names. The same construction worked in web2py 2.14 2017-09-12 18:15 GMT+02:00 Anthony <abasta...@gmail.com>: > SQLFORM.factory creates a dummy DAL table via DAL(None). A change was made > so that auto-validators no longer get applied to fields with DAL(None), so > no fields in a SQLFORM.factory table will get the usual default DAL > validators. Datetime fields typically get a default IS_DATETIME() validator > (wrapped in IS_EMPTY_OR()), and that is what caused the conversion to a > datetime object in the previous version of web2py. The IS_DATETIME() > validator is no longer being added, so we no longer get the conversion. > > This should be corrected somehow. I've posted on the developers list to > get a discussion going: https://groups.google.com/forum/#!topic/web2py- > developers/aX6CiPi4Dh0. > > In the meantime, you can explicitly add the validator: > > SQLFORM.factory(Field('startzeit', 'datetime', requires=IS_EMPTY_OR(IS_ > DATETIME()))) > > Alternatively, you can do something like this: > > def sqlform_factory(*fields, **attributes): > from gluon.dal import _default_validators > db = DAL(None) > db.validators_method = lambda f: _default_validators(db, f) > table = db.define_table('no_table', *fields) > return SQLFORM.factory(*table, **attributes) > > And then: > > form = sqlform_factory(Field('startzeit', 'datetime')) > > Anthony > > > On Monday, September 11, 2017 at 3:53:52 PM UTC-4, mweissen wrote: >> >> What is the type of the result of a Field(...;'datetime') ? >> >> I think, it should be "datetime" (and I am shure it has been in version >> 2.14.x), but web2py 2.15.4 delivers a "str". >> >> def dttest2(): >> form = SQLFORM.factory(Field('startzeit', 'datetime')) >> if form.process().accepted: >> return \ >> str(isinstance(form.vars.startzeit,datetime.datetime)) >> return dict(form=form) >> >> >> The result is "False" >> >> ​Regards Martin​ >> >> >> -- > 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.