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


Python Schema.create方法代码示例

本文整理汇总了Python中grano.model.Schema.create方法的典型用法代码示例。如果您正苦于以下问题:Python Schema.create方法的具体用法?Python Schema.create怎么用?Python Schema.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grano.model.Schema的用法示例。


在下文中一共展示了Schema.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_fixtures

# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import create [as 别名]
 def make_fixtures(self):
     self.app.post('/api/1/networks',
                 headers=AUTHZ_HEADER,
                 data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION,
                   h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY,
                   h.TEST_ENTITY_SCHEMA)
     res = self.app.post('/api/1/net/entities', 
                 headers=AUTHZ_HEADER,
                 data=ENTITY1_FIXTURE, 
                 follow_redirects=True)
     body = json.loads(res.data)
     self.source_id = body['id']
     res = self.app.post('/api/1/net/entities',
                 headers=AUTHZ_HEADER,
                 data=ENTITY2_FIXTURE, 
                 follow_redirects=True)
     body = json.loads(res.data)
     self.target_id = body['id']
     RELATION_FIXTURE['source'] = self.source_id
     RELATION_FIXTURE['target'] = self.target_id
     res = self.app.post('/api/1/net/relations', 
                 headers=AUTHZ_HEADER,
                 data=RELATION_FIXTURE, 
                 follow_redirects=True)
     print res.data
     body = json.loads(res.data)
     self.id = body['id']
开发者ID:jmorenoamor,项目名称:grano,代码行数:32,代码来源:test_relation_api.py

示例2: setUp

# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import create [as 别名]
 def setUp(self):
     self.client = h.make_test_app()
     self.network = Network.create({'title': 'Net', 'slug': 'net'})
     self.schema = Schema.create(self.network, Schema.ENTITY,
                                 h.TEST_ENTITY_SCHEMA)
     self.rschema = Schema.create(self.network, Schema.RELATION,
                                 h.TEST_RELATION_SCHEMA)
     db.session.commit()
     self.context = ValidationContext(network=self.network)
开发者ID:jmorenoamor,项目名称:grano,代码行数:11,代码来源:test_entity.py

示例3: setUp

# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import create [as 别名]
 def setUp(self):
     self.app = make_test_app()
     self.app.post('/api/1/networks',
                 headers=AUTHZ_HEADER,
                 data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION,
                   h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY,
                   h.TEST_ENTITY_SCHEMA)
     db.session.commit()
开发者ID:jmorenoamor,项目名称:grano,代码行数:13,代码来源:test_schema_api.py

示例4: make_fixtures

# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import create [as 别名]
 def make_fixtures(self):
     self.app.post('/api/1/networks',
                 headers=AUTHZ_HEADER,
                 data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION,
                   h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY,
                   h.TEST_ENTITY_SCHEMA)
     db.session.commit()
     res = self.app.post('/api/1/net/entities', 
                 headers=AUTHZ_HEADER,
                 data=ENTITY_FIXTURE, 
                 follow_redirects=True)
     body = json.loads(res.data)
     self.id = body['id']
开发者ID:jmorenoamor,项目名称:grano,代码行数:18,代码来源:test_entity_api.py

示例5: setUp

# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import create [as 别名]
 def setUp(self):
     self.client = h.make_test_app()
     self.network = Network.create({'title': 'Net', 'slug': 'net'})
     self.schema = Schema.create(self.network, Schema.RELATION,
                                 h.TEST_RELATION_SCHEMA)
     db.session.commit()
     self.eschema = Schema.create(self.network, Schema.ENTITY,
                                  h.TEST_ENTITY_SCHEMA)
     self.context = ValidationContext(network=self.network)
     entity = deepcopy(TEST_ENTITY)
     entity['network'] = self.network.slug
     entity = validate_entity(entity, self.eschema, self.context)
     entity['title'] = 'Alice'
     a = self.network.Entity.create(self.eschema, entity)
     entity['title'] = 'Bob'
     b = self.network.Entity.create(self.eschema, entity)
     TEST_RELATION['source'] = a.id
     TEST_RELATION['target'] = b.id
     db.session.commit()
开发者ID:jmorenoamor,项目名称:grano,代码行数:21,代码来源:test_relation.py

示例6: create

# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import create [as 别名]
def create(slug, type):
    """ Create a new schema. """
    network = _get_network(slug)
    require.schema.create(network)
    _valid_schema(type)
    data = request_content(request)
    data = validate_schema(dict(data.items()))
    schema = Schema.create(network, type, data)
    db.session.commit()
    url = url_for('.get', slug=network.slug,
            type=schema.entity, name=schema.name)
    return jsonify(schema, status=201, headers={'location': url})
开发者ID:jmorenoamor,项目名称:grano,代码行数:14,代码来源:schema_api.py

示例7: test_apply_schema

# 需要导入模块: from grano.model import Schema [as 别名]
# 或者: from grano.model.Schema import create [as 别名]
 def test_apply_schema(self):
     base = mapping('entity')
     schema = Schema.create(self.network, Schema.ENTITY, h.TEST_ENTITY_SCHEMA)
     base = apply_schema(base, schema)
     assert len(base.children)==len(h.TEST_ENTITY_SCHEMA['attributes'])
开发者ID:jmorenoamor,项目名称:grano,代码行数:7,代码来源:test_schema_validation.py


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