Tastypie函数调用关系图
2017-01-03 21:08:27 32 举报
tastypie函数调用关系图
作者其他创作
大纲/内容
patch_detail
创建Bundle对象,初始data,同时创建一个空的obj
cached_obj_get
apply_sorting
request
yes
http.HttpNoContent()
True
objects_to_delete
kwargs一般为空
object_data
no
dehydrate
patch_list
convert_post_to_patch(request)
deserialized/dict
objects
serialize
deletable_objects
if _meta.always_return_data
applicable_filters
http.HttpAccepted()
将获得的obj更新到bundle
data
bundle
build_bundle
put_detail
post_detail没有实现
authorized_read_list
full_dehydrate
except
self.hydrate_field_name(bundle)
alter_deserialized_list_data
if \"resource_uri\" in data:
get_detail
request.GET.copy()
remove_api_resource_names(kwargs)
start
except NotFound
yes/to_be_serialized
resource中实现了dehydrate_resource_uri;可以自定义dehydrate_field_name
alter_deserialized_detail_data
post_detail
json
basic_bundle
update_in_place
is_valid(bundle)
post/put/成功后是否返回对应的obj的序列化数据
kwargs
bsaic_bundle
ModelResource中实现
无操作,可自定义
yes/ updated_bundle
paginator
if self._meta.collection_name not in deserialized:
1
bundles
False/True
obj_create
post_list
deserialize
every object
Meta.queryset
初始化一个Bundle对象(虚基类)
#TODOpatch_list可以批量删除对象,{ \"objects\
build_bundle(request=request)
ModelResource中覆写
raise BadRequest
authorized_read_detail
raise NotFound(\"A model instance matching the provided arguments could not be found.\")
在这里对detail和list的返回结果做一些差异化处理,如进行不同的封装
obj
get_object_list
ORM
self.hydrate(bundle)
resource中简单返回了bundle,如果需要自定义bundle,可覆写该方法,这个方法对detail和list都有作用
updated_bundle
如果没有指定meta中的object_calss的值,ModelResource创建时会根据queryset.modle指定(1769)
post/put/成功后是否返回对应的序列化数据
GET/POST/PUT/...
location
obj_get_list
HttpResponse
#TODOget_multiple
alter_detail_data_to_serialize
bundle.obj.delete()
dispatch
dict_strip_unicode_keys(deserialized)
2
create_response
determine_format
#TODOget_schema
yes/obj
delete_list
format
no pk
put_list
for object_data in deserialized[self._meta.collection_name]:
没有实现,可自定义
self.save(bundle)
except ObjectDoesNotExist
生成这种东西--\"/api/v1/person/10003\"
bundle.obj
_build_reverse_url(891)
for data deserialized[collection_name]:
调用convert_post_to_put(request)利用post方法上传数据之后再重置put
self._meta.object_class()
for authed_obj in deletable_objects: authed_obj.delete()
MultipleObjectsReturned
Authrization权限控制,默认没有实现,需自定义
遍历to_be_serialized
deserialized[collection_name]
get_list
只能post单个对象的数据,不支持批量post,不过可通过patch_list实现批量创建
dispatch_detail
wrap_view
alter_list_data_to_serialize
无操作
obj_get
obj_update
for obj in objecs:这里进行了数据库查询
full_hydrate(bundle)
delete_detail
#TODO
dehydrate_field_name
将resource_uri更新到序列化数据中,然后走put_detail的逻辑,转化为调用obj_update
pk
dispatch_list
http.HttpNotFound()
http.HttpCreated(location=location)
4
apply_filters
3
obj_create(bundle=bundle)
Bundle(request=request)
......
脱水,填充bundle中data数据,resource初始化时已将model中字段加载到self.fileds中并设置了attribute(1787)
ObjectDoesNotExist
urlconf
build_filters
rollback(bundles_seen)
收藏
0 条评论
回复 删除
下一页