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


Python Response.pragma方法代码示例

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


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

示例1: get_reporting_instance_usage_file

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import pragma [as 别名]
 def get_reporting_instance_usage_file(self):
     conn = self.get_connection(conn_type='ec2reports')
     if not self.is_csrf_valid():
         return JSONResponse(status=400, message="missing CSRF token")
     granularity = self.request.params.get('granularity')
     group_by = self.request.params.get('groupBy')
     dates = self.dates_from_params(self.request.params)
     filters = self.request.params.get('filters') or '[]'
     filters = json.loads(filters)
     with boto_error_handler(self.request):
         # use "ViewInstanceUsageReport" call to fetch usage information
         ret = conn.view_instance_usage_report(
             dates.from_date, dates.to_date, filters, group_by, report_granularity=granularity
         )
         filename = 'EucalyptusInstanceUsage-{0}-{1}-{2}.csv'.format(
             self.request.session.get('account'),
             dates.from_date,
             dates.to_date
         )
         response = Response(content_type='text/csv')
         response.text = ret.get('usageReport')
         response.content_disposition = 'attachment; filename="{name}"'.format(name=filename)
         response.cache_control = 'no-store'
         response.pragma = 'no-cache'
         return response
开发者ID:,项目名称:,代码行数:27,代码来源:

示例2: file_download

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import pragma [as 别名]
def file_download(request):
    if not(BaseView.is_csrf_valid_static(request)):
        return JSONResponse(status=400, message="missing CSRF token")
    session = request.session
    if session.get('file_cache'):
        (filename, mime_type, contents) = session['file_cache']
        # Clean the session information regrading the new keypair
        del session['file_cache']
        response = Response(content_type=mime_type)
        response.body = str(contents)
        response.content_disposition = 'attachment; filename="{name}"'.format(name=filename)
        response.cache_control = 'no-store'
        response.pragma = 'no-cache'
        return response
    # no file found ...
    # this isn't handled on on client anyway, so we can return pretty much anything
    return Response(body='BaseView:file not found', status=500)
开发者ID:aliceh,项目名称:eucaconsole,代码行数:19,代码来源:__init__.py

示例3: get_reporting_monthly_usage_file

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import pragma [as 别名]
 def get_reporting_monthly_usage_file(self):
     if not self.is_csrf_valid():
         return JSONResponse(status=400, message="missing CSRF token")
     year = int(self.request.params.get('year'))
     month = int(self.request.params.get('month'))
     # use "ViewMontlyUsage" call to fetch usage information
     ret = self.conn.view_monthly_usage(year, month)
     filename = 'EucalyptusMonthlyUsage-{0}-{1}-{2}.csv'.format(
         self.request.session.get('account'),
         year,
         month
     )
     response = Response(content_type='text/csv')
     response.text = ret.get('data')
     response.content_disposition = 'attachment; filename="{name}"'.format(name=filename)
     response.cache_control = 'no-store'
     response.pragma = 'no-cache'
     return response
开发者ID:,项目名称:,代码行数:20,代码来源:

示例4: get_reporting_service_usage_file

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import pragma [as 别名]
 def get_reporting_service_usage_file(self):
     if not self.is_csrf_valid():
         return JSONResponse(status=400, message="missing CSRF token")
     service = self.request.params.get('service')
     usage_type = self.request.params.get('usageType')
     granularity = self.request.params.get('granularity')
     dates = self.dates_from_params(self.request.params)
     # use "ViewUsage" call to fetch usage information
     ret = self.conn.view_usage(
         service, usage_type, 'all', dates.from_date, dates.to_date, report_granularity=granularity
     )
     filename = 'EucalyptusServiceUsage-{0}-{1}-{2}.csv'.format(
         self.request.session.get('account'),
         service,
         usage_type
     )
     response = Response(content_type='text/csv')
     response.text = ret.get('data')
     response.content_disposition = 'attachment; filename="{name}"'.format(name=filename)
     response.cache_control = 'no-store'
     response.pragma = 'no-cache'
     return response
开发者ID:,项目名称:,代码行数:24,代码来源:


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