The backends are the real meat of the documents. Where the document defines what you can do, the backends implement the how of it. Documents and backends use dictionary to communicate to each other. A backend expects a dictionary representation of the document, applies it as needed, and returns the resource as a dictionary again. Each backend must implement the following methods:
The HTTP backend uses the requests library to communicate to remote backends over HTTP. It assumes currently JSON as exchange protocol. The document methods map the following way to the HTTP backend:
This backend uses the uri() method to determine its API endpoint. You can implement specific uri methods for each HTTP verb to be more precise. If a http specific uri method is not found, it will fallback to the default uri() method. The form of those methods is verb_uri.
class Article(Document):
id = fields.NumberField()
def post_uri(self):
# Use this method for POST requests
return "http://post_location"
def uri(self):
# The default uri location for all other HTTP requests
return "http://location"
The django backend stores and retrieves resources using the Django ORM.