This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

python-docar gives an declarative syntax for defining messages passed between client and server applications. By moving the focus of web applications to the documents exchanged it gives you the possibility to implement document oriented architectures. In this way you can map documents (messages) to resources identified by an URI. This is helpful for applications that implement a RESTful API. In the context of frameworks like Django, docar serves as a supporting library.

On the server side those documents can be mapped to an underlying model store. At this time python-docar supports a Django ORM backend and a HTTP backend. Other model mappers like Sqlalchemy or a MongoDB backend mappers are possible. Currently a MongoDB backend is in the making.

The same document definitions can be reused on the client side. In the future it will come with a HTTP client that can craft messages and send them right away to the server applications. Those documents can be validated, on the client side as well as on the server side.

At the moment the only messaging format supported is a very simple JSON format. It is planned to provide more dialects (like XML) or the possibility to override the built-in serializers.

For the full documentation, either build it yourself or visit the online documentation at readthedocs: http://readthedocs.org/docs/python-docar/

Report any issues on the issue tracker of github. For any questions, send me a mail at crito[AT]30loops.net.

python-docar is influenced by roar.

Example

The following code is a simplified example of how to use python-docar. We start using the Django backend:

# First declare your document
from webapp.models import EntryModel, AuthorModel
from docar import Document, Collection, fields

class Author(Document):
    name = fields.StringField()

    class Meta:
        backend_type = 'django'
        model = AuthorModel
        identifier = 'name'

class BlogEntry(Document):
    id = fields.NumberField()
    title = fields.StringField()
    body = fields.StringField()
    published = fields.BooleanField(default=False)
    author = fields.ForeignDocument(Author)

    class Meta:
        backend_type = 'django'
        model = EntryModel
        #identifier = 'id'  # The identifier defaults to 'id'

# You can also declare collections of documents
class Blog(Collection):
    document = BlogEntry

You can use those documents in the views of your application:

from webapp.documents import Author, BlogEntry, Blog

entry = BlogEntry({'id': 1})

# Bind the document to a model
entry.fetch()

I can also change attributes of the document and save it back to the model:

entry.title = "20000 Leagues under the sea"
entry.save()  # --> saves to the django model backend

The render method renders the document into a normalized dictionary. Serializers take the normalized output, and transform it into the message format that is needed.:

# render the document as a json string
entry.render()

{
    "id": 1,
    "title": "20000 Leagues under the sea",
    "body": "The whole story about captain Nemo ...",
    "published": True,
    "author": {
        "name": "Jules Vernes",
    }
}

Installation

Clone yourself the latest source from github. Development happens fast, so its good to always go with the latest commit:

$ git clone git://github.com/30loops/python-docar.git
$ cd python-docar
$ sudo python setup.py install

Development

This module comes along with a thorough test suite. Run it the following way:

$ python setup.py nosetests

Documentation

To build the documentation you need sphinx installed:

$ cd docs
$ make html

You find the documentation in docs/_build/html/.

Disclaimer

The use of this software comes without any warranty. It is released under a BSD license. See LICENSE for details.

Release History

Release History

0.9.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
docar-0.9.1.tar.gz (230.6 kB) Copy SHA256 Checksum SHA256 Source Oct 1, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting