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


Python Munch.user_name方法代码示例

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


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

示例1: add_metadata

# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import user_name [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
开发者ID:rodrigc,项目名称:python-fedora,代码行数:49,代码来源:faswhoplugin.py


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