本文整理汇总了Python中munch.Munch.user_id方法的典型用法代码示例。如果您正苦于以下问题:Python Munch.user_id方法的具体用法?Python Munch.user_id怎么用?Python Munch.user_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类munch.Munch
的用法示例。
在下文中一共展示了Munch.user_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_metadata
# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import user_id [as 别名]
def add_metadata(self, environ, identity):
log.info('In add_metadata')
if identity.get('error'):
log.info('Error exists in session, no need to set metadata')
return 'error'
plugin_user_info = {}
for plugin in self._metadata_plugins:
plugin(plugin_user_info)
identity.update(plugin_user_info)
del plugin_user_info
user = identity.get('repoze.who.userid')
(session_id, user_info) = fas_cache.get_value(
key=user,
expiretime=FAS_CACHE_TIMEOUT)
#### FIXME: Deprecate this line!!!
# If we make a new version of fas.who middleware, get rid of saving
# user information directly into identity. Instead, save it into
# user, as is done below
identity.update(user_info)
identity['userdata'] = user_info
identity['user'] = Munch()
identity['user'].created = user_info['creation']
identity['user'].display_name = user_info['human_name']
identity['user'].email_address = user_info['email']
identity['user'].groups = user_info['groups']
identity['user'].password = None
identity['user'].permissions = user_info['permissions']
identity['user'].user_id = user_info['id']
identity['user'].user_name = user_info['username']
identity['groups'] = user_info['groups']
identity['permissions'] = user_info['permissions']
if 'repoze.what.credentials' not in environ:
environ['repoze.what.credentials'] = {}
environ['repoze.what.credentials']['groups'] = user_info['groups']
permissions = user_info['permissions']
environ['repoze.what.credentials']['permissions'] = permissions
# Adding the userid:
userid = identity['repoze.who.userid']
environ['repoze.what.credentials']['repoze.what.userid'] = userid