CorePost 0.0.7, the REST microframework built on top of twisted.web is out.<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://pypi.python.org/pypi/CorePost/0.0.7">http://pypi.python.org/pypi/CorePost/0.0.7</a></div>
<div><br></div><div>This is a big release with lots of enhancements all around content types:</div><div><br></div><div>1) automatic parsing of incoming content based on type</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; "><pre style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; background-color: rgb(238, 238, 238); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(221, 221, 221); border-right-color: rgb(221, 221, 221); border-bottom-color: rgb(221, 221, 221); border-left-color: rgb(221, 221, 221); color: rgb(68, 68, 68); overflow-x: auto; overflow-y: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0664062) 0px 1px 2px inset; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px; ">
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px !important; background-color: rgb(238, 238, 238) !important; color: rgb(68, 68, 68) !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: none !important; border-right-style: none !important; border-bottom-style: none !important; border-left-style: none !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; border-width: initial !important; border-color: initial !important; ">@route(&quot;/post/json&quot;,(Http.POST,Http.PUT))
def test_json(self,request,**kwargs):
    return &quot;%s&quot; % json.dumps(request.json)

@route(&quot;/post/xml&quot;,(Http.POST,Http.PUT))
def test_xml(self,request,**kwargs):
    return &quot;%s&quot; % ElementTree.tostring(request.xml)

@route(&quot;/post/yaml&quot;,(Http.POST,Http.PUT))
def test_yaml(self,request,**kwargs):
    return &quot;%s&quot; % yaml.dump(request.yaml)</code></pre></span></div><div><br></div><div>2) ability to route to different methods for the same URL by incoming content</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; "><pre style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; background-color: rgb(238, 238, 238); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(221, 221, 221); border-right-color: rgb(221, 221, 221); border-bottom-color: rgb(221, 221, 221); border-left-color: rgb(221, 221, 221); color: rgb(68, 68, 68); overflow-x: auto; overflow-y: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0664062) 0px 1px 2px inset; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px; ">
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px !important; background-color: rgb(238, 238, 238) !important; color: rgb(68, 68, 68) !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: none !important; border-right-style: none !important; border-bottom-style: none !important; border-left-style: none !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; border-width: initial !important; border-color: initial !important; ">@route(&quot;/post/by/content&quot;,(Http.POST,Http.PUT),MediaType.APPLICATION_JSON)
def test_content_app_json(self,request,**kwargs):
    return request.received_headers[HttpHeader.CONTENT_TYPE]

@route(&quot;/post/by/content&quot;,(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(&quot;/post/by/content&quot;,(Http.POST,Http.PUT),MediaType.TEXT_YAML)
def test_content_yaml(self,request,**kwargs):
    return request.received_headers[HttpHeader.CONTENT_TYPE]

@route(&quot;/post/by/content&quot;,(Http.POST,Http.PUT))
def test_content_catch_all(self,request,**kwargs):
    return MediaType.WILDCARD</code></pre></span></div><div>3) ability to return dict/list response and have them automatically convert to JSON or YAML, depending on what caller can Accept</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; "><pre style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; background-color: rgb(238, 238, 238); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(221, 221, 221); border-right-color: rgb(221, 221, 221); border-bottom-color: rgb(221, 221, 221); border-left-color: rgb(221, 221, 221); color: rgb(68, 68, 68); overflow-x: auto; overflow-y: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0664062) 0px 1px 2px inset; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px; ">
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px !important; background-color: rgb(238, 238, 238) !important; color: rgb(68, 68, 68) !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: none !important; border-right-style: none !important; border-bottom-style: none !important; border-left-style: none !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; border-width: initial !important; border-color: initial !important; ">@route(&quot;/return/by/accept&quot;)
def test_return_content_by_accepts(self,request,**kwargs):
    val = [{&quot;test1&quot;:&quot;Test1&quot;},{&quot;test2&quot;:&quot;Test2&quot;}]
    return val
</code></pre><p style="margin-top: 1em !important; margin-right: 0px !important; margin-bottom: 1em !important; margin-left: 0px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5em !important; ">
Calling this URL with &quot;Accept: application/json&quot; will return:</p><pre style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; background-color: rgb(238, 238, 238); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(221, 221, 221); border-right-color: rgb(221, 221, 221); border-bottom-color: rgb(221, 221, 221); border-left-color: rgb(221, 221, 221); color: rgb(68, 68, 68); overflow-x: auto; overflow-y: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0664062) 0px 1px 2px inset; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px; ">
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px !important; background-color: rgb(238, 238, 238) !important; color: rgb(68, 68, 68) !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: none !important; border-right-style: none !important; border-bottom-style: none !important; border-left-style: none !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; border-width: initial !important; border-color: initial !important; ">[{&quot;test1&quot;: &quot;Test1&quot;}, {&quot;test2&quot;: &quot;Test2&quot;}]
</code></pre><p style="margin-top: 1em !important; margin-right: 0px !important; margin-bottom: 1em !important; margin-left: 0px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5em !important; ">
Calling it with &quot;Accept: text/yaml&quot; will return:</p><pre style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; background-color: rgb(238, 238, 238); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(221, 221, 221); border-right-color: rgb(221, 221, 221); border-bottom-color: rgb(221, 221, 221); border-left-color: rgb(221, 221, 221); color: rgb(68, 68, 68); overflow-x: auto; overflow-y: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0664062) 0px 1px 2px inset; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px; ">
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px !important; background-color: rgb(238, 238, 238) !important; color: rgb(68, 68, 68) !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: none !important; border-right-style: none !important; border-bottom-style: none !important; border-left-style: none !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; border-width: initial !important; border-color: initial !important; ">- {test1: Test1}
- {test2: Test2} </code></pre></span></div><div>4) proper support for <i>defer.returnValue()* </i>in @defer.inlineCallbacks routers (which supports the auto-conversion shown above)</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; "><pre style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; background-color: rgb(238, 238, 238); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(221, 221, 221); border-right-color: rgb(221, 221, 221); border-bottom-color: rgb(221, 221, 221); border-left-color: rgb(221, 221, 221); color: rgb(68, 68, 68); overflow-x: auto; overflow-y: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0664062) 0px 1px 2px inset; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px; ">
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; font: normal normal normal 12px/normal &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px !important; background-color: rgb(238, 238, 238) !important; color: rgb(68, 68, 68) !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: none !important; border-right-style: none !important; border-bottom-style: none !important; border-left-style: none !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; border-width: initial !important; border-color: initial !important; ">@route(&quot;/&quot;,Http.GET)
@defer.inlineCallbacks
def root(self,request,**kwargs):
    val1 = yield db.query(&quot;SELECT ....&quot;)
    val2 = yield db.query(&quot;SELECT ....&quot;)
    defer.returnValue(val1 + val2)</code></pre></span></div><div><br></div><div>Cheers,</div><div>Jacek</div><div><br></div>