aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/compat.py
diff options
context:
space:
mode:
authormarkotibold2011-05-18 22:13:48 +0200
committermarkotibold2011-05-18 22:13:48 +0200
commit92c015e0495b7cf39b0d0387fe6d376812a9ebef (patch)
tree81549ea10c2b2e3c550bea163e464d91f5925bb5 /djangorestframework/compat.py
parent49d4e50342cd3a6e2dce9f61d379cb54a0c1c6b5 (diff)
downloaddjango-rest-framework-92c015e0495b7cf39b0d0387fe6d376812a9ebef.tar.bz2
Most of the actual work so far has been markup really.
Diffstat (limited to 'djangorestframework/compat.py')
-rw-r--r--djangorestframework/compat.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/djangorestframework/compat.py b/djangorestframework/compat.py
index 98fbbb62..45a695c8 100644
--- a/djangorestframework/compat.py
+++ b/djangorestframework/compat.py
@@ -1,4 +1,6 @@
-"""Compatability module to provide support for backwards compatability with older versions of django/python"""
+"""
+Compatability module to provide support for backwards compatability with older versions of django/python
+"""
# cStringIO only if it's available
try:
@@ -27,24 +29,25 @@ except ImportError:
# Lovely stuff
class RequestFactory(Client):
"""
- Class that lets you create mock Request objects for use in testing.
+ Class that lets you create mock :obj:`Request` objects for use in testing.
- Usage:
+ Usage::
- rf = RequestFactory()
- get_request = rf.get('/hello/')
- post_request = rf.post('/submit/', {'foo': 'bar'})
+ rf = RequestFactory()
+ get_request = rf.get('/hello/')
+ post_request = rf.post('/submit/', {'foo': 'bar'})
- This class re-uses the django.test.client.Client interface, docs here:
- http://www.djangoproject.com/documentation/testing/#the-test-client
+ This class re-uses the :class:`django.test.client.Client` interface. Of which
+ you can find the docs here__.
- Once you have a request object you can pass it to any view function,
- just as if that view had been hooked up using a URLconf.
+ __ http://www.djangoproject.com/documentation/testing/#the-test-client
+ Once you have a :obj:`request` object you can pass it to any :func:`view` function,
+ just as if that :func:`view` had been hooked up using a URLconf.
"""
def request(self, **request):
"""
- Similar to parent class, but returns the request object as soon as it
+ Similar to parent class, but returns the :obj:`request` object as soon as it
has created it.
"""
environ = {
@@ -148,9 +151,11 @@ try:
import re
class CustomSetextHeaderProcessor(markdown.blockprocessors.BlockProcessor):
- """Override markdown's SetextHeaderProcessor, so that ==== headers are <h2> and ---- headers are <h3>.
+ """
+ Override `markdown`'s :class:`SetextHeaderProcessor`, so that ==== headers are <h2> and ---- headers are <h3>.
- We use <h1> for the resource name."""
+ We use <h1> for the resource name.
+ """
# Detect Setext-style header. Must be first 2 lines of block.
RE = re.compile(r'^.*?\n[=-]{3,}', re.MULTILINE)
@@ -172,8 +177,11 @@ try:
blocks.insert(0, '\n'.join(lines[2:]))
def apply_markdown(text):
- """Simple wrapper around markdown.markdown to apply our CustomSetextHeaderProcessor,
- and also set the base level of '#' style headers to <h2>."""
+ """
+ Simple wrapper around :func:`markdown.markdown` to apply our :class:`CustomSetextHeaderProcessor`,
+ and also set the base level of '#' style headers to <h2>.
+ """
+
extensions = ['headerid(level=2)']
safe_mode = False,
output_format = markdown.DEFAULT_OUTPUT_FORMAT