Commit 10885304 authored by Jacek Furmankiewicz's avatar Jacek Furmankiewicz

added better docs on how to return responses from REST services

parent c184036a
......@@ -5,6 +5,6 @@
<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>
<path>/corepost-pages</path>
</pydev_pathproperty>
</pydev_project>
#Fri Apr 20 15:05:37 EDT 2012
eclipse.preferences.version=1
encoding//doc/source/conf.py=utf-8
# 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
config: ba4b37ede2c9ab03178a68cf4d460b1c
tags: fbb0d17656682115ca4d033fb2f83ba1
......@@ -18,9 +18,10 @@ Features
url_routing
argument_parsing
arguments
http_codes
responses
content_types
modules
filters
http_codes
async
modules
Returning responses
===================
There are a number of ways in which you can return a response from a REST service
String
------
You can simply return a plain text String. CorePost will return the appropriate HTTP code for you::
@route("/",Http.GET)
def root(self,request,**kwargs):
return "Hello"
Dictionaries, lists or classes
------------------------------
You can return straight dictionaries::
@route("/",Http.GET)
def root(self,request,**kwargs):
return {"test":"test"}
or lists::
@route("/",Http.GET)
def root(self,request,**kwargs):
return [{"test":"test"},{"test":"test2"}]
or classes::
@route("/",Http.GET)
def root(self,request,**kwargs):
return SomeClass()
CorePost will serialize each of them to the appropriate content type (JSON,YAML or XML), depending on what the caller can accept.
Response objects
----------------
This option gives you the most control, as you can explicitly specify the response content, headers and HTTP code.
You need to return an instance of *corepost.Response* object::
class Response:
"""
Custom response object, can be returned instead of raw string response
"""
def __init__(self,code=200,entity=None,headers={}):
pass
Example::
@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)
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Argument parsing &mdash; CorePost 0.0.14 documentation</title>
<title>Argument parsing &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,7 +25,7 @@
<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="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="Argument validation" href="arguments.html" />
<link rel="prev" title="URL Routing" href="url_routing.html" />
</head>
......@@ -42,7 +42,7 @@
<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>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -175,7 +175,7 @@ for you without any additional effort.</p>
<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>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Argument validation &mdash; CorePost 0.0.14 documentation</title>
<title>Argument validation &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,8 +25,8 @@
<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="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="HTTP codes" href="http_codes.html" />
<link rel="prev" title="Argument parsing" href="argument_parsing.html" />
</head>
<body>
......@@ -37,12 +37,12 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="content_types.html" title="Content types"
<a href="http_codes.html" title="HTTP codes"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="argument_parsing.html" title="Argument parsing"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -98,8 +98,8 @@ Validators can be specified using a <em>formencode</em> Schema object, or via cu
<p class="topless"><a href="argument_parsing.html"
title="previous chapter">Argument parsing</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="content_types.html"
title="next chapter">Content types</a></p>
<p class="topless"><a href="http_codes.html"
title="next chapter">HTTP codes</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/arguments.txt"
......@@ -129,12 +129,12 @@ Validators can be specified using a <em>formencode</em> Schema object, or via cu
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="content_types.html" title="Content types"
<a href="http_codes.html" title="HTTP codes"
>next</a> |</li>
<li class="right" >
<a href="argument_parsing.html" title="Argument parsing"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Asynchronous Operations &mdash; CorePost 0.0.14 documentation</title>
<title>Asynchronous Operations &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,9 +25,8 @@
<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="Modular REST applications" href="modules.html" />
<link rel="prev" title="HTTP codes" href="http_codes.html" />
<link rel="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="prev" title="Filters" href="filters.html" />
</head>
<body>
<div class="related">
......@@ -37,12 +36,9 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="modules.html" title="Modular REST applications"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
<a href="filters.html" title="Filters"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -83,11 +79,8 @@
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="http_codes.html"
title="previous chapter">HTTP codes</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="modules.html"
title="next chapter">Modular REST applications</a></p>
<p class="topless"><a href="filters.html"
title="previous chapter">Filters</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/async.txt"
......@@ -117,12 +110,9 @@
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="modules.html" title="Modular REST applications"
>next</a> |</li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
<a href="filters.html" title="Filters"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Content types &mdash; CorePost 0.0.14 documentation</title>
<title>Content types &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,9 +25,9 @@
<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="Filters" href="filters.html" />
<link rel="prev" title="Argument validation" href="arguments.html" />
<link rel="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="Modular REST applications" href="modules.html" />
<link rel="prev" title="Returning responses" href="responses.html" />
</head>
<body>
<div class="related">
......@@ -37,12 +37,12 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="filters.html" title="Filters"
<a href="modules.html" title="Modular REST applications"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="arguments.html" title="Argument validation"
<a href="responses.html" title="Returning responses"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -116,11 +116,11 @@ Depending whether the caller can accept JSON (default) or YAML, the Python objec
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="arguments.html"
title="previous chapter">Argument validation</a></p>
<p class="topless"><a href="responses.html"
title="previous chapter">Returning responses</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="filters.html"
title="next chapter">Filters</a></p>
<p class="topless"><a href="modules.html"
title="next chapter">Modular REST applications</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/content_types.txt"
......@@ -150,12 +150,12 @@ Depending whether the caller can accept JSON (default) or YAML, the Python objec
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="filters.html" title="Filters"
<a href="modules.html" title="Modular REST applications"
>next</a> |</li>
<li class="right" >
<a href="arguments.html" title="Argument validation"
<a href="responses.html" title="Returning responses"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Filters &mdash; CorePost 0.0.14 documentation</title>
<title>Filters &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,9 +25,9 @@
<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="HTTP codes" href="http_codes.html" />
<link rel="prev" title="Content types" href="content_types.html" />
<link rel="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="Asynchronous Operations" href="async.html" />
<link rel="prev" title="Modular REST applications" href="modules.html" />
</head>
<body>
<div class="related">
......@@ -37,12 +37,12 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
<a href="async.html" title="Asynchronous Operations"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="content_types.html" title="Content types"
<a href="modules.html" title="Modular REST applications"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -115,11 +115,11 @@
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="content_types.html"
title="previous chapter">Content types</a></p>
<p class="topless"><a href="modules.html"
title="previous chapter">Modular REST applications</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="http_codes.html"
title="next chapter">HTTP codes</a></p>
<p class="topless"><a href="async.html"
title="next chapter">Asynchronous Operations</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/filters.txt"
......@@ -149,12 +149,12 @@
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="http_codes.html" title="HTTP codes"
<a href="async.html" title="Asynchronous Operations"
>next</a> |</li>
<li class="right" >
<a href="content_types.html" title="Content types"
<a href="modules.html" title="Modular REST applications"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -10,7 +10,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index &mdash; CorePost 0.0.14 documentation</title>
<title>Index &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -18,7 +18,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -27,7 +27,7 @@
<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="top" title="CorePost 0.0.16 documentation" href="index.html" />
</head>
<body>
<div class="related">
......@@ -36,7 +36,7 @@
<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>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -84,7 +84,7 @@
<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>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTTP codes &mdash; CorePost 0.0.14 documentation</title>
<title>HTTP codes &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,9 +25,9 @@
<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="Asynchronous Operations" href="async.html" />
<link rel="prev" title="Filters" href="filters.html" />
<link rel="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="Returning responses" href="responses.html" />
<link rel="prev" title="Argument validation" href="arguments.html" />
</head>
<body>
<div class="related">
......@@ -37,12 +37,12 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="async.html" title="Asynchronous Operations"
<a href="responses.html" title="Returning responses"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="filters.html" title="Filters"
<a href="arguments.html" title="Argument validation"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -75,11 +75,11 @@
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="filters.html"
title="previous chapter">Filters</a></p>
<p class="topless"><a href="arguments.html"
title="previous chapter">Argument validation</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="async.html"
title="next chapter">Asynchronous Operations</a></p>
<p class="topless"><a href="responses.html"
title="next chapter">Returning responses</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/http_codes.txt"
......@@ -109,12 +109,12 @@
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="async.html" title="Asynchronous Operations"
<a href="responses.html" title="Returning responses"
>next</a> |</li>
<li class="right" >
<a href="filters.html" title="Filters"
<a href="arguments.html" title="Argument validation"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CorePost &mdash; CorePost 0.0.14 documentation</title>
<title>CorePost &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,7 +25,7 @@
<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="#" />
<link rel="top" title="CorePost 0.0.16 documentation" href="#" />
<link rel="next" title="Introduction" href="intro.html" />
</head>
<body>
......@@ -38,7 +38,7 @@
<li class="right" >
<a href="intro.html" title="Introduction"
accesskey="N">next</a> |</li>
<li><a href="#">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="#">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -82,18 +82,24 @@
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="arguments.html">Argument validation</a></li>
<li class="toctree-l1"><a class="reference internal" href="http_codes.html">HTTP codes</a></li>
<li class="toctree-l1"><a class="reference internal" href="responses.html">Returning responses</a><ul>
<li class="toctree-l2"><a class="reference internal" href="responses.html#string">String</a></li>
<li class="toctree-l2"><a class="reference internal" href="responses.html#dictionaries-lists-or-classes">Dictionaries, lists or classes</a></li>
<li class="toctree-l2"><a class="reference internal" href="responses.html#response-objects">Response objects</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="content_types.html">Content types</a><ul>
<li class="toctree-l2"><a class="reference internal" href="content_types.html#parsing-of-incoming-content">Parsing of incoming content</a></li>
<li class="toctree-l2"><a class="reference internal" href="content_types.html#converting-python-objects-to-expected-content-type">Converting Python objects to expected content type</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules.html">Modular REST applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="filters.html">Filters</a></li>
<li class="toctree-l1"><a class="reference internal" href="http_codes.html">HTTP codes</a></li>
<li class="toctree-l1"><a class="reference internal" href="async.html">Asynchronous Operations</a><ul>
<li class="toctree-l2"><a class="reference internal" href="async.html#defer-inlinecallbacks-support">&#64;defer.inlineCallbacks support</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules.html">Modular REST applications</a></li>
</ul>
</div>
</div>
......@@ -152,7 +158,7 @@
<li class="right" >
<a href="intro.html" title="Introduction"
>next</a> |</li>
<li><a href="#">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="#">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Introduction &mdash; CorePost 0.0.14 documentation</title>
<title>Introduction &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,7 +25,7 @@
<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="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="URL Routing" href="url_routing.html" />
<link rel="prev" title="CorePost" href="index.html" />
</head>
......@@ -42,7 +42,7 @@
<li class="right" >
<a href="index.html" title="CorePost"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -155,7 +155,7 @@ while letting it take care of common required plumbing. That&#8217;s it.</p>
<li class="right" >
<a href="index.html" title="CorePost"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modular REST applications &mdash; CorePost 0.0.14 documentation</title>
<title>Modular REST applications &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,8 +25,9 @@
<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="Asynchronous Operations" href="async.html" />
<link rel="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="Filters" href="filters.html" />
<link rel="prev" title="Content types" href="content_types.html" />
</head>
<body>
<div class="related">
......@@ -36,9 +37,12 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="async.html" title="Asynchronous Operations"
<a href="filters.html" title="Filters"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="content_types.html" title="Content types"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -180,8 +184,11 @@ and it takes care of routing the request to the appropriate class.</p>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="async.html"
title="previous chapter">Asynchronous Operations</a></p>
<p class="topless"><a href="content_types.html"
title="previous chapter">Content types</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="filters.html"
title="next chapter">Filters</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/modules.txt"
......@@ -211,9 +218,12 @@ and it takes care of routing the request to the appropriate class.</p>
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="async.html" title="Asynchronous Operations"
<a href="filters.html" title="Filters"
>next</a> |</li>
<li class="right" >
<a href="content_types.html" title="Content types"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search &mdash; CorePost 0.0.14 documentation</title>
<title>Search &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -26,7 +26,7 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/searchtools.js"></script>
<link rel="top" title="CorePost 0.0.14 documentation" href="index.html" />
<link rel="top" title="CorePost 0.0.16 documentation" href="index.html" />
<script type="text/javascript">
jQuery(function() { Search.loadIndex("searchindex.js"); });
</script>
......@@ -40,7 +40,7 @@
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -88,7 +88,7 @@
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>URL Routing &mdash; CorePost 0.0.14 documentation</title>
<title>URL Routing &mdash; CorePost 0.0.16 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
......@@ -16,7 +16,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.14',
VERSION: '0.0.16',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
......@@ -25,7 +25,7 @@
<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="top" title="CorePost 0.0.16 documentation" href="index.html" />
<link rel="next" title="Argument parsing" href="argument_parsing.html" />
<link rel="prev" title="Introduction" href="intro.html" />
</head>
......@@ -42,7 +42,7 @@
<li class="right" >
<a href="intro.html" title="Introduction"
accesskey="P">previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
......@@ -189,7 +189,7 @@ In a real production application you would use existing Twisted <em>twistd</em>
<li class="right" >
<a href="intro.html" title="Introduction"
>previous</a> |</li>
<li><a href="index.html">CorePost 0.0.14 documentation</a> &raquo;</li>
<li><a href="index.html">CorePost 0.0.16 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
......
......@@ -61,24 +61,33 @@
\@writefile{toc}{\contentsline {section}{\numberline {2.3}Argument validation}{6}{section.2.3}}
\newlabel{arguments:argument-validation}{{2.3}{6}{Argument validation\relax }{section.2.3}{}}
\newlabel{arguments::doc}{{2.3}{6}{Argument validation\relax }{section.2.3}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.4}Content types}{6}{section.2.4}}
\newlabel{content_types::doc}{{2.4}{6}{Content types\relax }{section.2.4}{}}
\newlabel{content_types:content-types}{{2.4}{6}{Content types\relax }{section.2.4}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.4.1}Parsing of incoming content}{6}{subsection.2.4.1}}
\newlabel{content_types:parsing-of-incoming-content}{{2.4.1}{6}{Parsing of incoming content\relax }{subsection.2.4.1}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.4.2}Converting Python objects to expected content type}{7}{subsection.2.4.2}}
\newlabel{content_types:converting-python-objects-to-expected-content-type}{{2.4.2}{7}{Converting Python objects to expected content type\relax }{subsection.2.4.2}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.5}Filters}{7}{section.2.5}}
\newlabel{filters::doc}{{2.5}{7}{Filters\relax }{section.2.5}{}}
\newlabel{filters:filters}{{2.5}{7}{Filters\relax }{section.2.5}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.6}HTTP codes}{8}{section.2.6}}
\newlabel{http_codes::doc}{{2.6}{8}{HTTP codes\relax }{section.2.6}{}}
\newlabel{http_codes:http-codes}{{2.6}{8}{HTTP codes\relax }{section.2.6}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.7}Asynchronous Operations}{8}{section.2.7}}
\newlabel{async:asynchronous-operations}{{2.7}{8}{Asynchronous Operations\relax }{section.2.7}{}}
\newlabel{async::doc}{{2.7}{8}{Asynchronous Operations\relax }{section.2.7}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.7.1}@defer.inlineCallbacks support}{8}{subsection.2.7.1}}
\newlabel{async:defer-inlinecallbacks-support}{{2.7.1}{8}{@defer.inlineCallbacks support\relax }{subsection.2.7.1}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.8}Modular REST applications}{9}{section.2.8}}
\newlabel{modules::doc}{{2.8}{9}{Modular REST applications\relax }{section.2.8}{}}
\newlabel{modules:modular-rest-applications}{{2.8}{9}{Modular REST applications\relax }{section.2.8}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.4}HTTP codes}{6}{section.2.4}}
\newlabel{http_codes::doc}{{2.4}{6}{HTTP codes\relax }{section.2.4}{}}
\newlabel{http_codes:http-codes}{{2.4}{6}{HTTP codes\relax }{section.2.4}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.5}Returning responses}{7}{section.2.5}}
\newlabel{responses::doc}{{2.5}{7}{Returning responses\relax }{section.2.5}{}}
\newlabel{responses:returning-responses}{{2.5}{7}{Returning responses\relax }{section.2.5}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.5.1}String}{7}{subsection.2.5.1}}
\newlabel{responses:string}{{2.5.1}{7}{String\relax }{subsection.2.5.1}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.5.2}Dictionaries, lists or classes}{7}{subsection.2.5.2}}
\newlabel{responses:dictionaries-lists-or-classes}{{2.5.2}{7}{Dictionaries, lists or classes\relax }{subsection.2.5.2}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.5.3}Response objects}{7}{subsection.2.5.3}}
\newlabel{responses:response-objects}{{2.5.3}{7}{Response objects\relax }{subsection.2.5.3}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.6}Content types}{8}{section.2.6}}
\newlabel{content_types::doc}{{2.6}{8}{Content types\relax }{section.2.6}{}}
\newlabel{content_types:content-types}{{2.6}{8}{Content types\relax }{section.2.6}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.6.1}Parsing of incoming content}{8}{subsection.2.6.1}}
\newlabel{content_types:parsing-of-incoming-content}{{2.6.1}{8}{Parsing of incoming content\relax }{subsection.2.6.1}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.6.2}Converting Python objects to expected content type}{8}{subsection.2.6.2}}
\newlabel{content_types:converting-python-objects-to-expected-content-type}{{2.6.2}{8}{Converting Python objects to expected content type\relax }{subsection.2.6.2}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.7}Modular REST applications}{8}{section.2.7}}
\newlabel{modules::doc}{{2.7}{8}{Modular REST applications\relax }{section.2.7}{}}
\newlabel{modules:modular-rest-applications}{{2.7}{8}{Modular REST applications\relax }{section.2.7}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.8}Filters}{11}{section.2.8}}
\newlabel{filters::doc}{{2.8}{11}{Filters\relax }{section.2.8}{}}
\newlabel{filters:filters}{{2.8}{11}{Filters\relax }{section.2.8}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.9}Asynchronous Operations}{12}{section.2.9}}
\newlabel{async:asynchronous-operations}{{2.9}{12}{Asynchronous Operations\relax }{section.2.9}{}}
\newlabel{async::doc}{{2.9}{12}{Asynchronous Operations\relax }{section.2.9}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.9.1}@defer.inlineCallbacks support}{12}{subsection.2.9.1}}
\newlabel{async:defer-inlinecallbacks-support}{{2.9.1}{12}{@defer.inlineCallbacks support\relax }{subsection.2.9.1}{}}
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2012.3.27) 17 APR 2012 16:18
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2012.3.27) 20 APR 2012 15:28
entering extended mode
%&-line parsing enabled.
**CorePost.tex
......@@ -904,33 +904,33 @@ LaTeX Font Info: Font shape `T1/pcr/m/it' in size <9> not available
] [4] [5] [6] [7]
[8] [9]
Underfull \vbox (badness 10000) detected at line 750
Underfull \vbox (badness 10000) detected at line 740
[]
Underfull \vbox (badness 10000) detected at line 750
Underfull \vbox (badness 10000) detected at line 740
[]
[10] (./CorePost.ind) [11] (./CorePost.aux) )
[10] [11] (./CorePost.ind) [12] (./CorePost.aux) )
Here is how much of TeX's memory you used:
7981 strings out of 493848
108170 string characters out of 1152823
197503 words of memory out of 3000000
11019 multiletter control sequences out of 15000+50000
7992 strings out of 493848
108383 string characters out of 1152823
197759 words of memory out of 3000000
11025 multiletter control sequences out of 15000+50000
55793 words of font info for 63 fonts, out of 3000000 for 9000
715 hyphenation exceptions out of 8191
45i,12n,45p,426b,381s stack positions out of 5000i,500n,10000p,200000b,50000s
{/usr/share/texmf-texlive/fonts/en
c/dvips/base/8r.enc}</usr/share/texmf-texlive/fonts/type1/urw/courier/ucrb8a.pf
b></usr/share/texmf-texlive/fonts/type1/urw/courier/ucrr8a.pfb></usr/share/texm
f-texlive/fonts/type1/urw/courier/ucrro8a.pfb></usr/share/texmf-texlive/fonts/t
ype1/urw/helvetic/uhvb8a.pfb></usr/share/texmf-texlive/fonts/type1/urw/helvetic
/uhvbo8a.pfb></usr/share/texmf-texlive/fonts/type1/urw/times/utmb8a.pfb></usr/s
hare/texmf-texlive/fonts/type1/urw/times/utmr8a.pfb></usr/share/texmf-texlive/f
onts/type1/urw/times/utmri8a.pfb>
Output written on CorePost.pdf (15 pages, 149328 bytes).
{/usr/share/texmf-texlive/fon
ts/enc/dvips/base/8r.enc}</usr/share/texmf-texlive/fonts/type1/urw/courier/ucrb
8a.pfb></usr/share/texmf-texlive/fonts/type1/urw/courier/ucrr8a.pfb></usr/share
/texmf-texlive/fonts/type1/urw/courier/ucrro8a.pfb></usr/share/texmf-texlive/fo
nts/type1/urw/helvetic/uhvb8a.pfb></usr/share/texmf-texlive/fonts/type1/urw/hel
vetic/uhvbo8a.pfb></usr/share/texmf-texlive/fonts/type1/urw/times/utmb8a.pfb></
usr/share/texmf-texlive/fonts/type1/urw/times/utmr8a.pfb></usr/share/texmf-texl
ive/fonts/type1/urw/times/utmri8a.pfb>
Output written on CorePost.pdf (16 pages, 153055 bytes).
PDF statistics:
192 PDF objects out of 1000 (max. 8388607)
42 named destinations out of 1000 (max. 500000)
89 words of extra memory for PDF output out of 10000 (max. 10000000)
205 PDF objects out of 1000 (max. 8388607)
47 named destinations out of 1000 (max. 500000)
97 words of extra memory for PDF output out of 10000 (max. 10000000)
......@@ -4,8 +4,9 @@
\BOOKMARK [1][-]{section.2.1}{URL Routing}{chapter.2}
\BOOKMARK [1][-]{section.2.2}{Argument parsing}{chapter.2}
\BOOKMARK [1][-]{section.2.3}{Argument validation}{chapter.2}
\BOOKMARK [1][-]{section.2.4}{Content types}{chapter.2}
\BOOKMARK [1][-]{section.2.5}{Filters}{chapter.2}
\BOOKMARK [1][-]{section.2.6}{HTTP codes}{chapter.2}
\BOOKMARK [1][-]{section.2.7}{Asynchronous Operations}{chapter.2}
\BOOKMARK [1][-]{section.2.8}{Modular REST applications}{chapter.2}
\BOOKMARK [1][-]{section.2.4}{HTTP codes}{chapter.2}
\BOOKMARK [1][-]{section.2.5}{Returning responses}{chapter.2}
\BOOKMARK [1][-]{section.2.6}{Content types}{chapter.2}
\BOOKMARK [1][-]{section.2.7}{Modular REST applications}{chapter.2}
\BOOKMARK [1][-]{section.2.8}{Filters}{chapter.2}
\BOOKMARK [1][-]{section.2.9}{Asynchronous Operations}{chapter.2}
This diff is collapsed.
......@@ -17,11 +17,15 @@
\contentsline {subsection}{\numberline {2.2.4}YAML document arguments}{5}{subsection.2.2.4}
\contentsline {subsection}{\numberline {2.2.5}XML document arguments}{5}{subsection.2.2.5}
\contentsline {section}{\numberline {2.3}Argument validation}{6}{section.2.3}
\contentsline {section}{\numberline {2.4}Content types}{6}{section.2.4}
\contentsline {subsection}{\numberline {2.4.1}Parsing of incoming content}{6}{subsection.2.4.1}
\contentsline {subsection}{\numberline {2.4.2}Converting Python objects to expected content type}{7}{subsection.2.4.2}
\contentsline {section}{\numberline {2.5}Filters}{7}{section.2.5}
\contentsline {section}{\numberline {2.6}HTTP codes}{8}{section.2.6}
\contentsline {section}{\numberline {2.7}Asynchronous Operations}{8}{section.2.7}
\contentsline {subsection}{\numberline {2.7.1}@defer.inlineCallbacks support}{8}{subsection.2.7.1}
\contentsline {section}{\numberline {2.8}Modular REST applications}{9}{section.2.8}
\contentsline {section}{\numberline {2.4}HTTP codes}{6}{section.2.4}
\contentsline {section}{\numberline {2.5}Returning responses}{7}{section.2.5}
\contentsline {subsection}{\numberline {2.5.1}String}{7}{subsection.2.5.1}
\contentsline {subsection}{\numberline {2.5.2}Dictionaries, lists or classes}{7}{subsection.2.5.2}
\contentsline {subsection}{\numberline {2.5.3}Response objects}{7}{subsection.2.5.3}
\contentsline {section}{\numberline {2.6}Content types}{8}{section.2.6}
\contentsline {subsection}{\numberline {2.6.1}Parsing of incoming content}{8}{subsection.2.6.1}
\contentsline {subsection}{\numberline {2.6.2}Converting Python objects to expected content type}{8}{subsection.2.6.2}
\contentsline {section}{\numberline {2.7}Modular REST applications}{8}{section.2.7}
\contentsline {section}{\numberline {2.8}Filters}{11}{section.2.8}
\contentsline {section}{\numberline {2.9}Asynchronous Operations}{12}{section.2.9}
\contentsline {subsection}{\numberline {2.9.1}@defer.inlineCallbacks support}{12}{subsection.2.9.1}
......@@ -49,9 +49,9 @@ copyright = u'2012, Jacek Furmankiewicz'
# built documents.
#
# The short X.Y version.
version = '0.0.14'
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.0.14'
release = '0.0.16'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -18,9 +18,10 @@ Features
url_routing
argument_parsing
arguments
http_codes
responses
content_types
modules
filters
http_codes
async
modules
Returning responses
===================
There are a number of ways in which you can return a response from a REST service
String
------
You can simply return a plain text String. CorePost will return the appropriate HTTP code for you::
@route("/",Http.GET)
def root(self,request,**kwargs):
return "Hello"
Dictionaries, lists or classes
------------------------------
You can return straight dictionaries::
@route("/",Http.GET)
def root(self,request,**kwargs):
return {"test":"test"}
or lists::
@route("/",Http.GET)
def root(self,request,**kwargs):
return [{"test":"test"},{"test":"test2"}]
or classes::
@route("/",Http.GET)
def root(self,request,**kwargs):
return SomeClass()
CorePost will serialize each of them to the appropriate content type (JSON,YAML or XML), depending on what the caller can accept.
Response objects
----------------
This option gives you the most control, as you can explicitly specify the response content, headers and HTTP code.
You need to return an instance of *corepost.Response* object::
class Response:
"""
Custom response object, can be returned instead of raw string response
"""
def __init__(self,code=200,entity=None,headers={}):
pass
Example::
@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)
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