本文整理汇总了Python中s3crud.S3CRUD.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python S3CRUD.__init__方法的具体用法?Python S3CRUD.__init__怎么用?Python S3CRUD.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类s3crud.S3CRUD
的用法示例。
在下文中一共展示了S3CRUD.__init__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from s3crud import S3CRUD [as 别名]
# 或者: from s3crud.S3CRUD import __init__ [as 别名]
def __init__(self, simple=None, advanced=None, any=False, **args):
"""
Constructor
@param simple: the widgets for the simple search form as list
@param advanced: the widgets for the advanced search form as list
@param any: match "any of" (True) or "all of" (False) the options
in advanced search
"""
S3CRUD.__init__(self)
args = Storage(args)
if simple is None:
if "field" in args:
if "name" in args:
name = args.name
elif "_name" in args:
name = args._name
else:
name = "search_simple"
simple = S3SearchSimpleWidget(field=args.field, name=name, label=args.label, comment=args.comment)
names = []
self.__simple = []
if not isinstance(simple, (list, tuple)):
simple = [simple]
for widget in simple:
if widget is not None:
name = widget.attr._name
if name in names:
raise SyntaxError("Duplicate widget: %s") % name
elif not name:
raise SyntaxError("Widget with no name")
else:
self.__simple.append((name, widget))
names.append(name)
names = []
self.__advanced = []
if not isinstance(advanced, (list, tuple)):
advanced = [advanced]
for widget in advanced:
if widget is not None:
name = widget.attr._name
if name in names:
raise SyntaxError("Duplicate widget: %s") % name
elif not name:
raise SyntaxError("Widget with no name")
else:
self.__advanced.append((name, widget))
names.append(name)
self.__any = any
if self.__simple or self.__advanced:
self.__interactive = True
else:
self.__interactive = False