aboutsummaryrefslogtreecommitdiffstats
path: root/examples/permissionsexample/views.py
diff options
context:
space:
mode:
authorTom Christie2011-06-21 23:05:23 +0100
committerTom Christie2011-06-21 23:05:23 +0100
commit409ee533fd28b742f4e790dc56aa686f44db1fcd (patch)
tree4ead8d66f535fd6e6931f9a351c919fd702bd997 /examples/permissionsexample/views.py
parent82de0cf50a6f4ac2a3646a2524d149b7e7c85b2c (diff)
parent1692942ec2eaf211777d2dbb30ae6cf9dd52177f (diff)
downloaddjango-rest-framework-409ee533fd28b742f4e790dc56aa686f44db1fcd.tar.bz2
merge markos throttling example
Diffstat (limited to 'examples/permissionsexample/views.py')
-rw-r--r--examples/permissionsexample/views.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/permissionsexample/views.py b/examples/permissionsexample/views.py
new file mode 100644
index 00000000..20e7cba7
--- /dev/null
+++ b/examples/permissionsexample/views.py
@@ -0,0 +1,20 @@
+from djangorestframework.views import View
+from djangorestframework.permissions import PerUserThrottling
+
+
+class ThrottlingExampleView(View):
+ """
+ A basic read-only View that has a **per-user throttle** of 10 requests per minute.
+
+ If a user exceeds the 10 requests limit within a period of one minute, the
+ throttle will be applied until 60 seconds have passed since the first request.
+ """
+
+ permissions = ( PerUserThrottling, )
+ throttle = '10/min'
+
+ def get(self, request):
+ """
+ Handle GET requests.
+ """
+ return "Successful response to GET request because throttle is not yet active." \ No newline at end of file