本文整理汇总了Python中colanderalchemy.SQLAlchemySchemaNode.clone方法的典型用法代码示例。如果您正苦于以下问题:Python SQLAlchemySchemaNode.clone方法的具体用法?Python SQLAlchemySchemaNode.clone怎么用?Python SQLAlchemySchemaNode.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类colanderalchemy.SQLAlchemySchemaNode
的用法示例。
在下文中一共展示了SQLAlchemySchemaNode.clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_doctypes_schema
# 需要导入模块: from colanderalchemy import SQLAlchemySchemaNode [as 别名]
# 或者: from colanderalchemy.SQLAlchemySchemaNode import clone [as 别名]
def get_doctypes_schema(userdatas_model):
"""
Build a form schema for doctypes registration
:param obj userdatas_model: An instance of userdatas we're building
the form for
"""
registered = userdatas_model.doctypes_registrations
node_schema = SQLAlchemySchemaNode(UserDatasSocialDocTypes)
node_schema.widget = deform.widget.MappingWidget(
template="clean_mapping.pt"
)
node_schema['status'].widget = deform.widget.CheckboxWidget()
form_schema = colander.Schema()
for index, entry in enumerate(registered):
node = node_schema.clone()
name = 'node_%s' % index
node.name = name
node.title = u''
node['status'].title = u''
node['status'].label = entry.doctype.label
form_schema.add(node)
return form_schema
示例2: test_clone
# 需要导入模块: from colanderalchemy import SQLAlchemySchemaNode [as 别名]
# 或者: from colanderalchemy.SQLAlchemySchemaNode import clone [as 别名]
def test_clone(self):
schema = SQLAlchemySchemaNode(Account, dummy='dummy', dummy2='dummy2')
cloned = schema.clone()
for attr in ['class_', 'includes', 'excludes', 'overrides']:
self.assertEqual(getattr(schema, attr), getattr(cloned, attr))
self.assertEqual(cloned.kwargs, schema.kwargs)
self.assertEqual([node.name for node in schema.children],
[node.name for node in cloned.children])
示例3: get_doctypes_form_schema
# 需要导入模块: from colanderalchemy import SQLAlchemySchemaNode [as 别名]
# 或者: from colanderalchemy.SQLAlchemySchemaNode import clone [as 别名]
def get_doctypes_form_schema(userdatas_model):
"""
Returns a dynamically built form for doctypes registration
"""
registrations = userdatas_model.doctypes_registrations
node_schema = SQLAlchemySchemaNode(UserDatasSocialDocTypes)
appstruct = {}
form_schema = colander.Schema()
for index, registration in enumerate(registrations):
node = node_schema.clone()
name = 'node_%s' % index
node.name = name
node.title = u''
node['status'].title = registration.doctype.label
form_schema.add(node)
appstruct[name] = node_schema.dictify(registration)
return form_schema, appstruct