本文整理汇总了Python中grano.model.Schema.project方法的典型用法代码示例。如果您正苦于以下问题:Python Schema.project方法的具体用法?Python Schema.project怎么用?Python Schema.project使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grano.model.Schema
的用法示例。
在下文中一共展示了Schema.project方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import project [as 别名]
def save(data, schema=None):
""" Create a schema. """
schema_val = SchemaValidator(validator=check_attributes)
data = schema_val.deserialize(data)
if schema is None:
schema = Schema()
schema.name = data.get('name')
schema.project = data.get('project')
schema.label = data.get('label')
schema.obj = data.get('obj')
schema.hidden = data.get('hidden')
schema.meta = data.get('meta')
schema.project.updated_at = datetime.utcnow()
db.session.add(schema)
names = []
for attribute in data.get('attributes', []):
attribute['schema'] = schema
attr = attributes.save(attribute)
schema.attributes.append(attr)
names.append(attr.name)
for attr in schema.attributes:
if attr.name not in names:
attributes.delete(attr)
return schema
示例2: save
# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import project [as 别名]
def save(data, schema=None):
""" Create a schema. """
data = validate(data)
operation = 'create' if schema is None else 'update'
if schema is None:
schema = Schema()
schema.name = data.get('name')
schema.project = data.get('project')
schema.label = data.get('label')
schema.obj = data.get('obj')
schema.hidden = data.get('hidden')
schema.meta = data.get('meta')
schema.parent = data.get('parent')
if schema.name in DEFAULTS.values():
schema.parent = None
elif schema.parent is None or schema.is_circular():
schema.parent = Schema.by_name(schema.project,
DEFAULTS.get(schema.obj))
schema.project.updated_at = datetime.utcnow()
db.session.add(schema)
inherited = [a.name for a in schema.inherited_attributes]
names = []
for attribute in data.get('attributes', []):
if attribute.get('name') in inherited:
continue
attribute['schema'] = schema
attr = attributes.save(attribute)
schema.local_attributes.append(attr)
names.append(attr.name)
for attr in schema.local_attributes:
if attr.name not in names:
attributes.delete(attr)
db.session.flush()
_schema_changed(schema.project.slug, schema.name, operation)
return schema