本文整理汇总了Python中tastypie.bundle.Bundle.data['resource_uri']方法的典型用法代码示例。如果您正苦于以下问题:Python Bundle.data['resource_uri']方法的具体用法?Python Bundle.data['resource_uri']怎么用?Python Bundle.data['resource_uri']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tastypie.bundle.Bundle
的用法示例。
在下文中一共展示了Bundle.data['resource_uri']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_list
# 需要导入模块: from tastypie.bundle import Bundle [as 别名]
# 或者: from tastypie.bundle.Bundle import data['resource_uri'] [as 别名]
def post_list(self, request, **kwargs):
# ETAPA 1 - Desserialização e validação dos dados recebidos
# ---------------------------------------------------------
deserialized = self.deserialize(request, request.body,
format=request.META.get('CONTENT_TYPE', 'application/json'))
deserialized = self.alter_deserialized_detail_data(
request, deserialized)
bundle = Bundle(data=dict_strip_unicode_keys(deserialized),
request=request)
validation = CleanedDataFormValidation(form_class=CourseCreateForm)
validation_errors = validation.is_valid(bundle)
if validation_errors:
raise ImmediateHttpResponse(response=self.error_response(
bundle.request, validation_errors))
# ETAPA 2 - Efetuando operações no EDX
# ------------------------------------
course_create(bundle.data)
# Adicionando ``resource_uri``
bundle.data['resource_uri'] = reverse('api_dispatch_detail',
kwargs={ 'api_name': CourseResource._meta.api_name,
'resource_name': CourseResource._meta.resource_name,
'course_id_solaredx': course_id_encoder(bundle.data['course_id'])})
return self.create_response(request, bundle,
response_class=http.HttpCreated)