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
f8a0d31d
Commit
f8a0d31d
authored
Jun 05, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove ConfigurationError in favor of Django's ImproperlyConfigured
parent
2ca243a1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
13 deletions
+6
-13
rest_framework/exceptions.py
+0
-7
rest_framework/generics.py
+1
-1
rest_framework/renderers.py
+2
-2
rest_framework/throttling.py
+3
-3
No files found.
rest_framework/exceptions.py
View file @
f8a0d31d
...
@@ -86,10 +86,3 @@ class Throttled(APIException):
...
@@ -86,10 +86,3 @@ class Throttled(APIException):
self
.
detail
=
format
%
(
self
.
wait
,
self
.
wait
!=
1
and
's'
or
''
)
self
.
detail
=
format
%
(
self
.
wait
,
self
.
wait
!=
1
and
's'
or
''
)
else
:
else
:
self
.
detail
=
detail
or
self
.
default_detail
self
.
detail
=
detail
or
self
.
default_detail
class
ConfigurationError
(
Exception
):
"""
Indicates an internal server error.
"""
pass
rest_framework/generics.py
View file @
f8a0d31d
...
@@ -285,7 +285,7 @@ class GenericAPIView(views.APIView):
...
@@ -285,7 +285,7 @@ class GenericAPIView(views.APIView):
)
)
filter_kwargs
=
{
self
.
slug_field
:
slug
}
filter_kwargs
=
{
self
.
slug_field
:
slug
}
else
:
else
:
raise
exceptions
.
ConfigurationError
(
raise
ImproperlyConfigured
(
'Expected view
%
s to be called with a URL keyword argument '
'Expected view
%
s to be called with a URL keyword argument '
'named "
%
s". Fix your URL conf, or set the `.lookup_field` '
'named "
%
s". Fix your URL conf, or set the `.lookup_field` '
'attribute on the view correctly.'
%
'attribute on the view correctly.'
%
...
...
rest_framework/renderers.py
View file @
f8a0d31d
...
@@ -11,6 +11,7 @@ from __future__ import unicode_literals
...
@@ -11,6 +11,7 @@ from __future__ import unicode_literals
import
copy
import
copy
import
json
import
json
from
django
import
forms
from
django
import
forms
from
django.core.exceptions
import
ImproperlyConfigured
from
django.http.multipartparser
import
parse_header
from
django.http.multipartparser
import
parse_header
from
django.template
import
RequestContext
,
loader
,
Template
from
django.template
import
RequestContext
,
loader
,
Template
from
django.utils.xmlutils
import
SimplerXMLGenerator
from
django.utils.xmlutils
import
SimplerXMLGenerator
...
@@ -18,7 +19,6 @@ from rest_framework.compat import StringIO
...
@@ -18,7 +19,6 @@ from rest_framework.compat import StringIO
from
rest_framework.compat
import
six
from
rest_framework.compat
import
six
from
rest_framework.compat
import
smart_text
from
rest_framework.compat
import
smart_text
from
rest_framework.compat
import
yaml
from
rest_framework.compat
import
yaml
from
rest_framework.exceptions
import
ConfigurationError
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
from
rest_framework.request
import
clone_request
from
rest_framework.request
import
clone_request
from
rest_framework.utils
import
encoders
from
rest_framework.utils
import
encoders
...
@@ -270,7 +270,7 @@ class TemplateHTMLRenderer(BaseRenderer):
...
@@ -270,7 +270,7 @@ class TemplateHTMLRenderer(BaseRenderer):
return
[
self
.
template_name
]
return
[
self
.
template_name
]
elif
hasattr
(
view
,
'get_template_names'
):
elif
hasattr
(
view
,
'get_template_names'
):
return
view
.
get_template_names
()
return
view
.
get_template_names
()
raise
ConfigurationError
(
'Returned a template response with no template_name'
)
raise
ImproperlyConfigured
(
'Returned a template response with no template_name'
)
def
get_exception_template
(
self
,
response
):
def
get_exception_template
(
self
,
response
):
template_names
=
[
name
%
{
'status_code'
:
response
.
status_code
}
template_names
=
[
name
%
{
'status_code'
:
response
.
status_code
}
...
...
rest_framework/throttling.py
View file @
f8a0d31d
...
@@ -3,7 +3,7 @@ Provides various throttling policies.
...
@@ -3,7 +3,7 @@ Provides various throttling policies.
"""
"""
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.core.cache
import
cache
from
django.core.cache
import
cache
from
rest_framework
import
exceptions
from
django.core.exceptions
import
ImproperlyConfigured
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
import
time
import
time
...
@@ -65,13 +65,13 @@ class SimpleRateThrottle(BaseThrottle):
...
@@ -65,13 +65,13 @@ class SimpleRateThrottle(BaseThrottle):
if
not
getattr
(
self
,
'scope'
,
None
):
if
not
getattr
(
self
,
'scope'
,
None
):
msg
=
(
"You must set either `.scope` or `.rate` for '
%
s' throttle"
%
msg
=
(
"You must set either `.scope` or `.rate` for '
%
s' throttle"
%
self
.
__class__
.
__name__
)
self
.
__class__
.
__name__
)
raise
exceptions
.
ConfigurationError
(
msg
)
raise
ImproperlyConfigured
(
msg
)
try
:
try
:
return
self
.
settings
.
DEFAULT_THROTTLE_RATES
[
self
.
scope
]
return
self
.
settings
.
DEFAULT_THROTTLE_RATES
[
self
.
scope
]
except
KeyError
:
except
KeyError
:
msg
=
"No default throttle rate set for '
%
s' scope"
%
self
.
scope
msg
=
"No default throttle rate set for '
%
s' scope"
%
self
.
scope
raise
exceptions
.
ConfigurationError
(
msg
)
raise
ImproperlyConfigured
(
msg
)
def
parse_rate
(
self
,
rate
):
def
parse_rate
(
self
,
rate
):
"""
"""
...
...
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