<commit_before>========
restless
========

.. image:: https://travis-ci.org/toastdriven/restless.png?branch=master
        :target: https://travis-ci.org/toastdriven/restless

A lightweight REST miniframework for Python.

Documentation is at http://restless.readthedocs.org/.

Works great with Django_, Flask_, Pyramid_ & Itty_, but should be useful for
many other Python web frameworks. Based on the lessons learned from Tastypie_
& other REST libraries.

.. _Django: http://djangoproject.com/
.. _Flask: http://flask.pocoo.org/
.. _Pyramid: http://www.pylonsproject.org/
.. _Itty: https://pypi.python.org/pypi/itty
.. _Tastypie: http://tastypieapi.org/


Features
========

* Small, fast codebase
* JSON output by default, but overridable
* RESTful
* Python 3.3+ (with shims to make broke-ass Python 2.6+ work)
* Flexible


Anti-Features
=============

(Things that will never be added...)

* Automatic ORM integration
* Authorization (per-object or not)
* Extensive filtering options
* XML output (though you can implement your own)
* Metaclasses
* Mixins
* HATEOAS


Why?
====

Quite simply, I care about creating flexible & RESTFul APIs. In building
Tastypie, I tried to create something extremely complete & comprehensive.
The result was writing a lot of hook methods (for easy extensibility) & a lot
of (perceived) bloat, as I tried to accommodate for everything people might
want/need in a flexible/overridable manner.

But in reality, all I really ever personally want are the RESTful verbs, JSON
serialization & the ability of override behavior.

This one is written for me, but maybe it's useful to you.


Manifesto
=========

Rather than try to build something that automatically does the typically
correct thing within each of the views, it's up to you to implement the bodies
of various HTTP methods.

Example code:

.. code:: python

    # posts/api.py
    from django.contrib.auth.models import User

    from restless.dj import DjangoResource

    from posts.models import Post


    class PostResource(DjangoResource):
        # Controls what data is included in the serialized output.
        preparer = Preparer(fields={
            'id': 'id',
            'title': 'title',
            'author': 'user.username',
            'body': 'content',
            'posted_on': 'posted_on',
        })

        # GET /
        def list(self):
            return Post.objects.all()

        # GET /pk/
        def detail(self, pk):
            return Post.objects.get(id=pk)
<commit_msg>Add forgotten import in the Manifesto example<commit_after>========
restless
========

.. image:: https://travis-ci.org/toastdriven/restless.png?branch=master
        :target: https://travis-ci.org/toastdriven/restless

A lightweight REST miniframework for Python.

Documentation is at http://restless.readthedocs.org/.

Works great with Django_, Flask_, Pyramid_ & Itty_, but should be useful for
many other Python web frameworks. Based on the lessons learned from Tastypie_
& other REST libraries.

.. _Django: http://djangoproject.com/
.. _Flask: http://flask.pocoo.org/
.. _Pyramid: http://www.pylonsproject.org/
.. _Itty: https://pypi.python.org/pypi/itty
.. _Tastypie: http://tastypieapi.org/


Features
========

* Small, fast codebase
* JSON output by default, but overridable
* RESTful
* Python 3.3+ (with shims to make broke-ass Python 2.6+ work)
* Flexible


Anti-Features
=============

(Things that will never be added...)

* Automatic ORM integration
* Authorization (per-object or not)
* Extensive filtering options
* XML output (though you can implement your own)
* Metaclasses
* Mixins
* HATEOAS


Why?
====

Quite simply, I care about creating flexible & RESTFul APIs. In building
Tastypie, I tried to create something extremely complete & comprehensive.
The result was writing a lot of hook methods (for easy extensibility) & a lot
of (perceived) bloat, as I tried to accommodate for everything people might
want/need in a flexible/overridable manner.

But in reality, all I really ever personally want are the RESTful verbs, JSON
serialization & the ability of override behavior.

This one is written for me, but maybe it's useful to you.


Manifesto
=========

Rather than try to build something that automatically does the typically
correct thing within each of the views, it's up to you to implement the bodies
of various HTTP methods.

Example code:

.. code:: python

    # posts/api.py
    from django.contrib.auth.models import User

    from restless.dj import DjangoResource
    from restless.preparers import Preparer

    from posts.models import Post


    class PostResource(DjangoResource):
        # Controls what data is included in the serialized output.
        preparer = Preparer(fields={
            'id': 'id',
            'title': 'title',
            'author': 'user.username',
            'body': 'content',
            'posted_on': 'posted_on',
        })

        # GET /
        def list(self):
            return Post.objects.all()

        # GET /pk/
        def detail(self, pk):
            return Post.objects.get(id=pk)

{'fraction_non_alphanumeric': 0.10626971608832808, 'fraction_numerical': 0.0015772870662460567, 'mean_word_length': 3.1995033112582782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1237813', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1442, 'n_words': 550}