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


Python Response.cache_control方法代码示例

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


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

示例1: get_reporting_instance_usage_file

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [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: captcha

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [as 别名]
def captcha(request):
    form_id = request.matchdict.get('form_id', u'')  # 2 routes: with and without form_id

    image, ctype = Captcha(request.client_addr, form_id).render()

    response = Response(body=image, content_type=ctype)
    response.content_length = len(image)
    response.cache_control = 'no-cache, no-store'

    return response
开发者ID:pthorn,项目名称:Eye-Of-Ra,代码行数:12,代码来源:views.py

示例3: __call__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [as 别名]
	def __call__(self):
		image = PIL.Image.new('RGB', (self.width,self.height),(255,255,255))
		draw = PIL.ImageDraw.Draw(image)
		draw.rectangle([(0,0),(float(self.width)*self.max_count/self.max_count,10)], fill=self.color2)
		draw.rectangle([(0,0),(float(self.width)*self.count/self.max_count,10)], fill=self.color1)
		output = StringIO.StringIO()
		image.save(output, format='PNG')
		response = Response()
		response.content_type = 'image/png'
		response.cache_control = 'max-age=86400'
		response.body = output.getvalue()
		output.close()
		return response
开发者ID:tynsh,项目名称:muesli,代码行数:15,代码来源:viewsTutorial.py

示例4: file_download

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [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

示例5: get_reporting_monthly_usage_file

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [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,代码来源:

示例6: get_feed

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [as 别名]
def get_feed(request):
	url = request.matchdict['url']
	headers = {'User-Agent': USER_AGENT, 'Accept': ', '.join(ALLOWED_CONTENT_TYPES)}
	try:
		with closing(requests.get(url, headers=headers, stream=True)) as r:
			ct = r.headers.get('content-type', '').split(';')[0].lower()
			if ct in ALLOWED_CONTENT_TYPES:
				res = Response()
				res.content_type = ct
				if r.headers.get('cache-control'):
					res.cache_control = r.headers.get('cache-control')
				for x in r.iter_content(1024 * 1024):
					if x:
						res.body_file.write(x)
				return res
			else:
				return Response("Invalid content type: " + ct, status_code=400)
	except requests.exceptions.RequestException as e:
		return Response(str(e), status_code=400)
开发者ID:kz26,项目名称:rssp,代码行数:21,代码来源:views.py

示例7: __call__

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [as 别名]
 def __call__(self):
     image = PIL.Image.new("RGB", (self.width, self.height), (255, 255, 255))
     draw = PIL.ImageDraw.Draw(image)
     barheight = float(self.height) / len(self.values)
     for i, bar in enumerate(self.values):
         draw.rectangle(
             [(0, i * barheight), (float(self.width) * bar[1] / self.max, (i + 1) * barheight)], fill=self.color2
         )
         draw.rectangle(
             [(0, i * barheight), (float(self.width) * bar[0] / self.max, (i + 1) * barheight)], fill=self.color1
         )
     output = StringIO.StringIO()
     image.save(output, format="PNG")
     response = Response()
     response.content_type = "image/png"
     response.cache_control = "max-age=86400"
     response.body = output.getvalue()
     output.close()
     return response
开发者ID:dotlambda,项目名称:muesli,代码行数:21,代码来源:viewsExam.py

示例8: get_reporting_service_usage_file

# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import cache_control [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.cache_control方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。