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


Python Entry.primitive方法代码示例

本文整理汇总了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)
开发者ID:openregister-attic,项目名称:openregister-flask,代码行数:16,代码来源:test_app.py

示例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']
开发者ID:byrondover,项目名称:entry,代码行数:9,代码来源:test_representation_primitive.py

示例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}
开发者ID:openregister-attic,项目名称:openregister-flask,代码行数:10,代码来源:test_app.py

示例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"
开发者ID:openregister-attic,项目名称:openregister-flask,代码行数:11,代码来源:test_app.py

示例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
开发者ID:openregister-attic,项目名称:openregister-flask,代码行数:44,代码来源:views.py

示例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"
开发者ID:byrondover,项目名称:entry,代码行数:16,代码来源:test_representation_primitive.py

示例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 == {}
开发者ID:byrondover,项目名称:entry,代码行数:6,代码来源:test_representation_primitive.py


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