aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pygments_api
diff options
context:
space:
mode:
authortom christie tom@tomchristie.com2011-02-19 10:26:27 +0000
committertom christie tom@tomchristie.com2011-02-19 10:26:27 +0000
commit805aa03ec1871f6a766d9052b348ddce9e9843c3 (patch)
tree8ab5b6a7396236aa45bbc61e8404cc77fc75a9c5 /examples/pygments_api
parentb749b950a1b4bede76b7e3900a6385779904902d (diff)
downloaddjango-rest-framework-805aa03ec1871f6a766d9052b348ddce9e9843c3.tar.bz2
Yowzers. Final big bunch of refactoring for 0.1 release. Now support Django 1.3's views, admin style api is all polished off, loads of tests, new test project for running the test. All sorts of goodness. Getting ready to push this out now.
Diffstat (limited to 'examples/pygments_api')
-rw-r--r--examples/pygments_api/urls.py9
-rw-r--r--examples/pygments_api/views.py6
2 files changed, 9 insertions, 6 deletions
diff --git a/examples/pygments_api/urls.py b/examples/pygments_api/urls.py
index f96f4518..905e31c5 100644
--- a/examples/pygments_api/urls.py
+++ b/examples/pygments_api/urls.py
@@ -1,6 +1,7 @@
-from django.conf.urls.defaults import patterns
+from django.conf.urls.defaults import patterns, url
+from pygments_api.views import PygmentsRoot, PygmentsInstance
-urlpatterns = patterns('pygments_api.views',
- (r'^$', 'PygmentsRoot'),
- (r'^([a-zA-Z0-9-]+)/$', 'PygmentsInstance'),
+urlpatterns = patterns('',
+ url(r'^$', PygmentsRoot.as_view(), name='pygments-root'),
+ url(r'^([a-zA-Z0-9-]+)/$', PygmentsInstance.as_view(), name='pygments-instance'),
)
diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py
index e22705d9..84e5e703 100644
--- a/examples/pygments_api/views.py
+++ b/examples/pygments_api/views.py
@@ -1,4 +1,6 @@
+from __future__ import with_statement # for python 2.5
from django.conf import settings
+from django.core.urlresolvers import reverse
from djangorestframework.resource import Resource
from djangorestframework.response import Response, status
@@ -41,7 +43,7 @@ class PygmentsRoot(Resource):
def get(self, request, auth):
"""Return a list of all currently existing snippets."""
unique_ids = sorted(os.listdir(HIGHLIGHTED_CODE_DIR))
- return [self.reverse(PygmentsInstance, unique_id) for unique_id in unique_ids]
+ return [reverse('pygments-instance', args=[unique_id]) for unique_id in unique_ids]
def post(self, request, auth, content):
"""Create a new highlighed snippet and return it's location.
@@ -59,7 +61,7 @@ class PygmentsRoot(Resource):
remove_oldest_files(HIGHLIGHTED_CODE_DIR, MAX_FILES)
- return Response(status.HTTP_201_CREATED, headers={'Location': self.reverse(PygmentsInstance, unique_id)})
+ return Response(status.HTTP_201_CREATED, headers={'Location': reverse('pygments-instance', args=[unique_id])})
class PygmentsInstance(Resource):