Commit c2aa82c2 authored by Jacek Furmankiewicz's avatar Jacek Furmankiewicz

adding sphinx docs to gh page

parent 06fb4283
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>corepost</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/corepost</path>
</pydev_pathproperty>
</pydev_project>
Argument validation
===================
CorePost integrates the popular 'formencode' package to implement form and query argument validation.
Validators can be specified using a *formencode* Schema object, or via custom field-specific validators.
Example::
from corepost.web import validate, route
from corepost.enums import Http
from formencode import Schema, validators
class TestSchema(Schema):
allow_extra_fields = True
childId = validators.Regex(regex="^value1|value2$")
class MyApp():
@route("/validate/<int:rootId>/schema",Http.POST)
@validate(schema=TestSchema())
def postValidateSchema(self,request,rootId,childId,**kwargs):
'''Validate using a common schema'''
return "%s - %s - %s" % (rootId,childId,kwargs)
@route("/validate/<int:rootId>/custom",Http.POST)
@validate(childId=validators.Regex(regex="^value1|value2$"))
def postValidateCustom(self,request,rootId,childId,**kwargs):
'''Validate using argument-specific validators'''
return "%s - %s - %s" % (rootId,childId,kwargs)
Please see the *FormEncode* documentation:
http://www.formencode.org/en/latest/Validator.html
for list of available validators:
* Common : http://www.formencode.org/en/latest/modules/validators.html#module-formencode.validators
* National : http://www.formencode.org/en/latest/modules/national.html#module-formencode.national
Asynchronous Operations
=================
@defer.inlineCallbacks support
-----------------------
If you want a deferred async method, just use *defer.returnValue()*::
@route("/",Http.GET)
@defer.inlineCallbacks
def root(self,request,**kwargs):
val1 = yield db.query("SELECT ....")
val2 = yield db.query("SELECT ....")
defer.returnValue(val1 + val2)
This is standard Twisted functionality.
Content types
=============
CorePost integrates support for JSON, YAML and XML (partially) based on request content types.
Parsing of incoming content
---------------------------
Based on the incoming content type in POST/PUT requests,
the body will be automatically parsed to JSON, YAML and XML (ElementTree)
* request.json
* request.yaml
* request.xml
and attached to the request::
@route("/post/json",(Http.POST,Http.PUT))
def test_json(self,request,**kwargs):
return "%s" % json.dumps(request.json)
@route("/post/xml",(Http.POST,Http.PUT))
def test_xml(self,request,**kwargs):
return "%s" % ElementTree.tostring(request.xml)
@route("/post/yaml",(Http.POST,Http.PUT))
def test_yaml(self,request,**kwargs):
return "%s" % yaml.dump(request.yaml)
Converting Python objects to expected content type
--------------------------------------------------
Instead of returning string responses, the code can just return Python objects.
Depending whether the caller can accept JSON (default) or YAML, the Python objects will be automatically converted::
@route("/return/by/accept")
def test_return_content_by_accepts(self,request,**kwargs):
val = [{"test1":"Test1"},{"test2":"Test2"}]
return val
Calling this URL with "Accept: application/json" will return:
::
[{"test1": "Test1"}, {"test2": "Test2"}]
Calling it with "Accept: text/yaml" will return:
::
- {test1: Test1}
- {test2: Test2}
Filters
=======
There is support for CorePost resource filters via the two following *corepost.filter* interfaces::
class IRequestFilter(Interface):
"""Request filter interface"""
def filterRequest(self,request):
"""Allows to intercept and change an incoming request"""
pass
class IResponseFilter(Interface):
"""Response filter interface"""
def filterResponse(self,request,response):
"""Allows to intercept and change an outgoing response"""
pass
A filter class can implement either of them or both (for a wrap around filter), e.g.::
class AddCustomHeaderFilter():
"""Implements a request filter that adds a custom header to the incoming request"""
zope.interface.implements(IRequestFilter)
def filterRequest(self,request):
request.received_headers["Custom-Header"] = "Custom Header Value"
class Change404to503Filter():
"""Implements just a response filter that changes 404 to 503 statuses"""
zope.interface.implements(IResponseFilter)
def filterResponse(self,request,response):
if response.code == 404:
response.code = 503
class WrapAroundFilter():
"""Implements both types of filters in one class"""
zope.interface.implements(IRequestFilter,IResponseFilter)
def filterRequest(self,request):
request.received_headers["X-Wrap-Input"] = "Input"
def filterResponse(self,request,response):
response.headers["X-Wrap-Output"] = "Output"
In order to activate the filters on a RESTResource instance, you need to pass a list of them in the constructor as the *filters* parameter, e.g.::
class FilterApp:
@route("/",Http.GET)
def root(self,request,**kwargs):
return request.received_headers
def run_filter_app():
app = RESTResource(services=(FilterApp(),),filters=(Change404to503Filter(),AddCustomHeaderFilter(),WrapAroundFilter(),))
app.run(8083)
HTTP codes
==========
By default, CorePost returns the appropriate HTTP code based on the HTTP method:
Success:
* 200 (OK) - GET, DELETE, PUT
* 201 (Created) - POST
Errors:
* 404 - not able to match any URL.
* 400 - missing mandatory argument (driven from the arguments on the actual functions)
* 400 - argument failed validation
* 500 - server error
CorePost CorePost
==================================== ====================================
REST micro-framework, powered by the asynchronous Twisted Web APIs A Twisted REST micro-framework
------------------------------------------------------------------ ------------------------------
Contents:
.. toctree:: .. toctree::
:maxdepth: 4 :maxdepth: 4
intro intro
features
Indices and tables Features
================== --------
* :ref:`genindex` .. toctree::
* :ref:`modindex` :maxdepth: 4
* :ref:`search`
url_routing
arguments
content_types
filters
http_codes
async
modules
Modular REST applications
=========================
A typical case in REST is where you have parent/child resources (business entities), e.g.
::
Customer
Customer Address
Customer Phone
Customer Order
Customer Invoice
Customer Invoice Payment
etc.
This can create a URL structure like:
::
/customer
/customer/<customerId>
/customer/<customerId>/address
/customer/<customerId>/address/<addressId>
/customer/<customerId>/phone
/customer/<customerId>/phone/<phoneId>
/customer/<customerId>/invoice
/customer/<customerId>/invoice/<invoiceId>
/customer/<customerId>/invoice/<invoiceId>/payment
/customer/<customerId>/invoice/<invoiceId>/payment/<paymentId>
CorePost allows you to write small, modular classes that implement a REST service for just a single entity,
driven by URL paths with dynamic elements in them (e.g. the *customerId*, *invoiceId*, *paymentId* path parameters in the sample above).
You do not have to mesh all these different entities in a single class.
At the end, you wrap all of the different REST services in a single *RESTResource* object (which extends the regular Twisted Web Resource object)
and it takes care of routing the request to the appropriate class.
Here is a full-blown example of two REST services for Customer and Customer Address::
from corepost import Response, NotFoundException, AlreadyExistsException
from corepost.web import RESTResource, route, Http
class CustomerRESTService():
path = "/customer"
@route("/")
def getAll(self,request):
return DB.getAllCustomers()
@route("/<customerId>")
def get(self,request,customerId):
return DB.getCustomer(customerId)
@route("/",Http.POST)
def post(self,request,customerId,firstName,lastName):
customer = Customer(customerId, firstName, lastName)
DB.saveCustomer(customer)
return Response(201)
@route("/<customerId>",Http.PUT)
def put(self,request,customerId,firstName,lastName):
c = DB.getCustomer(customerId)
(c.firstName,c.lastName) = (firstName,lastName)
return Response(200)
@route("/<customerId>",Http.DELETE)
def delete(self,request,customerId):
DB.deleteCustomer(customerId)
return Response(200)
@route("/",Http.DELETE)
def deleteAll(self,request):
DB.deleteAllCustomers()
return Response(200)
class CustomerAddressRESTService():
path = "/customer/<customerId>/address"
@route("/")
def getAll(self,request,customerId):
return DB.getCustomer(customerId).addresses
@route("/<addressId>")
def get(self,request,customerId,addressId):
return DB.getCustomerAddress(customerId, addressId)
@route("/",Http.POST)
def post(self,request,customerId,addressId,streetNumber,streetName,stateCode,countryCode):
c = DB.getCustomer(customerId)
address = CustomerAddress(streetNumber,streetName,stateCode,countryCode)
c.addresses[addressId] = address
return Response(201)
@route("/<addressId>",Http.PUT)
def put(self,request,customerId,addressId,streetNumber,streetName,stateCode,countryCode):
address = DB.getCustomerAddress(customerId, addressId)
(address.streetNumber,address.streetName,address.stateCode,address.countryCode) = (streetNumber,streetName,stateCode,countryCode)
return Response(200)
@route("/<addressId>",Http.DELETE)
def delete(self,request,customerId,addressId):
DB.getCustomerAddress(customerId, addressId) #validate address exists
del(DB.getCustomer(customerId).addresses[addressId])
return Response(200)
@route("/",Http.DELETE)
def deleteAll(self,request,customerId):
c = DB.getCustomer(customerId)
c.addresses = {}
return Response(200)
def run_rest_app():
app = RESTResource((CustomerRESTService(),CustomerAddressRESTService()))
app.run(8080)
if __name__ == "__main__":
run_rest_app()
URL Routing
=================
@route decorator
----------------
Via a simple *@route* decorator you can automatically route *twisted.web* Request objects to your class method
based on URL (with dynamic paths), HTTP method, expected content type, etc::
from corepost.web import route, RESTResource
from corepost.enums import Http
class RESTService():
@route("/",Http.GET)
def root(self,request,**kwargs):
return request.path
@route("/test",Http.GET)
def test(self,request,**kwargs):
return request.path
@route("/test/<int:numericid>",Http.GET)
def test_get_resources(self,request,numericid,**kwargs):
return "%s" % numericid
if __name__ == '__main__':
app = RESTResource((RESTService,))
app.run()
*Note*:
This piece of code::
app.run()
is just for convenience when showing code samples and writing unit tests.
In a real production application you would use existing Twisted *twistd* functionality:
* http://twistedmatrix.com/documents/current/core/howto/basics.html
* http://twistedmatrix.com/documents/current/core/howto/application.html
* http://twistedmatrix.com/documents/current/core/howto/tap.html
Path argument extraction
----------------
CorePort can easily extract path arguments from an URL and convert them to the desired type.
The supported types are:
* *int*
* *float*
* *string*
Example::
@route("/int/<int:intarg>/float/<float:floatarg>/string/<stringarg>",Http.GET)
def test(self,request,intarg,floatarg,stringarg,**kwargs):
pass
Routing requests by incoming content type
-----------------------------------------
Based on the incoming content type in POST/PUT requests, the *same* URL can be hooked up to different router methods::
@route("/post/by/content",(Http.POST,Http.PUT),MediaType.APPLICATION_JSON)
def test_content_app_json(self,request,**kwargs):
return request.received_headers[HttpHeader.CONTENT_TYPE]
@route("/post/by/content",(Http.POST,Http.PUT),(MediaType.TEXT_XML,MediaType.APPLICATION_XML))
def test_content_xml(self,request,**kwargs):
return request.received_headers[HttpHeader.CONTENT_TYPE]
@route("/post/by/content",(Http.POST,Http.PUT),MediaType.TEXT_YAML)
def test_content_yaml(self,request,**kwargs):
return request.received_headers[HttpHeader.CONTENT_TYPE]
@route("/post/by/content",(Http.POST,Http.PUT))
def test_content_catch_all(self,request,**kwargs):
return MediaType.WILDCARD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Argument validation &mdash; CorePost 0.0.14 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="CorePost 0.0.14 documentation" href="index.html" />
<link rel="next" title="Content types" href="content_types.html" />
<link rel="prev" title="URL Routing" href="url_routing.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="content_types.html" title="Content types"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="url_routing.html" title="URL Routing"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="argument-validation">
<h1>Argument validation<a class="headerlink" href="#argument-validation" title="Permalink to this headline"></a></h1>
<p>CorePost integrates the popular &#8216;formencode&#8217; package to implement form and query argument validation.
Validators can be specified using a <em>formencode</em> Schema object, or via custom field-specific validators.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">corepost.web</span> <span class="kn">import</span> <span class="n">validate</span><span class="p">,</span> <span class="n">route</span>
<span class="kn">from</span> <span class="nn">corepost.enums</span> <span class="kn">import</span> <span class="n">Http</span>
<span class="kn">from</span> <span class="nn">formencode</span> <span class="kn">import</span> <span class="n">Schema</span><span class="p">,</span> <span class="n">validators</span>
<span class="k">class</span> <span class="nc">TestSchema</span><span class="p">(</span><span class="n">Schema</span><span class="p">):</span>
<span class="n">allow_extra_fields</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">childId</span> <span class="o">=</span> <span class="n">validators</span><span class="o">.</span><span class="n">Regex</span><span class="p">(</span><span class="n">regex</span><span class="o">=</span><span class="s">&quot;^value1|value2$&quot;</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">MyApp</span><span class="p">():</span>
<span class="nd">@route</span><span class="p">(</span><span class="s">&quot;/validate/&lt;int:rootId&gt;/schema&quot;</span><span class="p">,</span><span class="n">Http</span><span class="o">.</span><span class="n">POST</span><span class="p">)</span>
<span class="nd">@validate</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">TestSchema</span><span class="p">())</span>
<span class="k">def</span> <span class="nf">postValidateSchema</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">request</span><span class="p">,</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;Validate using a common schema&#39;&#39;&#39;</span>
<span class="k">return</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="n">kwargs</span><span class="p">)</span>
<span class="nd">@route</span><span class="p">(</span><span class="s">&quot;/validate/&lt;int:rootId&gt;/custom&quot;</span><span class="p">,</span><span class="n">Http</span><span class="o">.</span><span class="n">POST</span><span class="p">)</span>
<span class="nd">@validate</span><span class="p">(</span><span class="n">childId</span><span class="o">=</span><span class="n">validators</span><span class="o">.</span><span class="n">Regex</span><span class="p">(</span><span class="n">regex</span><span class="o">=</span><span class="s">&quot;^value1|value2$&quot;</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">postValidateCustom</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">request</span><span class="p">,</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;Validate using argument-specific validators&#39;&#39;&#39;</span>
<span class="k">return</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>
</div>
<p>Please see the <em>FormEncode</em> documentation:</p>
<p><a class="reference external" href="http://www.formencode.org/en/latest/Validator.html">http://www.formencode.org/en/latest/Validator.html</a></p>
<p>for list of available validators:</p>
<ul class="simple">
<li>Common : <a class="reference external" href="http://www.formencode.org/en/latest/modules/validators.html#module-formencode.validators">http://www.formencode.org/en/latest/modules/validators.html#module-formencode.validators</a></li>
<li>National : <a class="reference external" href="http://www.formencode.org/en/latest/modules/national.html#module-formencode.national">http://www.formencode.org/en/latest/modules/national.html#module-formencode.national</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="url_routing.html"
title="previous chapter">URL Routing</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="content_types.html"
title="next chapter">Content types</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/arguments.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="content_types.html" title="Content types"
>next</a> |</li>
<li class="right" >
<a href="url_routing.html" title="URL Routing"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2012, Jacek Furmankiewicz.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Asynchronous Operations &mdash; CorePost 0.0.14 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="CorePost 0.0.14 documentation" href="index.html" />
<link rel="prev" title="HTTP codes" href="http_codes.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="asynchronous-operations">
<h1>Asynchronous Operations<a class="headerlink" href="#asynchronous-operations" title="Permalink to this headline"></a></h1>
<div class="section" id="defer-inlinecallbacks-support">
<h2>&#64;defer.inlineCallbacks support<a class="headerlink" href="#defer-inlinecallbacks-support" title="Permalink to this headline"></a></h2>
<p>If you want a deferred async method, just use <em>defer.returnValue()</em>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="nd">@route</span><span class="p">(</span><span class="s">&quot;/&quot;</span><span class="p">,</span><span class="n">Http</span><span class="o">.</span><span class="n">GET</span><span class="p">)</span>
<span class="nd">@defer.inlineCallbacks</span>
<span class="k">def</span> <span class="nf">root</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">request</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">val1</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">db</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s">&quot;SELECT ....&quot;</span><span class="p">)</span>
<span class="n">val2</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">db</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s">&quot;SELECT ....&quot;</span><span class="p">)</span>
<span class="n">defer</span><span class="o">.</span><span class="n">returnValue</span><span class="p">(</span><span class="n">val1</span> <span class="o">+</span> <span class="n">val2</span><span class="p">)</span>
</pre></div>
</div>
<p>This is standard Twisted functionality.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Asynchronous Operations</a><ul>
<li><a class="reference internal" href="#defer-inlinecallbacks-support">&#64;defer.inlineCallbacks support</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="http_codes.html"
title="previous chapter">HTTP codes</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/async.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2012, Jacek Furmankiewicz.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
</div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 85f542c5812a83c65e62d87283293d45
tags: fbb0d17656682115ca4d033fb2f83ba1
Argument validation
===================
CorePost integrates the popular 'formencode' package to implement form and query argument validation.
Validators can be specified using a *formencode* Schema object, or via custom field-specific validators.
Example::
from corepost.web import validate, route
from corepost.enums import Http
from formencode import Schema, validators
class TestSchema(Schema):
allow_extra_fields = True
childId = validators.Regex(regex="^value1|value2$")
class MyApp():
@route("/validate/<int:rootId>/schema",Http.POST)
@validate(schema=TestSchema())
def postValidateSchema(self,request,rootId,childId,**kwargs):
'''Validate using a common schema'''
return "%s - %s - %s" % (rootId,childId,kwargs)
@route("/validate/<int:rootId>/custom",Http.POST)
@validate(childId=validators.Regex(regex="^value1|value2$"))
def postValidateCustom(self,request,rootId,childId,**kwargs):
'''Validate using argument-specific validators'''
return "%s - %s - %s" % (rootId,childId,kwargs)
Please see the *FormEncode* documentation:
http://www.formencode.org/en/latest/Validator.html
for list of available validators:
* Common : http://www.formencode.org/en/latest/modules/validators.html#module-formencode.validators
* National : http://www.formencode.org/en/latest/modules/national.html#module-formencode.national
Asynchronous Operations
=================
@defer.inlineCallbacks support
-----------------------
If you want a deferred async method, just use *defer.returnValue()*::
@route("/",Http.GET)
@defer.inlineCallbacks
def root(self,request,**kwargs):
val1 = yield db.query("SELECT ....")
val2 = yield db.query("SELECT ....")
defer.returnValue(val1 + val2)
This is standard Twisted functionality.
Content types
=============
CorePost integrates support for JSON, YAML and XML (partially) based on request content types.
Parsing of incoming content
---------------------------
Based on the incoming content type in POST/PUT requests,
the body will be automatically parsed to JSON, YAML and XML (ElementTree)
* request.json
* request.yaml
* request.xml
and attached to the request::
@route("/post/json",(Http.POST,Http.PUT))
def test_json(self,request,**kwargs):
return "%s" % json.dumps(request.json)
@route("/post/xml",(Http.POST,Http.PUT))
def test_xml(self,request,**kwargs):
return "%s" % ElementTree.tostring(request.xml)
@route("/post/yaml",(Http.POST,Http.PUT))
def test_yaml(self,request,**kwargs):
return "%s" % yaml.dump(request.yaml)
Converting Python objects to expected content type
--------------------------------------------------
Instead of returning string responses, the code can just return Python objects.
Depending whether the caller can accept JSON (default) or YAML, the Python objects will be automatically converted::
@route("/return/by/accept")
def test_return_content_by_accepts(self,request,**kwargs):
val = [{"test1":"Test1"},{"test2":"Test2"}]
return val
Calling this URL with "Accept: application/json" will return:
::
[{"test1": "Test1"}, {"test2": "Test2"}]
Calling it with "Accept: text/yaml" will return:
::
- {test1: Test1}
- {test2: Test2}
This diff is collapsed.
Filters
=======
There is support for CorePost resource filters via the two following *corepost.filter* interfaces::
class IRequestFilter(Interface):
"""Request filter interface"""
def filterRequest(self,request):
"""Allows to intercept and change an incoming request"""
pass
class IResponseFilter(Interface):
"""Response filter interface"""
def filterResponse(self,request,response):
"""Allows to intercept and change an outgoing response"""
pass
A filter class can implement either of them or both (for a wrap around filter), e.g.::
class AddCustomHeaderFilter():
"""Implements a request filter that adds a custom header to the incoming request"""
zope.interface.implements(IRequestFilter)
def filterRequest(self,request):
request.received_headers["Custom-Header"] = "Custom Header Value"
class Change404to503Filter():
"""Implements just a response filter that changes 404 to 503 statuses"""
zope.interface.implements(IResponseFilter)
def filterResponse(self,request,response):
if response.code == 404:
response.code = 503
class WrapAroundFilter():
"""Implements both types of filters in one class"""
zope.interface.implements(IRequestFilter,IResponseFilter)
def filterRequest(self,request):
request.received_headers["X-Wrap-Input"] = "Input"
def filterResponse(self,request,response):
response.headers["X-Wrap-Output"] = "Output"
In order to activate the filters on a RESTResource instance, you need to pass a list of them in the constructor as the *filters* parameter, e.g.::
class FilterApp:
@route("/",Http.GET)
def root(self,request,**kwargs):
return request.received_headers
def run_filter_app():
app = RESTResource(services=(FilterApp(),),filters=(Change404to503Filter(),AddCustomHeaderFilter(),WrapAroundFilter(),))
app.run(8083)
HTTP codes
==========
By default, CorePost returns the appropriate HTTP code based on the HTTP method:
Success:
* 200 (OK) - GET, DELETE, PUT
* 201 (Created) - POST
Errors:
* 404 - not able to match any URL.
* 400 - missing mandatory argument (driven from the arguments on the actual functions)
* 400 - argument failed validation
* 500 - server error
CorePost
====================================
A Twisted REST micro-framework
------------------------------
.. toctree::
:maxdepth: 4
intro
Features
--------
.. toctree::
:maxdepth: 4
url_routing
arguments
content_types
filters
http_codes
async
modules
Introduction
============
What is CorePost?
-----------------
CorePost is a Python REST micro-framework. It is meant for building enterprise-grade REST server applications that provide
API services to other applications and/or a UI layer (coded in any framework or language).
More importantly, CorePost is an asynchronous I/O web framework (similar to Node.js).
Hence it relies on asynchronous I/O operations, which are extremely efficient, but somewhat more complicated to code.
Fortunately, CorePost does not create it's own async I/O library, but instead uses under the mature, well documented
and extremely well designed Twisted library, in particular its web layer (known simply as twisted.web)
Coupled with a JIT runtime like PyPy, this should give you the ability to develop REST server side applications
that will be extremely performant in production, yet (hopefully) fun and productive to develop.
What is Twisted?
----------------
Twisted is a very mature Python async I/O network toolkit:
http://twistedmatrix.com/trac/
Understanding core principles behind Twisted and its APIs is required (at least at a basic level) before coding any CorePost application.
Hence we recommend either reading the very thorough developer's guide:
http://twistedmatrix.com/documents/current/core/howto/book.pdf
or the excellent Twisted tutorials from Dave Peticolas:
http://krondo.com/blog/?page_id=1327
In particular, understanding the core Twisted Deferred object (and its productive inline callback approach) are crucial
to productive usage of Twisted APIs for writing asynchronous web applications.
What does CorePost add on top of Twisted Web?
---------------------------------------------
Mostly productivity features that take of low-level plumbing such as:
* routing request to handler methods
* automatic parsing of JSON/YAML/XML input
* automatic conversion of Python objects and classes to JSON / YAML / XML formats
* simplified exception handling
* custom request / response filters
However, this is a very thin layer. Once you get to write some serious code that interacts with an external system (e.g. a SQL database)
you are writing a hard-code Twisted web application. CorePost is just there to make it easier for you and let you focus on business logic,
while letting it take care of common required plumbing. That's it.
A CorePost application is nothing more than a *twisted.web* application under the hood.
Why would I use CorePost instead of Node.js?
--------------------------------------------
As you develop more Twisted code, you will realize how its elegant and powerful *Deferred* object
(and especially inline callbacks) make developing *readable* asynchronous code much more pleasant than any other solution.
\ No newline at end of file
Modular REST applications
=========================
A typical case in REST is where you have parent/child resources (business entities), e.g.
::
Customer
Customer Address
Customer Phone
Customer Order
Customer Invoice
Customer Invoice Payment
etc.
This can create a URL structure like:
::
/customer
/customer/<customerId>
/customer/<customerId>/address
/customer/<customerId>/address/<addressId>
/customer/<customerId>/phone
/customer/<customerId>/phone/<phoneId>
/customer/<customerId>/invoice
/customer/<customerId>/invoice/<invoiceId>
/customer/<customerId>/invoice/<invoiceId>/payment
/customer/<customerId>/invoice/<invoiceId>/payment/<paymentId>
CorePost allows you to write small, modular classes that implement a REST service for just a single entity,
driven by URL paths with dynamic elements in them (e.g. the *customerId*, *invoiceId*, *paymentId* path parameters in the sample above).
You do not have to mesh all these different entities in a single class.
At the end, you wrap all of the different REST services in a single *RESTResource* object (which extends the regular Twisted Web Resource object)
and it takes care of routing the request to the appropriate class.
Here is a full-blown example of two REST services for Customer and Customer Address::
from corepost import Response, NotFoundException, AlreadyExistsException
from corepost.web import RESTResource, route, Http
class CustomerRESTService():
path = "/customer"
@route("/")
def getAll(self,request):
return DB.getAllCustomers()
@route("/<customerId>")
def get(self,request,customerId):
return DB.getCustomer(customerId)
@route("/",Http.POST)
def post(self,request,customerId,firstName,lastName):
customer = Customer(customerId, firstName, lastName)
DB.saveCustomer(customer)
return Response(201)
@route("/<customerId>",Http.PUT)
def put(self,request,customerId,firstName,lastName):
c = DB.getCustomer(customerId)
(c.firstName,c.lastName) = (firstName,lastName)
return Response(200)
@route("/<customerId>",Http.DELETE)
def delete(self,request,customerId):
DB.deleteCustomer(customerId)
return Response(200)
@route("/",Http.DELETE)
def deleteAll(self,request):
DB.deleteAllCustomers()
return Response(200)
class CustomerAddressRESTService():
path = "/customer/<customerId>/address"
@route("/")
def getAll(self,request,customerId):
return DB.getCustomer(customerId).addresses
@route("/<addressId>")
def get(self,request,customerId,addressId):
return DB.getCustomerAddress(customerId, addressId)
@route("/",Http.POST)
def post(self,request,customerId,addressId,streetNumber,streetName,stateCode,countryCode):
c = DB.getCustomer(customerId)
address = CustomerAddress(streetNumber,streetName,stateCode,countryCode)
c.addresses[addressId] = address
return Response(201)
@route("/<addressId>",Http.PUT)
def put(self,request,customerId,addressId,streetNumber,streetName,stateCode,countryCode):
address = DB.getCustomerAddress(customerId, addressId)
(address.streetNumber,address.streetName,address.stateCode,address.countryCode) = (streetNumber,streetName,stateCode,countryCode)
return Response(200)
@route("/<addressId>",Http.DELETE)
def delete(self,request,customerId,addressId):
DB.getCustomerAddress(customerId, addressId) #validate address exists
del(DB.getCustomer(customerId).addresses[addressId])
return Response(200)
@route("/",Http.DELETE)
def deleteAll(self,request,customerId):
c = DB.getCustomer(customerId)
c.addresses = {}
return Response(200)
def run_rest_app():
app = RESTResource((CustomerRESTService(),CustomerAddressRESTService()))
app.run(8080)
if __name__ == "__main__":
run_rest_app()
URL Routing
=================
@route decorator
----------------
Via a simple *@route* decorator you can automatically route *twisted.web* Request objects to your class method
based on URL (with dynamic paths), HTTP method, expected content type, etc::
from corepost.web import route, RESTResource
from corepost.enums import Http
class RESTService():
@route("/",Http.GET)
def root(self,request,**kwargs):
return request.path
@route("/test",Http.GET)
def test(self,request,**kwargs):
return request.path
@route("/test/<int:numericid>",Http.GET)
def test_get_resources(self,request,numericid,**kwargs):
return "%s" % numericid
if __name__ == '__main__':
app = RESTResource((RESTService,))
app.run()
*Note*:
This piece of code::
app.run()
is just for convenience when showing code samples and writing unit tests.
In a real production application you would use existing Twisted *twistd* functionality:
* http://twistedmatrix.com/documents/current/core/howto/basics.html
* http://twistedmatrix.com/documents/current/core/howto/application.html
* http://twistedmatrix.com/documents/current/core/howto/tap.html
Path argument extraction
----------------
CorePort can easily extract path arguments from an URL and convert them to the desired type.
The supported types are:
* *int*
* *float*
* *string*
Example::
@route("/int/<int:intarg>/float/<float:floatarg>/string/<stringarg>",Http.GET)
def test(self,request,intarg,floatarg,stringarg,**kwargs):
pass
Routing requests by incoming content type
-----------------------------------------
Based on the incoming content type in POST/PUT requests, the *same* URL can be hooked up to different router methods::
@route("/post/by/content",(Http.POST,Http.PUT),MediaType.APPLICATION_JSON)
def test_content_app_json(self,request,**kwargs):
return request.received_headers[HttpHeader.CONTENT_TYPE]
@route("/post/by/content",(Http.POST,Http.PUT),(MediaType.TEXT_XML,MediaType.APPLICATION_XML))
def test_content_xml(self,request,**kwargs):
return request.received_headers[HttpHeader.CONTENT_TYPE]
@route("/post/by/content",(Http.POST,Http.PUT),MediaType.TEXT_YAML)
def test_content_yaml(self,request,**kwargs):
return request.received_headers[HttpHeader.CONTENT_TYPE]
@route("/post/by/content",(Http.POST,Http.PUT))
def test_content_catch_all(self,request,**kwargs):
return MediaType.WILDCARD
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar input[type="text"] {
width: 170px;
}
div.sphinxsidebar input[type="submit"] {
width: 30px;
}
img {
border: 0;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li div.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable dl, table.indextable dd {
margin-top: 0;
margin-bottom: 0;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- general body styles --------------------------------------------------- */
a.headerlink {
visibility: hidden;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.field-list ul {
padding-left: 1em;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px 7px 0 7px;
background-color: #ffe;
width: 40%;
float: right;
}
p.sidebar-title {
font-weight: bold;
}
/* -- topics ---------------------------------------------------------------- */
div.topic {
border: 1px solid #ccc;
padding: 7px 7px 0 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
div.admonition dl {
margin-bottom: 0;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
border: 0;
border-collapse: collapse;
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
table.field-list td, table.field-list th {
border: 0 !important;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
dl {
margin-bottom: 15px;
}
dd p {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dt:target, .highlighted {
background-color: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.refcount {
color: #060;
}
.optional {
font-size: 1.3em;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
td.linenos pre {
padding: 5px 0px;
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
margin-left: 0.5em;
}
table.highlighttable td {
padding: 0 0.5em 0 0.5em;
}
tt.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
tt.descclassname {
background-color: transparent;
}
tt.xref, a tt {
background-color: transparent;
font-weight: bold;
}
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}
\ No newline at end of file
/*
* default.css_t
* ~~~~~~~~~~~~~
*
* Sphinx stylesheet -- default theme.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@import url("basic.css");
/* -- page layout ----------------------------------------------------------- */
body {
font-family: sans-serif;
font-size: 100%;
background-color: #11303d;
color: #000;
margin: 0;
padding: 0;
}
div.document {
background-color: #1c4e63;
}
div.documentwrapper {
float: left;
width: 100%;
}
div.bodywrapper {
margin: 0 0 0 230px;
}
div.body {
background-color: #ffffff;
color: #000000;
padding: 0 20px 30px 20px;
}
div.footer {
color: #ffffff;
width: 100%;
padding: 9px 0 9px 0;
text-align: center;
font-size: 75%;
}
div.footer a {
color: #ffffff;
text-decoration: underline;
}
div.related {
background-color: #133f52;
line-height: 30px;
color: #ffffff;
}
div.related a {
color: #ffffff;
}
div.sphinxsidebar {
}
div.sphinxsidebar h3 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.4em;
font-weight: normal;
margin: 0;
padding: 0;
}
div.sphinxsidebar h3 a {
color: #ffffff;
}
div.sphinxsidebar h4 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.3em;
font-weight: normal;
margin: 5px 0 0 0;
padding: 0;
}
div.sphinxsidebar p {
color: #ffffff;
}
div.sphinxsidebar p.topless {
margin: 5px 10px 10px 10px;
}
div.sphinxsidebar ul {
margin: 10px;
padding: 0;
color: #ffffff;
}
div.sphinxsidebar a {
color: #98dbcc;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
/* -- hyperlink styles ------------------------------------------------------ */
a {
color: #355f7c;
text-decoration: none;
}
a:visited {
color: #355f7c;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* -- body styles ----------------------------------------------------------- */
div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
font-family: 'Trebuchet MS', sans-serif;
background-color: #f2f2f2;
font-weight: normal;
color: #20435c;
border-bottom: 1px solid #ccc;
margin: 20px -20px 10px -20px;
padding: 3px 0 3px 10px;
}
div.body h1 { margin-top: 0; font-size: 200%; }
div.body h2 { font-size: 160%; }
div.body h3 { font-size: 140%; }
div.body h4 { font-size: 120%; }
div.body h5 { font-size: 110%; }
div.body h6 { font-size: 100%; }
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
div.body p, div.body dd, div.body li {
text-align: justify;
line-height: 130%;
}
div.admonition p.admonition-title + p {
display: inline;
}
div.admonition p {
margin-bottom: 5px;
}
div.admonition pre {
margin-bottom: 5px;
}
div.admonition ul, div.admonition ol {
margin-bottom: 5px;
}
div.note {
background-color: #eee;
border: 1px solid #ccc;
}
div.seealso {
background-color: #ffc;
border: 1px solid #ff6;
}
div.topic {
background-color: #eee;
}
div.warning {
background-color: #ffe4e4;
border: 1px solid #f66;
}
p.admonition-title {
display: inline;
}
p.admonition-title:after {
content: ":";
}
pre {
padding: 5px;
background-color: #eeffcc;
color: #333333;
line-height: 120%;
border: 1px solid #ac9;
border-left: none;
border-right: none;
}
tt {
background-color: #ecf0f3;
padding: 0 1px 0 1px;
font-size: 0.95em;
}
th {
background-color: #ede;
}
.warning tt {
background: #efc2c2;
}
.note tt {
background: #d6d6d6;
}
.viewcode-back {
font-family: sans-serif;
}
div.viewcode-block:target {
background-color: #f4debf;
border-top: 1px solid #ac9;
border-bottom: 1px solid #ac9;
}
\ No newline at end of file
/*
* doctools.js
* ~~~~~~~~~~~
*
* Sphinx JavaScript utilities for all documentation.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* select a different prefix for underscore
*/
$u = _.noConflict();
/**
* make the code below compatible with browsers without
* an installed firebug like debugger
if (!window.console || !console.firebug) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
"dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
"profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {};
}
*/
/**
* small helper function to urldecode strings
*/
jQuery.urldecode = function(x) {
return decodeURIComponent(x).replace(/\+/g, ' ');
}
/**
* small helper function to urlencode strings
*/
jQuery.urlencode = encodeURIComponent;
/**
* This function returns the parsed url parameters of the
* current request. Multiple values per key are supported,
* it will always return arrays of strings for the value parts.
*/
jQuery.getQueryParameters = function(s) {
if (typeof s == 'undefined')
s = document.location.search;
var parts = s.substr(s.indexOf('?') + 1).split('&');
var result = {};
for (var i = 0; i < parts.length; i++) {
var tmp = parts[i].split('=', 2);
var key = jQuery.urldecode(tmp[0]);
var value = jQuery.urldecode(tmp[1]);
if (key in result)
result[key].push(value);
else
result[key] = [value];
}
return result;
};
/**
* small function to check if an array contains
* a given item.
*/
jQuery.contains = function(arr, item) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == item)
return true;
}
return false;
};
/**
* highlight a given string on a jquery object by wrapping it in
* span elements with the given class name.
*/
jQuery.fn.highlightText = function(text, className) {
function highlight(node) {
if (node.nodeType == 3) {
var val = node.nodeValue;
var pos = val.toLowerCase().indexOf(text);
if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
var span = document.createElement("span");
span.className = className;
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
node.nextSibling));
node.nodeValue = val.substr(0, pos);
}
}
else if (!jQuery(node).is("button, select, textarea")) {
jQuery.each(node.childNodes, function() {
highlight(this);
});
}
}
return this.each(function() {
highlight(this);
});
};
/**
* Small JavaScript module for the documentation.
*/
var Documentation = {
init : function() {
this.fixFirefoxAnchorBug();
this.highlightSearchWords();
this.initIndexTable();
},
/**
* i18n support
*/
TRANSLATIONS : {},
PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
LOCALE : 'unknown',
// gettext and ngettext don't access this so that the functions
// can safely bound to a different name (_ = Documentation.gettext)
gettext : function(string) {
var translated = Documentation.TRANSLATIONS[string];
if (typeof translated == 'undefined')
return string;
return (typeof translated == 'string') ? translated : translated[0];
},
ngettext : function(singular, plural, n) {
var translated = Documentation.TRANSLATIONS[singular];
if (typeof translated == 'undefined')
return (n == 1) ? singular : plural;
return translated[Documentation.PLURALEXPR(n)];
},
addTranslations : function(catalog) {
for (var key in catalog.messages)
this.TRANSLATIONS[key] = catalog.messages[key];
this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
this.LOCALE = catalog.locale;
},
/**
* add context elements like header anchor links
*/
addContextElements : function() {
$('div[id] > :header:first').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this headline')).
appendTo(this);
});
$('dt[id]').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this definition')).
appendTo(this);
});
},
/**
* workaround a firefox stupidity
*/
fixFirefoxAnchorBug : function() {
if (document.location.hash && $.browser.mozilla)
window.setTimeout(function() {
document.location.href += '';
}, 10);
},
/**
* highlight the search words provided in the url in the text
*/
highlightSearchWords : function() {
var params = $.getQueryParameters();
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
if (terms.length) {
var body = $('div.body');
window.setTimeout(function() {
$.each(terms, function() {
body.highlightText(this.toLowerCase(), 'highlighted');
});
}, 10);
$('<p class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
.appendTo($('#searchbox'));
}
},
/**
* init the domain index toggle buttons
*/
initIndexTable : function() {
var togglers = $('img.toggler').click(function() {
var src = $(this).attr('src');
var idnum = $(this).attr('id').substr(7);
$('tr.cg-' + idnum).toggle();
if (src.substr(-9) == 'minus.png')
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
else
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
}).css('display', '');
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
togglers.click();
}
},
/**
* helper function to hide the search marks again
*/
hideSearchWords : function() {
$('#searchbox .highlight-link').fadeOut(300);
$('span.highlighted').removeClass('highlighted');
},
/**
* make the url absolute
*/
makeURL : function(relativeURL) {
return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
},
/**
* get the current relative url
*/
getCurrentURL : function() {
var path = document.location.pathname;
var parts = path.split(/\//);
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
if (this == '..')
parts.pop();
});
var url = parts.join('/');
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
}
};
// quick alias for translations
_ = Documentation.gettext;
$(document).ready(function() {
Documentation.init();
});
This diff is collapsed.
.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #007020 } /* Comment.Preproc */
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #303030 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0040D0 } /* Generic.Traceback */
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #007020 } /* Keyword.Pseudo */
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #902000 } /* Keyword.Type */
.highlight .m { color: #208050 } /* Literal.Number */
.highlight .s { color: #4070a0 } /* Literal.String */
.highlight .na { color: #4070a0 } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60add5 } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #007020 } /* Name.Exception */
.highlight .nf { color: #06287e } /* Name.Function */
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #bb60d5 } /* Name.Variable */
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mf { color: #208050 } /* Literal.Number.Float */
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
.highlight .sr { color: #235388 } /* Literal.String.Regex */
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */
\ No newline at end of file
This diff is collapsed.
/*
* sidebar.js
* ~~~~~~~~~~
*
* This script makes the Sphinx sidebar collapsible.
*
* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds
* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
* used to collapse and expand the sidebar.
*
* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
* and the width of the sidebar and the margin-left of the document
* are decreased. When the sidebar is expanded the opposite happens.
* This script saves a per-browser/per-session cookie used to
* remember the position of the sidebar among the pages.
* Once the browser is closed the cookie is deleted and the position
* reset to the default (expanded).
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
$(function() {
// global elements used by the functions.
// the 'sidebarbutton' element is defined as global after its
// creation, in the add_sidebar_button function
var bodywrapper = $('.bodywrapper');
var sidebar = $('.sphinxsidebar');
var sidebarwrapper = $('.sphinxsidebarwrapper');
// for some reason, the document has no sidebar; do not run into errors
if (!sidebar.length) return;
// original margin-left of the bodywrapper and width of the sidebar
// with the sidebar expanded
var bw_margin_expanded = bodywrapper.css('margin-left');
var ssb_width_expanded = sidebar.width();
// margin-left of the bodywrapper and width of the sidebar
// with the sidebar collapsed
var bw_margin_collapsed = '.8em';
var ssb_width_collapsed = '.8em';
// colors used by the current theme
var dark_color = $('.related').css('background-color');
var light_color = $('.document').css('background-color');
function sidebar_is_collapsed() {
return sidebarwrapper.is(':not(:visible)');
}
function toggle_sidebar() {
if (sidebar_is_collapsed())
expand_sidebar();
else
collapse_sidebar();
}
function collapse_sidebar() {
sidebarwrapper.hide();
sidebar.css('width', ssb_width_collapsed);
bodywrapper.css('margin-left', bw_margin_collapsed);
sidebarbutton.css({
'margin-left': '0',
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('»');
sidebarbutton.attr('title', _('Expand sidebar'));
document.cookie = 'sidebar=collapsed';
}
function expand_sidebar() {
bodywrapper.css('margin-left', bw_margin_expanded);
sidebar.css('width', ssb_width_expanded);
sidebarwrapper.show();
sidebarbutton.css({
'margin-left': ssb_width_expanded-12,
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('«');
sidebarbutton.attr('title', _('Collapse sidebar'));
document.cookie = 'sidebar=expanded';
}
function add_sidebar_button() {
sidebarwrapper.css({
'float': 'left',
'margin-right': '0',
'width': ssb_width_expanded - 28
});
// create the button
sidebar.append(
'<div id="sidebarbutton"><span>&laquo;</span></div>'
);
var sidebarbutton = $('#sidebarbutton');
light_color = sidebarbutton.css('background-color');
// find the height of the viewport to center the '<<' in the page
var viewport_height;
if (window.innerHeight)
viewport_height = window.innerHeight;
else
viewport_height = $(window).height();
sidebarbutton.find('span').css({
'display': 'block',
'margin-top': (viewport_height - sidebar.position().top - 20) / 2
});
sidebarbutton.click(toggle_sidebar);
sidebarbutton.attr('title', _('Collapse sidebar'));
sidebarbutton.css({
'color': '#FFFFFF',
'border-left': '1px solid ' + dark_color,
'font-size': '1.2em',
'cursor': 'pointer',
'height': bodywrapper.height(),
'padding-top': '1px',
'margin-left': ssb_width_expanded - 12
});
sidebarbutton.hover(
function () {
$(this).css('background-color', dark_color);
},
function () {
$(this).css('background-color', light_color);
}
);
}
function set_position_from_cookie() {
if (!document.cookie)
return;
var items = document.cookie.split(';');
for(var k=0; k<items.length; k++) {
var key_val = items[k].split('=');
var key = key_val[0];
if (key == 'sidebar') {
var value = key_val[1];
if ((value == 'collapsed') && (!sidebar_is_collapsed()))
collapse_sidebar();
else if ((value == 'expanded') && (sidebar_is_collapsed()))
expand_sidebar();
}
}
}
add_sidebar_button();
var sidebarbutton = $('#sidebarbutton');
set_position_from_cookie();
});
// Underscore.js 0.5.5
// (c) 2009 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the terms of the MIT license.
// Portions of Underscore are inspired by or borrowed from Prototype.js,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore/
(function(){var j=this,n=j._,i=function(a){this._wrapped=a},m=typeof StopIteration!=="undefined"?StopIteration:"__break__",b=j._=function(a){return new i(a)};if(typeof exports!=="undefined")exports._=b;var k=Array.prototype.slice,o=Array.prototype.unshift,p=Object.prototype.toString,q=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;b.VERSION="0.5.5";b.each=function(a,c,d){try{if(a.forEach)a.forEach(c,d);else if(b.isArray(a)||b.isArguments(a))for(var e=0,f=a.length;e<f;e++)c.call(d,
a[e],e,a);else{var g=b.keys(a);f=g.length;for(e=0;e<f;e++)c.call(d,a[g[e]],g[e],a)}}catch(h){if(h!=m)throw h;}return a};b.map=function(a,c,d){if(a&&b.isFunction(a.map))return a.map(c,d);var e=[];b.each(a,function(f,g,h){e.push(c.call(d,f,g,h))});return e};b.reduce=function(a,c,d,e){if(a&&b.isFunction(a.reduce))return a.reduce(b.bind(d,e),c);b.each(a,function(f,g,h){c=d.call(e,c,f,g,h)});return c};b.reduceRight=function(a,c,d,e){if(a&&b.isFunction(a.reduceRight))return a.reduceRight(b.bind(d,e),c);
var f=b.clone(b.toArray(a)).reverse();b.each(f,function(g,h){c=d.call(e,c,g,h,a)});return c};b.detect=function(a,c,d){var e;b.each(a,function(f,g,h){if(c.call(d,f,g,h)){e=f;b.breakLoop()}});return e};b.select=function(a,c,d){if(a&&b.isFunction(a.filter))return a.filter(c,d);var e=[];b.each(a,function(f,g,h){c.call(d,f,g,h)&&e.push(f)});return e};b.reject=function(a,c,d){var e=[];b.each(a,function(f,g,h){!c.call(d,f,g,h)&&e.push(f)});return e};b.all=function(a,c,d){c=c||b.identity;if(a&&b.isFunction(a.every))return a.every(c,
d);var e=true;b.each(a,function(f,g,h){(e=e&&c.call(d,f,g,h))||b.breakLoop()});return e};b.any=function(a,c,d){c=c||b.identity;if(a&&b.isFunction(a.some))return a.some(c,d);var e=false;b.each(a,function(f,g,h){if(e=c.call(d,f,g,h))b.breakLoop()});return e};b.include=function(a,c){if(b.isArray(a))return b.indexOf(a,c)!=-1;var d=false;b.each(a,function(e){if(d=e===c)b.breakLoop()});return d};b.invoke=function(a,c){var d=b.rest(arguments,2);return b.map(a,function(e){return(c?e[c]:e).apply(e,d)})};b.pluck=
function(a,c){return b.map(a,function(d){return d[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);var e={computed:-Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;g>=e.computed&&(e={value:f,computed:g})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;g<e.computed&&(e={value:f,computed:g})});return e.value};b.sortBy=function(a,c,d){return b.pluck(b.map(a,
function(e,f,g){return{value:e,criteria:c.call(d,e,f,g)}}).sort(function(e,f){e=e.criteria;f=f.criteria;return e<f?-1:e>f?1:0}),"value")};b.sortedIndex=function(a,c,d){d=d||b.identity;for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?(e=g+1):(f=g)}return e};b.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(b.isArray(a))return a;if(b.isArguments(a))return k.call(a);return b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=function(a,c,d){return c&&!d?k.call(a,
0,c):a[0]};b.rest=function(a,c,d){return k.call(a,b.isUndefined(c)||d?1:c)};b.last=function(a){return a[a.length-1]};b.compact=function(a){return b.select(a,function(c){return!!c})};b.flatten=function(a){return b.reduce(a,[],function(c,d){if(b.isArray(d))return c.concat(b.flatten(d));c.push(d);return c})};b.without=function(a){var c=b.rest(arguments);return b.select(a,function(d){return!b.include(c,d)})};b.uniq=function(a,c){return b.reduce(a,[],function(d,e,f){if(0==f||(c===true?b.last(d)!=e:!b.include(d,
e)))d.push(e);return d})};b.intersect=function(a){var c=b.rest(arguments);return b.select(b.uniq(a),function(d){return b.all(c,function(e){return b.indexOf(e,d)>=0})})};b.zip=function(){for(var a=b.toArray(arguments),c=b.max(b.pluck(a,"length")),d=new Array(c),e=0;e<c;e++)d[e]=b.pluck(a,String(e));return d};b.indexOf=function(a,c){if(a.indexOf)return a.indexOf(c);for(var d=0,e=a.length;d<e;d++)if(a[d]===c)return d;return-1};b.lastIndexOf=function(a,c){if(a.lastIndexOf)return a.lastIndexOf(c);for(var d=
a.length;d--;)if(a[d]===c)return d;return-1};b.range=function(a,c,d){var e=b.toArray(arguments),f=e.length<=1;a=f?0:e[0];c=f?e[0]:e[1];d=e[2]||1;e=Math.ceil((c-a)/d);if(e<=0)return[];e=new Array(e);f=a;for(var g=0;1;f+=d){if((d>0?f-c:c-f)>=0)return e;e[g++]=f}};b.bind=function(a,c){var d=b.rest(arguments,2);return function(){return a.apply(c||j,d.concat(b.toArray(arguments)))}};b.bindAll=function(a){var c=b.rest(arguments);if(c.length==0)c=b.functions(a);b.each(c,function(d){a[d]=b.bind(a[d],a)});
return a};b.delay=function(a,c){var d=b.rest(arguments,2);return setTimeout(function(){return a.apply(a,d)},c)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(b.rest(arguments)))};b.wrap=function(a,c){return function(){var d=[a].concat(b.toArray(arguments));return c.apply(c,d)}};b.compose=function(){var a=b.toArray(arguments);return function(){for(var c=b.toArray(arguments),d=a.length-1;d>=0;d--)c=[a[d].apply(this,c)];return c[0]}};b.keys=function(a){if(b.isArray(a))return b.range(0,a.length);
var c=[];for(var d in a)q.call(a,d)&&c.push(d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=function(a){return b.select(b.keys(a),function(c){return b.isFunction(a[c])}).sort()};b.extend=function(a,c){for(var d in c)a[d]=c[d];return a};b.clone=function(a){if(b.isArray(a))return a.slice(0);return b.extend({},a)};b.tap=function(a,c){c(a);return a};b.isEqual=function(a,c){if(a===c)return true;var d=typeof a;if(d!=typeof c)return false;if(a==c)return true;if(!a&&c||a&&!c)return false;
if(a.isEqual)return a.isEqual(c);if(b.isDate(a)&&b.isDate(c))return a.getTime()===c.getTime();if(b.isNaN(a)&&b.isNaN(c))return true;if(b.isRegExp(a)&&b.isRegExp(c))return a.source===c.source&&a.global===c.global&&a.ignoreCase===c.ignoreCase&&a.multiline===c.multiline;if(d!=="object")return false;if(a.length&&a.length!==c.length)return false;d=b.keys(a);var e=b.keys(c);if(d.length!=e.length)return false;for(var f in a)if(!b.isEqual(a[f],c[f]))return false;return true};b.isEmpty=function(a){return b.keys(a).length==
0};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=function(a){return!!(a&&a.concat&&a.unshift)};b.isArguments=function(a){return a&&b.isNumber(a.length)&&!b.isArray(a)&&!r.call(a,"length")};b.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)};b.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)};b.isNumber=function(a){return p.call(a)==="[object Number]"};b.isDate=function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)};b.isRegExp=function(a){return!!(a&&
a.test&&a.exec&&(a.ignoreCase||a.ignoreCase===false))};b.isNaN=function(a){return b.isNumber(a)&&isNaN(a)};b.isNull=function(a){return a===null};b.isUndefined=function(a){return typeof a=="undefined"};b.noConflict=function(){j._=n;return this};b.identity=function(a){return a};b.breakLoop=function(){throw m;};var s=0;b.uniqueId=function(a){var c=s++;return a?a+c:c};b.template=function(a,c){a=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+a.replace(/[\r\t\n]/g,
" ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');");return c?a(c):a};b.forEach=b.each;b.foldl=b.inject=b.reduce;b.foldr=b.reduceRight;b.filter=b.select;b.every=b.all;b.some=b.any;b.head=b.first;b.tail=b.rest;b.methods=b.functions;var l=function(a,c){return c?b(a).chain():a};b.each(b.functions(b),function(a){var c=b[a];i.prototype[a]=function(){var d=b.toArray(arguments);
o.call(d,this._wrapped);return l(c.apply(b,d),this._chain)}});b.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){c.apply(this._wrapped,arguments);return l(this._wrapped,this._chain)}});b.each(["concat","join","slice"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){return l(c.apply(this._wrapped,arguments),this._chain)}});i.prototype.chain=function(){this._chain=true;return this};i.prototype.value=function(){return this._wrapped}})();
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Argument validation &mdash; CorePost 0.0.14 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="CorePost 0.0.14 documentation" href="index.html" />
<link rel="next" title="Content types" href="content_types.html" />
<link rel="prev" title="URL Routing" href="url_routing.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="content_types.html" title="Content types"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="url_routing.html" title="URL Routing"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="argument-validation">
<h1>Argument validation<a class="headerlink" href="#argument-validation" title="Permalink to this headline"></a></h1>
<p>CorePost integrates the popular &#8216;formencode&#8217; package to implement form and query argument validation.
Validators can be specified using a <em>formencode</em> Schema object, or via custom field-specific validators.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">corepost.web</span> <span class="kn">import</span> <span class="n">validate</span><span class="p">,</span> <span class="n">route</span>
<span class="kn">from</span> <span class="nn">corepost.enums</span> <span class="kn">import</span> <span class="n">Http</span>
<span class="kn">from</span> <span class="nn">formencode</span> <span class="kn">import</span> <span class="n">Schema</span><span class="p">,</span> <span class="n">validators</span>
<span class="k">class</span> <span class="nc">TestSchema</span><span class="p">(</span><span class="n">Schema</span><span class="p">):</span>
<span class="n">allow_extra_fields</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">childId</span> <span class="o">=</span> <span class="n">validators</span><span class="o">.</span><span class="n">Regex</span><span class="p">(</span><span class="n">regex</span><span class="o">=</span><span class="s">&quot;^value1|value2$&quot;</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">MyApp</span><span class="p">():</span>
<span class="nd">@route</span><span class="p">(</span><span class="s">&quot;/validate/&lt;int:rootId&gt;/schema&quot;</span><span class="p">,</span><span class="n">Http</span><span class="o">.</span><span class="n">POST</span><span class="p">)</span>
<span class="nd">@validate</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">TestSchema</span><span class="p">())</span>
<span class="k">def</span> <span class="nf">postValidateSchema</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">request</span><span class="p">,</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;Validate using a common schema&#39;&#39;&#39;</span>
<span class="k">return</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="n">kwargs</span><span class="p">)</span>
<span class="nd">@route</span><span class="p">(</span><span class="s">&quot;/validate/&lt;int:rootId&gt;/custom&quot;</span><span class="p">,</span><span class="n">Http</span><span class="o">.</span><span class="n">POST</span><span class="p">)</span>
<span class="nd">@validate</span><span class="p">(</span><span class="n">childId</span><span class="o">=</span><span class="n">validators</span><span class="o">.</span><span class="n">Regex</span><span class="p">(</span><span class="n">regex</span><span class="o">=</span><span class="s">&quot;^value1|value2$&quot;</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">postValidateCustom</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">request</span><span class="p">,</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;Validate using argument-specific validators&#39;&#39;&#39;</span>
<span class="k">return</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s"> - </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">rootId</span><span class="p">,</span><span class="n">childId</span><span class="p">,</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>
</div>
<p>Please see the <em>FormEncode</em> documentation:</p>
<p><a class="reference external" href="http://www.formencode.org/en/latest/Validator.html">http://www.formencode.org/en/latest/Validator.html</a></p>
<p>for list of available validators:</p>
<ul class="simple">
<li>Common : <a class="reference external" href="http://www.formencode.org/en/latest/modules/validators.html#module-formencode.validators">http://www.formencode.org/en/latest/modules/validators.html#module-formencode.validators</a></li>
<li>National : <a class="reference external" href="http://www.formencode.org/en/latest/modules/national.html#module-formencode.national">http://www.formencode.org/en/latest/modules/national.html#module-formencode.national</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="url_routing.html"
title="previous chapter">URL Routing</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="content_types.html"
title="next chapter">Content types</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/arguments.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="content_types.html" title="Content types"
>next</a> |</li>
<li class="right" >
<a href="url_routing.html" title="URL Routing"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2012, Jacek Furmankiewicz.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Asynchronous Operations &mdash; CorePost 0.0.14 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="CorePost 0.0.14 documentation" href="index.html" />
<link rel="prev" title="HTTP codes" href="http_codes.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="asynchronous-operations">
<h1>Asynchronous Operations<a class="headerlink" href="#asynchronous-operations" title="Permalink to this headline"></a></h1>
<div class="section" id="defer-inlinecallbacks-support">
<h2>&#64;defer.inlineCallbacks support<a class="headerlink" href="#defer-inlinecallbacks-support" title="Permalink to this headline"></a></h2>
<p>If you want a deferred async method, just use <em>defer.returnValue()</em>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="nd">@route</span><span class="p">(</span><span class="s">&quot;/&quot;</span><span class="p">,</span><span class="n">Http</span><span class="o">.</span><span class="n">GET</span><span class="p">)</span>
<span class="nd">@defer.inlineCallbacks</span>
<span class="k">def</span> <span class="nf">root</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">request</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">val1</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">db</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s">&quot;SELECT ....&quot;</span><span class="p">)</span>
<span class="n">val2</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">db</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s">&quot;SELECT ....&quot;</span><span class="p">)</span>
<span class="n">defer</span><span class="o">.</span><span class="n">returnValue</span><span class="p">(</span><span class="n">val1</span> <span class="o">+</span> <span class="n">val2</span><span class="p">)</span>
</pre></div>
</div>
<p>This is standard Twisted functionality.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Asynchronous Operations</a><ul>
<li><a class="reference internal" href="#defer-inlinecallbacks-support">&#64;defer.inlineCallbacks support</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="http_codes.html"
title="previous chapter">HTTP codes</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/async.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2012, Jacek Furmankiewicz.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
</div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index &mdash; CorePost 0.0.14 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="CorePost 0.0.14 documentation" href="index.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="#" title="General Index"
accesskey="I">index</a></li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1 id="index">Index</h1>
<div class="genindex-jumpbox">
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="#" title="General Index"
>index</a></li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2012, Jacek Furmankiewicz.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
</div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Search.setIndex({objects:{},terms:{all:2,code:[0,1,3,4,5,7],partial:4,queri:[8,6],formencod:6,iresponsefilt:7,follow:7,rootid:6,depend:4,received_head:[7,3],readabl:5,specif:6,under:5,string:[4,3],veri:5,level:5,list:[6,7],small:2,pleas:6,enterpris:5,fortun:5,abil:5,design:5,pass:[7,3],val2:8,val1:8,phoneid:2,index:[],what:[0,5],savecustom:2,abl:1,current:[5,3],delet:[2,1],intarg:3,filterrespons:7,method:[8,5,1,3],can:[4,2,6,7,3],full:2,restservic:3,here:2,bodi:4,modular:[0,2],intercept:7,let:5,floatarg:3,address:2,path:[0,2,3],statecod:2,valu:7,convert:[4,0,3],convers:5,extrem:5,chang:7,via:[6,7,3],activ:7,modul:6,countrycod:2,api:5,select:8,regex:6,from:[6,5,2,1,3],would:[0,5,3],two:[2,7],handler:5,call:4,value2:6,value1:6,recommend:5,type:[4,0,7,3],more:5,desir:3,test_yaml:4,phone:2,indic:[],particular:5,known:5,customerid:2,content_typ:3,postvalidateschema:6,focu:5,del:2,thin:5,root:[8,7,3],def:[2,3,4,6,7,8],defer:[0,5,8],tap:3,give:5,accept:4,want:8,multipl:[],write:[5,2,3],how:5,instead:[4,0,5],simpl:3,product:[5,3],resourc:[2,7],befor:5,mesh:2,end:2,httpheader:3,tutori:5,seriou:5,element:2,callback:5,allow:[2,7],order:[2,7],dynam:[2,3],entiti:2,yaml:[4,5],jit:5,easier:5,them:[2,7,3],application_json:3,"return":[1,2,3,4,6,7],python:[4,0,5],nation:6,framework:[0,5],introduct:[0,5],trac:5,easili:3,wraparoundfilt:7,side:5,status:7,hard:5,expect:[4,0,3],paymentid:2,extract:[0,3],network:5,develop:5,crucial:5,content:[4,0,3],restresourc:[2,7,3],deleteal:2,test_content_app_json:3,integr:[4,6],standard:8,pleasant:5,base:[4,1,3],put:[4,2,1,3],org:6,care:[5,2],addressid:2,filter:[0,5,7],router:3,principl:5,interact:5,testschema:6,oper:[0,5,8],note:3,blown:2,grade:5,onc:5,lastnam:2,test_json:4,getallcustom:2,hook:3,miss:1,hood:5,differ:[2,3],addcustomheaderfilt:7,getcustomeraddress:2,customeraddress:2,top:[0,5],system:5,least:5,attach:4,conveni:3,schema:6,customeraddressrestservic:2,specifi:6,pars:[4,0,5],streetnumb:2,mostli:5,than:5,provid:5,structur:2,argument:[6,0,1,3],packag:6,have:2,"__main__":[2,3],need:7,inlinecallback:[0,8],test_return_content_by_accept:4,self:[2,3,4,6,7,8],especi:5,thorough:5,stringarg:3,take:[5,2],which:[5,2],noth:5,singl:2,simplifi:5,importantli:5,deletecustom:2,regular:2,why:[0,5],url:[4,0,2,1,3],request:[0,2,3,4,5,6,7,8],doe:[0,5],test_content_xml:3,runtim:5,wildcard:3,numericid:3,somewhat:5,show:3,text:4,xml:[4,5],just:[2,3,4,5,7,8],solut:5,plumb:5,should:5,busi:[5,2],meant:5,get:[1,2,3,5,7,8],pypi:5,requir:5,run_filter_app:7,change404to503filt:7,yield:8,"default":[4,1],common:[5,6],deleteallcustom:2,where:2,valid:[0,2,1,6],dump:4,see:6,mandatori:1,respons:[4,5,2,7],fail:1,extend:2,hopefulli:5,databas:5,behind:5,"import":[2,6,3],paramet:[2,7],approach:5,parent:2,both:7,howev:5,test_content_catch_al:3,etc:[2,3],instanc:7,logic:5,pdf:5,com:[5,3],simpli:5,header:7,guid:5,coupl:5,json:[4,5],much:5,basic:[5,3],search:[],ani:[5,1],notfoundexcept:2,dave:5,run_rest_app:2,child:2,"case":2,text_xml:3,tostr:4,servic:[5,2,7],"while":5,abov:2,error:1,fun:5,exist:[2,3],layer:5,twistedmatrix:[5,3],tabl:[],henc:5,toolkit:5,kwarg:[4,8,6,7,3],myapp:6,postvalidatecustom:6,incom:[4,0,7,3],twistd:3,decor:[0,3],allow_extra_field:6,perform:5,make:5,same:3,handl:5,html:[6,3],zope:7,document:[5,6,3],breakdown:[],http:[0,1,2,3,4,5,6,7,8],driven:[2,1],extern:5,typic:2,appropri:[2,1],eleg:5,well:5,coreport:3,exampl:[2,6,3],thi:[4,8,5,2,3],rout:[0,2,3,4,5,6,7,8],latest:6,test1:4,test2:4,firstnam:2,when:3,rest:[0,5,2],filterapp:7,test_content_yaml:3,yet:5,languag:5,web:[0,5,2,6,3],application_xml:3,except:5,getal:2,blog:5,add:[0,5,7],book:5,input:[5,7],app:[2,7,3],match:1,build:5,real:3,applic:[4,0,5,2,3],around:7,format:5,read:5,irequestfilt:7,howto:[5,3],piec:3,realiz:5,like:[5,2],success:1,filterrequest:7,test_get_resourc:3,either:[5,7],popular:6,output:7,page:[],childid:6,www:6,some:5,sampl:[2,3],server:[5,1],librari:5,kei:[],getcustom:2,micro:[0,5],peticola:5,outgo:7,unit:3,test_xml:4,complic:5,core:[5,3],object:[0,2,3,4,5,6],run:[2,7,3],power:5,payment:2,"enum":[6,3],usag:5,alreadyexistsexcept:2,async:[8,5],"__name__":[2,3],post:[4,6,2,1,3],actual:1,constructor:7,other:5,own:5,effici:5,"float":3,automat:[4,5,3],wrap:[2,7],your:3,invoiceid:2,val:4,support:[4,0,8,7,3],custom:[5,2,6,7],avail:6,reli:5,interfac:7,low:5,"function":[8,1,3],returnvalu:8,form:6,streetnam:2,inlin:5,"true":6,whether:4,page_id:5,caller:4,asynchron:[0,5,8],similar:5,featur:[0,5],creat:[5,2,1],"int":[6,3],customerrestservic:2,twist:[0,5,2,8,3],implement:[2,6,7],krondo:5,excel:5,elementtre:4,field:6,corepost:[0,1,2,3,4,5,6,7],test:3,you:[8,5,2,7,3],node:[0,5],matur:5,mediatyp:3,"class":[5,2,6,7,3],sql:5,text_yaml:3,understand:5,invoic:2},objtypes:{},titles:["CorePost","HTTP codes","Modular REST applications","URL Routing","Content types","Introduction","Argument validation","Filters","Asynchronous Operations"],objnames:{},filenames:["index","http_codes","modules","url_routing","content_types","intro","arguments","filters","async"]})
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Search.setIndex({objects:{},terms:{all:2,code:[0,1,2],partial:2,queri:2,formencod:2,abil:1,follow:2,rootid:2,depend:2,received_head:2,readabl:1,specif:2,under:[0,1,2],string:2,veri:1,level:1,list:2,small:2,pleas:2,enterpris:1,fortun:1,iresponsefilt:2,design:1,pass:2,val2:2,val1:2,phoneid:2,index:0,what:[0,1,2],savecustom:2,abl:2,current:[1,2],delet:2,intarg:2,filterrespons:2,method:[1,2],can:[0,2],full:2,restservic:2,here:2,bodi:2,modular:2,intercept:2,let:1,floatarg:2,address:2,path:[0,2],statecod:2,valu:2,convert:[0,2],convers:1,extrem:1,chang:2,via:2,activ:2,modul:[0,2],countrycod:2,api:[0,1],select:2,regex:2,from:[1,2],would:[0,1,2],two:2,handler:1,call:2,value2:2,value1:2,recommend:1,type:[0,2],more:1,desir:2,test_yaml:2,phone:2,indic:0,particular:1,known:1,customerid:2,content_typ:2,postvalidateschema:2,focu:1,del:2,thin:1,root:[0,2],def:2,defer:[0,1,2],tap:2,give:1,accept:[0,2],want:2,multipl:[0,2],write:[1,2],how:1,instead:[0,1,2],simpl:2,product:[1,2],resourc:2,befor:1,mesh:2,end:2,httpheader:2,tutori:1,seriou:1,element:2,callback:1,allow:2,order:2,dynam:2,entiti:2,yaml:[1,2],jit:1,html:2,easier:1,them:2,application_json:2,"return":2,python:[0,1,2],nation:2,framework:[0,1],introduct:[0,1],trac:1,easili:2,wraparoundfilt:2,side:1,status:2,hard:1,expect:2,paymentid:2,extract:[0,2],network:1,crucial:1,content:[0,2],restresourc:2,deleteal:2,test_content_app_json:2,integr:2,standard:2,pleasant:1,base:[0,2],put:2,org:2,care:[1,2],addressid:2,filter:[0,1,2],router:2,principl:1,interact:1,testschema:2,oper:[0,1,2],note:2,blown:2,grade:1,onc:1,lastnam:2,test_json:2,getallcustom:2,hook:2,miss:2,hood:1,differ:2,addcustomheaderfilt:2,getcustomeraddress:2,customeraddress:2,top:[0,1],system:1,least:1,attach:2,conveni:2,schema:2,customeraddressrestservic:2,specifi:2,pars:[1,2],streetnumb:2,mostli:1,than:1,provid:1,structur:2,argument:[0,2],packag:2,have:2,"__main__":2,need:2,inlinecallback:[0,2],test_return_content_by_accept:2,self:2,especi:1,thorough:1,stringarg:2,take:[1,2],which:[1,2],noth:1,singl:2,simplifi:1,importantli:1,deletecustom:2,regular:2,why:[0,1],url:[0,2],request:[0,1,2],doe:[0,1],test_content_xml:2,runtim:1,wildcard:2,numericid:2,somewhat:1,show:2,text:2,xml:[1,2],just:[1,2],solut:1,plumb:1,should:1,busi:[1,2],meant:1,get:[1,2],pypi:1,requir:1,run_filter_app:2,change404to503filt:2,yield:2,"default":2,common:[0,1,2],deleteallcustom:2,where:2,valid:[0,2],dump:2,see:2,mandatori:2,respons:[1,2],fail:2,extend:2,hopefulli:1,databas:1,behind:1,"import":2,paramet:2,approach:1,kei:2,both:2,howev:1,test_content_catch_al:2,etc:2,instanc:2,logic:1,pdf:1,com:[1,2],simpli:1,header:2,guid:1,coupl:1,json:[1,2],much:1,basic:[1,2],search:0,ani:[1,2],notfoundexcept:2,dave:1,run_rest_app:2,child:2,"case":2,tostr:2,servic:[0,1,2],"while":1,abov:2,error:2,fun:1,exist:2,layer:1,twistedmatrix:[1,2],tabl:0,henc:1,toolkit:1,kwarg:2,myapp:2,postvalidatecustom:2,incom:[0,2],twistd:2,parent:2,decor:[0,2],develop:1,perform:1,make:1,same:2,handl:1,text_xml:2,zope:2,document:[1,2],breakdown:2,http:[0,1,2],driven:2,extern:1,typic:2,appropri:2,eleg:1,well:1,coreport:2,exampl:2,thi:[1,2],rout:[0,1,2],latest:2,test1:2,test2:2,firstnam:2,when:2,rest:[0,1,2],filterapp:2,test_content_yaml:2,yet:1,languag:1,web:[0,1,2],application_xml:2,except:1,getal:2,blog:1,add:[0,1,2],book:1,input:[1,2],app:2,match:2,build:1,real:2,applic:[1,2],around:2,format:1,read:1,irequestfilt:2,howto:[1,2],piec:2,realiz:1,like:[1,2],success:2,filterrequest:2,allow_extra_field:2,test_get_resourc:2,either:[1,2],popular:2,output:2,page:0,childid:2,www:2,some:1,sampl:2,server:[1,2],librari:1,getcustom:2,micro:[0,1],peticola:1,outgo:2,unit:2,test_xml:2,complic:1,core:[1,2],object:[0,1,2],run:2,power:[0,1],payment:2,"enum":2,usag:1,alreadyexistsexcept:2,async:[1,2],"__name__":2,post:2,actual:2,constructor:2,other:1,own:1,effici:1,"float":2,automat:[1,2],wrap:2,your:2,invoiceid:2,val:2,support:[0,2],custom:[1,2],avail:2,reli:1,interfac:2,low:1,"function":2,returnvalu:2,form:2,streetnam:2,inlin:1,"true":2,whether:2,page_id:1,caller:[0,2],asynchron:[0,1,2],similar:1,featur:[0,1,2],creat:[1,2],"int":2,customerrestservic:2,twist:[0,1,2],implement:2,krondo:1,excel:1,elementtre:2,field:2,corepost:[0,1,2],test:2,you:[1,2],node:[0,1],matur:1,mediatyp:2,"class":[1,2],sql:1,text_yaml:2,understand:1,invoic:2},objtypes:{},titles:["CorePost","Introduction","Features"],objnames:{},filenames:["index","intro","features"]}) Search.setIndex({objects:{},terms:{all:2,code:[0,1,3,4,5,7],partial:4,queri:[8,6],formencod:6,iresponsefilt:7,follow:7,rootid:6,depend:4,received_head:[7,3],readabl:5,specif:6,under:5,string:[4,3],veri:5,level:5,list:[6,7],small:2,pleas:6,enterpris:5,fortun:5,abil:5,design:5,pass:[7,3],val2:8,val1:8,phoneid:2,index:[],what:[0,5],savecustom:2,abl:1,current:[5,3],delet:[2,1],intarg:3,filterrespons:7,method:[8,5,1,3],can:[4,2,6,7,3],full:2,restservic:3,here:2,bodi:4,modular:[0,2],intercept:7,let:5,floatarg:3,address:2,path:[0,2,3],statecod:2,valu:7,convert:[4,0,3],convers:5,extrem:5,chang:7,via:[6,7,3],activ:7,modul:6,countrycod:2,api:5,select:8,regex:6,from:[6,5,2,1,3],would:[0,5,3],two:[2,7],handler:5,call:4,value2:6,value1:6,recommend:5,type:[4,0,7,3],more:5,desir:3,test_yaml:4,phone:2,indic:[],particular:5,known:5,customerid:2,content_typ:3,postvalidateschema:6,focu:5,del:2,thin:5,root:[8,7,3],def:[2,3,4,6,7,8],defer:[0,5,8],tap:3,give:5,accept:4,want:8,multipl:[],write:[5,2,3],how:5,instead:[4,0,5],simpl:3,product:[5,3],resourc:[2,7],befor:5,mesh:2,end:2,httpheader:3,tutori:5,seriou:5,element:2,callback:5,allow:[2,7],order:[2,7],dynam:[2,3],entiti:2,yaml:[4,5],jit:5,easier:5,them:[2,7,3],application_json:3,"return":[1,2,3,4,6,7],python:[4,0,5],nation:6,framework:[0,5],introduct:[0,5],trac:5,easili:3,wraparoundfilt:7,side:5,status:7,hard:5,expect:[4,0,3],paymentid:2,extract:[0,3],network:5,develop:5,crucial:5,content:[4,0,3],restresourc:[2,7,3],deleteal:2,test_content_app_json:3,integr:[4,6],standard:8,pleasant:5,base:[4,1,3],put:[4,2,1,3],org:6,care:[5,2],addressid:2,filter:[0,5,7],router:3,principl:5,interact:5,testschema:6,oper:[0,5,8],note:3,blown:2,grade:5,onc:5,lastnam:2,test_json:4,getallcustom:2,hook:3,miss:1,hood:5,differ:[2,3],addcustomheaderfilt:7,getcustomeraddress:2,customeraddress:2,top:[0,5],system:5,least:5,attach:4,conveni:3,schema:6,customeraddressrestservic:2,specifi:6,pars:[4,0,5],streetnumb:2,mostli:5,than:5,provid:5,structur:2,argument:[6,0,1,3],packag:6,have:2,"__main__":[2,3],need:7,inlinecallback:[0,8],test_return_content_by_accept:4,self:[2,3,4,6,7,8],especi:5,thorough:5,stringarg:3,take:[5,2],which:[5,2],noth:5,singl:2,simplifi:5,importantli:5,deletecustom:2,regular:2,why:[0,5],url:[4,0,2,1,3],request:[0,2,3,4,5,6,7,8],doe:[0,5],test_content_xml:3,runtim:5,wildcard:3,numericid:3,somewhat:5,show:3,text:4,xml:[4,5],just:[2,3,4,5,7,8],solut:5,plumb:5,should:5,busi:[5,2],meant:5,get:[1,2,3,5,7,8],pypi:5,requir:5,run_filter_app:7,change404to503filt:7,yield:8,"default":[4,1],common:[5,6],deleteallcustom:2,where:2,valid:[0,2,1,6],dump:4,see:6,mandatori:1,respons:[4,5,2,7],fail:1,extend:2,hopefulli:5,databas:5,behind:5,"import":[2,6,3],paramet:[2,7],approach:5,parent:2,both:7,howev:5,test_content_catch_al:3,etc:[2,3],instanc:7,logic:5,pdf:5,com:[5,3],simpli:5,header:7,guid:5,coupl:5,json:[4,5],much:5,basic:[5,3],search:[],ani:[5,1],notfoundexcept:2,dave:5,run_rest_app:2,child:2,"case":2,text_xml:3,tostr:4,servic:[5,2,7],"while":5,abov:2,error:1,fun:5,exist:[2,3],layer:5,twistedmatrix:[5,3],tabl:[],henc:5,toolkit:5,kwarg:[4,8,6,7,3],myapp:6,postvalidatecustom:6,incom:[4,0,7,3],twistd:3,decor:[0,3],allow_extra_field:6,perform:5,make:5,same:3,handl:5,html:[6,3],zope:7,document:[5,6,3],breakdown:[],http:[0,1,2,3,4,5,6,7,8],driven:[2,1],extern:5,typic:2,appropri:[2,1],eleg:5,well:5,coreport:3,exampl:[2,6,3],thi:[4,8,5,2,3],rout:[0,2,3,4,5,6,7,8],latest:6,test1:4,test2:4,firstnam:2,when:3,rest:[0,5,2],filterapp:7,test_content_yaml:3,yet:5,languag:5,web:[0,5,2,6,3],application_xml:3,except:5,getal:2,blog:5,add:[0,5,7],book:5,input:[5,7],app:[2,7,3],match:1,build:5,real:3,applic:[4,0,5,2,3],around:7,format:5,read:5,irequestfilt:7,howto:[5,3],piec:3,realiz:5,like:[5,2],success:1,filterrequest:7,test_get_resourc:3,either:[5,7],popular:6,output:7,page:[],childid:6,www:6,some:5,sampl:[2,3],server:[5,1],librari:5,kei:[],getcustom:2,micro:[0,5],peticola:5,outgo:7,unit:3,test_xml:4,complic:5,core:[5,3],object:[0,2,3,4,5,6],run:[2,7,3],power:5,payment:2,"enum":[6,3],usag:5,alreadyexistsexcept:2,async:[8,5],"__name__":[2,3],post:[4,6,2,1,3],actual:1,constructor:7,other:5,own:5,effici:5,"float":3,automat:[4,5,3],wrap:[2,7],your:3,invoiceid:2,val:4,support:[4,0,8,7,3],custom:[5,2,6,7],avail:6,reli:5,interfac:7,low:5,"function":[8,1,3],returnvalu:8,form:6,streetnam:2,inlin:5,"true":6,whether:4,page_id:5,caller:4,asynchron:[0,5,8],similar:5,featur:[0,5],creat:[5,2,1],"int":[6,3],customerrestservic:2,twist:[0,5,2,8,3],implement:[2,6,7],krondo:5,excel:5,elementtre:4,field:6,corepost:[0,1,2,3,4,5,6,7],test:3,you:[8,5,2,7,3],node:[0,5],matur:5,mediatyp:3,"class":[5,2,6,7,3],sql:5,text_yaml:3,understand:5,invoic:2},objtypes:{},titles:["CorePost","HTTP codes","Modular REST applications","URL Routing","Content types","Introduction","Argument validation","Filters","Asynchronous Operations"],objnames:{},filenames:["index","http_codes","modules","url_routing","content_types","intro","arguments","filters","async"]})
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment