本文整理匯總了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)