Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
94f24e2e
Commit
94f24e2e
authored
Jan 09, 2012
by
Benoit C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce a final methods in View class
parent
e712ab0b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
djangorestframework/views.py
+16
-12
No files found.
djangorestframework/views.py
View file @
94f24e2e
...
@@ -154,19 +154,8 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
...
@@ -154,19 +154,8 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
except
ErrorResponse
,
exc
:
except
ErrorResponse
,
exc
:
response
=
exc
.
response
response
=
exc
.
response
# Always add these headers.
#
# TODO - this isn't actually the correct way to set the vary header,
# also it's currently sub-optimal for HTTP caching - need to sort that out.
response
.
headers
[
'Allow'
]
=
', '
.
join
(
self
.
allowed_methods
)
response
.
headers
[
'Vary'
]
=
'Authenticate, Accept'
# merge with headers possibly set at some point in the view
response
.
headers
.
update
(
self
.
headers
)
set_script_prefix
(
orig_prefix
)
set_script_prefix
(
orig_prefix
)
return
self
.
final
(
request
,
response
)
return
self
.
render
(
response
)
def
options
(
self
,
request
,
*
args
,
**
kwargs
):
def
options
(
self
,
request
,
*
args
,
**
kwargs
):
response_obj
=
{
response_obj
=
{
...
@@ -183,6 +172,21 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
...
@@ -183,6 +172,21 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
response_obj
[
'fields'
]
=
field_name_types
response_obj
[
'fields'
]
=
field_name_types
return
response_obj
return
response_obj
def
final
(
self
,
request
,
response
,
*
args
,
**
kargs
):
"""
As initial, final can be overriden to add code that must be set after the render
"""
# Always add these headers.
#
# TODO - this isn't actually the correct way to set the vary header,
# also it's currently sub-optimal for HTTP caching - need to sort that out.
response
.
headers
[
'Allow'
]
=
', '
.
join
(
self
.
allowed_methods
)
response
.
headers
[
'Vary'
]
=
'Authenticate, Accept'
# merge with headers possibly set at some point in the view
response
.
headers
.
update
(
self
.
headers
)
return
self
.
render
(
response
)
class
ModelView
(
View
):
class
ModelView
(
View
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment