本文整理汇总了Python中models.Email.from_fp方法的典型用法代码示例。如果您正苦于以下问题:Python Email.from_fp方法的具体用法?Python Email.from_fp怎么用?Python Email.from_fp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Email
的用法示例。
在下文中一共展示了Email.from_fp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import from_fp [as 别名]
def post(self, request):
# META is standard python dict
# and content-length will be inside definitely
length = request.META['CONTENT_LENGTH']
if not length or int(length)==0: # in post there must be a content-length
logger.warn('Recved a request of length %s', length, extra=request.__dict__)
return HttpResponse(status=411)
# Max 50M
if length.isdigit() and int(length) > 50*1024*1024:
logger.warn('Recved a request larger than 50M', extra=request.__dict__)
return HttpResponse(status=413)
if not self.is_authenticated(request):
logger.warn('Unauthorized request', extra=request.__dict__)
return HttpResponse(status=403)
email = Email.from_fp(request)
email.save()
return HttpResponse('{ok: true, location: %s}' %
# by http host
request.build_absolute_uri(reverse('email_detail',
args=(email.id,))), status=201)