本文整理汇总了Python中entry.Entry.primitive方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.primitive方法的具体用法?Python Entry.primitive怎么用?Python Entry.primitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry.Entry
的用法示例。
在下文中一共展示了Entry.primitive方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import primitive [as 别名]
def setup():
collections = db.collection_names()
if 'testing' not in collections:
db.create_collection('testing')
entry = Entry()
entry.primitive = {"id": 123, "someField": "thevalue"}
register.put(entry)
entry.primitive = {"id": 678, "someField": "thevalue"}
register.put(entry)
entry.primitive = {"id": 234, "otherField": "another value"}
register.put(entry)
示例2: test_set_of_tags_from_primitive
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import primitive [as 别名]
def test_set_of_tags_from_primitive():
entry = Entry()
entry.primitive = {
'fields': ['a', 'b', 'c'],
'name': 'foo'}
assert entry.name == 'foo'
assert entry.fields == ['a', 'b', 'c']
示例3: test_get_entry_json_by_hash
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import primitive [as 别名]
def test_get_entry_json_by_hash():
entry = Entry()
entry.primitive = {"id": 123, "someField": "thevalue"}
response = app.get('/hash/%s.json' % entry.hash, base_url=field_url)
assert response.status_code == 200
data = json.loads(response.data.decode('utf-8'))
assert data == {"hash": entry.hash, "entry": entry.primitive}
示例4: test_get_entry_yaml_by_hash
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import primitive [as 别名]
def test_get_entry_yaml_by_hash():
entry = Entry()
entry.primitive = {'field': 'value'}
register.put(entry)
response = app.get('/hash/%s.yaml' % entry.hash, base_url=field_url)
assert response.status_code == 200
data = response.data.decode('utf-8')
assert data == "field: value\n"
示例5: create
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import primitive [as 别名]
def create():
name = subdomain(request)
register = registers.get(name)
if not register:
register = Register(name.capitalize(),
current_app.config['MONGO_URI'])
registers[name] = register
search = "http://register.openregister.org/search.json"
url = "%s?field=register&value=%s" % (search, name)
if request.method == 'GET':
# fetch form fields from register register for register type - ouch
# e.g. http://register.openregister.org/search.
# json?field=register&value=court and use entry.fields
# however i think best that we persist this type of
# metadata with register on intialisation
resp = requests.get(url)
fields = resp.json()[0]['entry']['fields']
return render_template('create.html', register=register, fields=fields)
else:
try:
entry = Entry()
entry_dict = {}
if form_post(request):
for val in request.form:
entry_dict[val] = request.form[val]
entry = Entry()
entry.primitive = entry_dict
register.put(entry)
domain = current_app.config['REGISTER_DOMAIN']
url = 'http://%s.%s/hash/%s' % (name, domain, entry.hash)
return redirect(url)
elif request.headers['Content-Type'] == 'application/json':
entry = Entry()
entry.primitive = request.get_json()['entry']
register.put(entry)
return 'OK', 201
except Exception as ex:
log_traceback(current_app.logger, ex)
return 'Internal Server Error', 500
示例6: test_postaladdress_from_primitive
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import primitive [as 别名]
def test_postaladdress_from_primitive():
entry = Entry()
entry.primitive = {
'addressCountry': 'GB',
'addressLocality': 'Holborn',
'addressRegion': 'London',
'postcode': 'WC2B 6NH',
'streetAddress': 'Aviation House, 125 Kingsway'}
assert entry.streetAddress == "Aviation House, 125 Kingsway"
assert entry.addressLocality == "Holborn"
assert entry.addressRegion == "London"
assert entry.postcode == "WC2B 6NH"
assert entry.addressCountry == "GB"
示例7: test_empty_entry_from_primitive
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import primitive [as 别名]
def test_empty_entry_from_primitive():
entry = Entry()
entry.primitive = {}
assert entry.primitive == {}