static.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码
def attach_profile_and_content_to_context(request, content_path, context):
    """Attaches UserProfile data and yaml content to a request context.

    Args:
      request: a Request instance passed to the View
      content_path: path to our static yaml content
      context: a base context to be modified

    Returns:
      the modified context
    """
    if not request.user.is_anonymous():
        context['user_profile'] = UserProfile.objects.get(user=request.user)
    if content_path:
        with open(content_path) as content_file:
            content = yaml.safe_load(content_file)
        for item in content:
            context[item] = content[item]
    return context
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号