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


Python Tiddler.fields['mapped_user']方法代码示例

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


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

示例1: test_user_maps_info

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields['mapped_user'] [as 别名]
def test_user_maps_info():
    """User can get their own identities at /users/{username}/identities"""
    global AUTH_COOKIE
    http = httplib2.Http()

# auth required
    response, content = http.request(
            'http://0.0.0.0:8080/users/cdent/identities',
            method='GET')
    assert response['status'] == '401'

# user can get own identities
    response, content = http.request(
            'http://0.0.0.0:8080/users/cdent/identities',
            method='GET',
            headers={'Cookie': 'tiddlyweb_user="%s"' % AUTH_COOKIE})
    assert response['status'] == '200', content

    info = simplejson.loads(content)
    assert 'x.auth.thing' in info, info

    tiddler = Tiddler('fnd.example.org', 'MAPUSER')
    tiddler.fields['mapped_user'] = 'fnd'
    tiddler = store.put(tiddler)
    tiddler = Tiddler('cdent.example.com', 'MAPUSER')
    tiddler.fields['mapped_user'] = 'cdent'
    tiddler = store.put(tiddler)

    response, content = http.request(
            'http://0.0.0.0:8080/users/cdent/identities',
            method='GET',
            headers={'Cookie': 'tiddlyweb_user="%s"' % AUTH_COOKIE})
    identities = simplejson.loads(content)
    assert response['status'] == '200', content
    assert len(identities) == 2
    assert 'x.auth.thing' in identities
    assert 'cdent.example.com' in identities
    assert 'fnd.example.org' not in identities

# user can't get other identities
    response, content = http.request(
            'http://0.0.0.0:8080/users/fnd/identities',
            method='GET',
            headers={'Cookie': 'tiddlyweb_user="%s"' % AUTH_COOKIE})
    assert response['status'] == '403'
    assert 'Bad user for action' in content

# admin can get other identities
    user = store.get(User('cdent'))
    user.add_role('ADMIN')
    store.put(user)
    response, content = http.request(
            'http://0.0.0.0:8080/users/fnd/identities',
            method='GET',
            headers={'Cookie': 'tiddlyweb_user="%s"' % AUTH_COOKIE})
    assert response['status'] == '200'
    identities = simplejson.loads(content)
    assert identities == ['fnd.example.org']
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:60,代码来源:test_mapuser_validate.py

示例2: establish_user_auth

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields['mapped_user'] [as 别名]
def establish_user_auth(config, store, host, username):
    user = User(username)
    mapping_username = 'github-%s' % username
    mapping_tiddler = Tiddler(mapping_username, 'MAPUSER')
    mapping_tiddler.fields['mapped_user'] = username

    try:
        store.delete(user)
    except StoreError:
        pass
    try:
        store.delete(mapping_tiddler)
    except IOError:
        pass

    user.add_role('MEMBER')
    user.note = '{}'
    store.put(user)
    ensure_bag('MAPUSER', store)
    store.put(mapping_tiddler)
    stamp = datetime.utcnow().strftime('%Y%m%d%H')
    csrf = gen_nonce(username, host, stamp, config['secret'])
    cookie = make_cookie('tiddlyweb_user', mapping_username,
            mac_key=config['secret'], httponly=False)

    return cookie, csrf
开发者ID:BillSeitz,项目名称:tank,代码行数:28,代码来源:fixtures.py

示例3: test_simple_translate

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields['mapped_user'] [as 别名]
def test_simple_translate():
    bag = Bag('MAPUSER')
    store.put(bag)
    tiddler = Tiddler('xfoo.example.com', 'MAPUSER')
    tiddler.fields['mapped_user'] = 'xfoo'
    store.put(tiddler)

    extractor = Extractor()

    assert extractor.translate_user(environ, 'xfoo.example.com') == 'xfoo'
开发者ID:FND,项目名称:tiddlywebplugins.magicuser,代码行数:12,代码来源:test_simple.py


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