diff --git a/VERSION b/VERSION index cd89be37..b80cd69e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.2.1 (2012-11-14 08:44:05) stable +Version 2.2.1 (2012-11-14 13:47:50) stable diff --git a/gluon/html.py b/gluon/html.py index ca8ef7e6..ccc314e4 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -129,6 +129,11 @@ def xmlescape(data, quote=True): data = cgi.escape(data, quote).replace("'", "'") return data +def call_as_list(f,*a,**b): + if not isinstance(f, (list,tuple)): + f = [f] + for item in f: + item(*a,**b) def truncate_string(text, length, dots='...'): text = text.decode('utf-8') @@ -1998,20 +2003,20 @@ class FORM(DIV): onsuccess = onvalidation.get('onsuccess', None) onfailure = onvalidation.get('onfailure', None) onchange = onvalidation.get('onchange', None) + if [k for k in onvalidation if not k in ( + 'onsuccess','onfailure','onchange')]: + raise RuntimeError('Invalid key in onvalidate dict') if onsuccess and status: - onsuccess(self) + call_as_list(onsuccess,self) if onfailure and request_vars and not status: - onfailure(self) + call_as_list(onfailure,self) status = len(self.errors) == 0 if changed: if onchange and self.record_changed and \ self.detect_record_change: - onchange(self) + call_as_list(onchange,self) elif status: - if isinstance(onvalidation, (list, tuple)): - [f(self) for f in onvalidation] - else: - onvalidation(self) + call_as_list(onvalidation, self) if self.errors: status = False if not session is None: