当前位置: 首页>>代码示例>>Python>>正文


Python SQLAlchemySchemaNode.clone方法代码示例

本文整理汇总了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
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:27,代码来源:userdatas.py

示例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])
开发者ID:timka,项目名称:ColanderAlchemy,代码行数:11,代码来源:test_schema.py

示例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
开发者ID:w3bcr4ft,项目名称:autonomie,代码行数:22,代码来源:user.py


注:本文中的colanderalchemy.SQLAlchemySchemaNode.clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。