本文整理汇总了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']
示例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)
示例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()
示例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']
示例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()
示例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})
示例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'])