diff --git a/applications/welcome/controllers/default.py b/applications/welcome/controllers/default.py index 19013477..b2f2a5dd 100644 --- a/applications/welcome/controllers/default.py +++ b/applications/welcome/controllers/default.py @@ -9,9 +9,6 @@ ## - api is an example of Hypermedia API support and access control ######################################################################### -def test(): - return locals() - def index(): """ example action using the internationalization operator T and flash diff --git a/applications/welcome/models/db.py b/applications/welcome/models/db.py index 932a7a60..ab0c624e 100644 --- a/applications/welcome/models/db.py +++ b/applications/welcome/models/db.py @@ -50,7 +50,6 @@ service = Service() plugins = PluginManager() ## create all tables needed by auth if not custom tables -auth.settings.extra_fields['auth_user'] = [Field('claims','list:string')] auth.define_tables(username=False, signature=False) ## configure email diff --git a/gluon/dal.py b/gluon/dal.py index 07eba094..f09b1993 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -246,7 +246,7 @@ except ImportError: simplejson = None LOGGER = logging.getLogger("web2py.dal") -DEFAULT = lambda: 0 +DEFAULT = lambda: None GLOBAL_LOCKER = threading.RLock() THREAD_LOCAL = threading.local() @@ -10122,7 +10122,7 @@ class Field(Expression): self.custom_qualifier = custom_qualifier self.label = (label if label is not None else fieldname.replace('_', ' ').title()) - self.requires = requires if not requires in (None, DEFAULT) else [] + self.requires = requires if requires is not None else [] self.map_none = map_none self._rname = rname diff --git a/gluon/html.py b/gluon/html.py index 8d480181..ee021da1 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -1846,8 +1846,12 @@ class INPUT(DIV): if requires: if not isinstance(requires, (list, tuple)): requires = [requires] - for validator in requires: - (value, errors) = validator(value) + for k,validator in enumerate(requires): + try: + (value, errors) = validator(value) + except: + msg = "Validation error, field:%s %s" % (name,validator) + raise Exception(msg) if not errors is None: self.vars[name] = value self.errors[name] = errors diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 0ef3ae28..c08ae048 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -22,7 +22,8 @@ from gluon.html import FORM, INPUT, LABEL, OPTION, SELECT, COL, COLGROUP from gluon.html import TABLE, THEAD, TBODY, TR, TD, TH, STYLE from gluon.html import URL, truncate_string, FIELDSET from gluon.dal import DAL, Field, Table, Row, CALLABLETYPES, smart_query, \ - bar_encode, Reference, Expression, SQLCustomType + bar_encode, Reference, Expression, SQLCustomType, sqlhtml_validators, \ + DEFAULT from gluon.storage import Storage from gluon.utils import md5_hash from gluon.validators import IS_EMPTY_OR, IS_NOT_EMPTY, IS_LIST_OF, IS_DATE, \ @@ -1118,9 +1119,13 @@ class SQLFORM(FORM): extra_fields = extra_fields or [] self.extra_fields = {} for extra_field in extra_fields: - extra_field.tablename = '_extra' self.fields.append(extra_field.name) self.extra_fields[extra_field.name] = extra_field + extra_field.db = table._db + extra_field.table = table + extra_field.tablename = table._tablename + if extra_field.requires == DEFAULT: + extra_field.requires = sqlhtml_validators(extra_field) for fieldname in self.fields: if fieldname.find('.') >= 0: @@ -1186,7 +1191,7 @@ class SQLFORM(FORM): if cond: - # ## if field.represent is available else + # ## if field.re field.requires = sqlhtml_validators(field) field.requires = sqlhtml_validators(field)present is available else # ## ignore blob and preview uploaded images # ## format everything else diff --git a/gluon/utils.py b/gluon/utils.py index 5b07eed5..0c1fbfb2 100644 --- a/gluon/utils.py +++ b/gluon/utils.py @@ -354,7 +354,7 @@ def getipaddrinfo(host): def obj2dict(obj, processed=None): """ - converts any objet into a dict, recursively + converts any object into a dict, recursively """ processed = processed if not processed is None else set() if obj is None: