allow arbistrary params to formstyle=style(placeholder=True, errors='down'), thanks André Kablu
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.9.5-trunk+timestamp.2014.07.28.00.20.49
|
Version 2.9.5-trunk+timestamp.2014.07.28.23.28.19
|
||||||
|
|||||||
+3
-2
@@ -35,7 +35,7 @@ import re
|
|||||||
import cStringIO
|
import cStringIO
|
||||||
from gluon.globals import current
|
from gluon.globals import current
|
||||||
from gluon.http import redirect
|
from gluon.http import redirect
|
||||||
import inspect
|
from gluon.utils import get_callable_argspec
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import gluon.settings as settings
|
import gluon.settings as settings
|
||||||
@@ -1278,6 +1278,7 @@ class SQLFORM(FORM):
|
|||||||
table = self.createform(xfields)
|
table = self.createform(xfields)
|
||||||
self.components = [table]
|
self.components = [table]
|
||||||
|
|
||||||
|
|
||||||
def createform(self, xfields):
|
def createform(self, xfields):
|
||||||
formstyle = self.formstyle
|
formstyle = self.formstyle
|
||||||
if isinstance(formstyle, basestring):
|
if isinstance(formstyle, basestring):
|
||||||
@@ -1288,7 +1289,7 @@ class SQLFORM(FORM):
|
|||||||
|
|
||||||
if callable(formstyle):
|
if callable(formstyle):
|
||||||
# backward compatibility, 4 argument function is the old style
|
# backward compatibility, 4 argument function is the old style
|
||||||
args, varargs, keywords, defaults = inspect.getargspec(formstyle)
|
args, varargs, keywords, defaults = get_callable_argspec(formstyle)
|
||||||
if defaults and len(args) - len(defaults) == 4 or len(args) == 4:
|
if defaults and len(args) - len(defaults) == 4 or len(args) == 4:
|
||||||
table = TABLE()
|
table = TABLE()
|
||||||
for id, a, b, c in xfields:
|
for id, a, b, c in xfields:
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import threading
|
|||||||
import struct
|
import struct
|
||||||
import uuid
|
import uuid
|
||||||
import random
|
import random
|
||||||
|
import inspect
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -132,6 +133,16 @@ DIGEST_ALG_BY_SIZE = {
|
|||||||
512 / 4: 'sha512',
|
512 / 4: 'sha512',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_callable_argspec(fn):
|
||||||
|
if inspect.isfunction(fn) or inspect.ismethod(fn):
|
||||||
|
inspectable = fn
|
||||||
|
elif inspect.isclass(fn):
|
||||||
|
inspectable = fn.__init__
|
||||||
|
elif hasattr(fn, '__call__'):
|
||||||
|
inspectable = fn.__call__
|
||||||
|
else:
|
||||||
|
inspectable = fn
|
||||||
|
return inspect.getargspec(inspectable)
|
||||||
|
|
||||||
def pad(s, n=32, padchar=' '):
|
def pad(s, n=32, padchar=' '):
|
||||||
return s + (32 - len(s) % 32) * padchar
|
return s + (32 - len(s) % 32) * padchar
|
||||||
|
|||||||
Reference in New Issue
Block a user