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


Python Request.headers['x-container-sysmeta-owner']方法代码示例

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


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

示例1: __call__

# 需要导入模块: from swift.common.swob import Request [as 别名]
# 或者: from swift.common.swob.Request import headers['x-container-sysmeta-owner'] [as 别名]
 def __call__(self, env, start_response):
     
     req = Request(env)
     username   = env.get('HTTP_X_USER_NAME',None)
     userid     = env.get('HTTP_X_USER_ID',None)
     tenant     = env.get('HTTP_X_PROJECT_NAME',None)
     version, account, container, obj = req.split_path(1,4,True)
     #COMMENT: Control the author of the request. 
     if req.method == "PUT" and req.headers.get('x-container-read',None) is not None and  container is not None and obj is None:
             #Associate owner to container
             req.headers['x-container-sysmeta-owner'] = userid
             req.headers['x-container-meta-owner'] = userid
     if req.method =="POST" and req.headers.get('x-container-read',None) is not None:
             new_req = Request.blank(req.path_info,None,req.headers,None)
             new_req.method = "HEAD"
             new_req.path_info = "/".join(["",version,account,container])
             new_resp = new_req.get_response(self.app) 
             if new_resp.headers.get('x-container-meta-bel-id',None) is None:
                 #Container public -> private. Associate owner
                 req.headers['x-container-sysmeta-owner'] = userid
                 req.headers['x-container-meta-owner'] = userid
             elif new_resp.headers.get('x-container-sysmeta-owner',None) != userid:
                 #Container already private and user is not the owner
                 return HTTPUnauthorized(body="Unauthorized")(env, start_response)
     if req.method == "GET" and username != "ceilometer" and username != None:
         if obj != None:
             #Request a container
             new_req = Request.blank(req.path_info,None,req.headers,None)
             new_req.method = "HEAD"
             new_req.path_info = "/".join(["",version,account,container])
             response = new_req.get_response(self.app)
             cont_header = response.headers
             container_sel_id = cont_header.get('x-container-meta-sel-id',None)
             cont_secret_ref = cont_header.get('x-container-meta-container-ref',None)
             env['swift_crypto_fetch_cont_id'] = container_sel_id    
             resp_obj = req.get_response(self.app)
             object_sel_id = resp_obj.headers.get('x-object-meta-sel-id',None)
             if object_sel_id != container_sel_id:# and onResource=="False":
                 #The object has been uploaded before the last policy change
                 if object_sel_id is not None:
                     old_dek = get_secret(self.userID,cont_secret_ref,object_sel_id,tenant).get('KEK',None)
                     if old_dek is not None:
                         env['swift_crypto_old_fetch_key'] = old_dek
                     else:
                         env['swift_crypto_old_fetch_key'] = "NotAuthorized"
                 if container_sel_id is not None: 
                     dek = get_secret(self.userID,cont_secret_ref,container_sel_id,tenant).get('KEK',None)
                     if dek is not None:
                         env['swift_crypto_fetch_key'] = dek
                     else:
                         env['swift_crypto_fetch_key'] = "NotAuthorized"  
         """elif obj == None and container == None:
             resp_account = req.get_response(self.app)
             list_containers = resp_account.body
             list_containers = json.loads(list_containers)
             for cont in list_containers:
                 new_req = Request.blank(req.path_info,None,None,None)
                 new_req.method = "GET"
                 cont_name = cont.get('name','') 
                 new_req.path_info = "/".join(["",version,account,cont_name])
                 response = new_req.get_response(self.app)
                 print response.headers
                 print cont
                 print "-----------------------"
                 list_acl = self.extractACL(response.headers)
                 if list_acl != [] and userid not in list_acl:
                     print "list_acl\n"
                     print list_acl
                     list_containers.remove(cont)
             resp_account.body = json.dumps(list_containers)"""
     return self.app(env, start_response)
开发者ID:danieleguttadoro,项目名称:ovencswiftserver_onthefly,代码行数:73,代码来源:key_master.py


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