forked from jfinkels/flask-restless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
213 lines (138 loc) · 6.84 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Flask-Restless #
## Introduction ##
This is Flask-Restless, a [Flask][1] extension which facilitates the creation
of ReSTful JSON APIs. It is compatible with models which have been defined
using either [SQLAlchemy][sa] or [Flask-SQLAlchemy][fsa].
This document contains some brief instructions concerning installation of
requirements, installation of this extension, configuration and usage of this
extension, and building of documentation.
For more information, check the World Wide Web!
* [Documentation](http://readthedocs.org/docs/flask-restless)
* [Python Package Index listing](http://pypi.python.org/pypi/Flask-Restless)
* [Source code repository](http://github.com/jfinkels/flask-restless)
[![Build status](https://secure.travis-ci.org/jfinkels/flask-restless.png)](http://travis-ci.org/jfinkels/flask-restless)
[1]: http://flask.pocoo.org
[sa]: http://sqlalchemy.org
[fsa]: http://packages.python.org/Flask-SQLAlchemy
## Copyright license ##
The code comprising this program is copyright 2011 Lincoln de Sousa and
copyright 2012, 2013, and 2014 Jeffrey Finkelstein, and is dual-licensed under
the following two copyright licenses:
* the GNU Affero General Public License, either version 3 or (at your option)
any later version
* the 3-clause BSD License
For more information, see the files `LICENSE.AGPL` and `LICENSE.BSD` in this
directory.
## Contents ##
This is a partial listing of the contents of this package.
* `LICENSE.AGPL` - one possible copyright license under which this program is
distributed to you (the GNU Affero General Public License version 3)
* `LICENSE.BSD` - another possible copyright license under which this program
is distributed to you (the 3-clause BSD License)
* `docs/` - the Sphinx documentation for Flask-Restless
* `examples/` - example applications of Flask-Restless
* `flask_restless/` - the Python package containing the extension
* `README.md` - this file
* `setup.py` - Python setuptools configuration file for packaging this
extension
* `tests/` - unit tests for Flask-Restless
The `flask_restless` directory is a Python package containing the following
files:
* `helpers.py` - utility functions, mainly for performing introspection on
SQLAlchemy objects
* `manager.py` - contains the main class which end users will utilize to create
ReSTful APIs for their database models
* `search.py` - functions and classes which facilitate searching the database
on requests which require a search
* `views.py` - the view class which implements the ReSTful API
## Installing ##
This application requires [Python][4] version 2.6, 2.7 or 3.3. Python 3.2 is
not supported by Flask and therefore cannot be supported by Flask-Restless.
This application requires the following libraries to be installed:
* [Flask][1] version 0.10 or greater
* [SQLAlchemy][sa]
* [python-dateutil][5] version greater than 2.0
* [Flask-SQLAlchemy][fsa] only if your models are defined using Flask-SQLAlchemy
These requirements are also listed in the `requirements.txt` file. Using `pip`
is probably the easiest way to install these:
pip install -r requirements.txt
or
pip install Flask Flask-SQLAlchemy python-dateutil sqlalchemy
[4]: http://www.python.org/
[5]: http://labix.org/python-dateutil
## Building as a Python egg ##
This package can be built, installed, etc. as a Python egg using the provided
`setup.py` script. For more information, run
python setup.py --help
## How to use ##
For information on how to use this extension, build the documentation here or
[view it on the Web](http://readthedocs.org/docs/flask-restless).
## Testing ##
Running the unit tests requires the [nosetests][n] library. This requirement is
also listed in the `requirements-test.txt` file.
Using `pip` is probably the easiest way to install this:
pip install -r requirements-test.txt
or
pip install nose
The Python unit tests are contained in the `tests/` directory (which is a
Python package). To run the test suite, run the command
python setup.py test
You can also run the unit tests in a less verbose way by doing
nosetests
[n]: https://nose.readthedocs.org/
### Test coverage ###
You can measure the test coverage by running
nosetests --with-coverage --cover-html --cover-html-dir=<somedir>
where <somedir> is the name of the directory in which the HTML formatted
coverage report will be written.
Measuring test coverage requires the [coverage.py][cov] package, which can be
installed like this:
pip install coverage
[cov]: http://nedbatchelder.com/code/coverage
### Testing validation ###
Validation is not provided directly by Flask-Restless, but it does provide a
way for users to indicate exceptions to catch. If you wish to test validation
of SQLAlchemy models with a real external SQLAlchemy validation library,
install the development version of [SAValidation][sav]:
pip install savalidation
This is only possible on Python 2. The test suite will automatically skip these
tests if `savalidation` is not installed or if you are using Python 3.
[sav]: http://pypi.python.org/pypi/SAValidation
## Building documentation ##
Flask-Restless requires the following program and supporting library to build
the documentation:
* [Sphinx][6]
* [sphinxcontrib-httpdomain][7], version 1.1.7 or greater
These requirements are also listed in the `requirements-doc.txt` file. Using
`pip` is probably the easiest way to install these:
pip install -r requirements-doc.txt
or
pip install sphinx "sphinxcontrib-httpdomain>=1.1.7"
The documentation is written for Sphinx in [reStructuredText][8] files in the
`docs/` directory. Documentation for each class and function is provided in the
docstring in the code.
The documentation uses the Flask Sphinx theme. It is included as a git
submodule of this project, rooted at `docs/_themes`. To get the themes, do
git submodule update --init
Now to build the documentation, run the command
python setup.py build_sphinx
in the top-level directory. The output can be viewed in a web browser by
opening `docs/_build/html/index.html`.
[6]: http://sphinx.pocoo.org/
[7]: http://packages.python.org/sphinxcontrib-httpdomain/
[8]: http://docutils.sourceforge.net/rst.html
## Authors ##
See the `AUTHORS` file for a list of people who have contributed to this code.
## Artwork ##
The `artwork/flask-restless-small.svg` and
`docs/_static/flask-restless-small.png` are licensed under the
[Creative Commons Attribute-ShareAlike 3.0 license][9]. The original image is a
scan of a (now public domain) illustration by Arthur Hopkins in a serial
edition of "The Return of the Native" by Thomas Hardy published in October
1878.
The `artwork/flask-restless.svg` and `docs/_static/flask-restless.png` are
licensed under the [Flask Artwork License][10].
[9]: http://creativecommons.org/licenses/by-sa/3.0
[10]: http://flask.pocoo.org/docs/license/#flask-artwork-license
## Contact ##
Jeffrey Finkelstein <[email protected]>