Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A Twisted Web REST micro-framework

Project Description

Based on Flask API, with plans for integrated multiprocessing support for full usage of all CPUs. Provides a more Flask/Sinatra-style API on top of the core twisted.web APIs. Integrates FormEncode for path, form and query argument validation.

An example of a multi–module twisted.web CorePost REST application which exposes two separate REST services (for a Customer and Customer Address entities):

class CustomerRESTService():
    path = "/customer"

    def getAll(self,request):
        return DB.getAllCustomers()

    def get(self,request,customerId):
        return DB.getCustomer(customerId)

    def post(self,request,customerId,firstName,lastName):
        customer = Customer(customerId, firstName, lastName)
        return Response(201)

    def put(self,request,customerId,firstName,lastName):
        c = DB.getCustomer(customerId)
        (c.firstName,c.lastName) = (firstName,lastName)
        return Response(200)

    def delete(self,request,customerId):
        return Response(200)

    def deleteAll(self,request):
        return Response(200)

class CustomerAddressRESTService():
    path = "/customer/<customerId>/address"

    def getAll(self,request,customerId):
        return DB.getCustomer(customerId).addresses

    def get(self,request,customerId,addressId):
        return DB.getCustomerAddress(customerId, addressId)

    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)

    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)

    def delete(self,request,customerId,addressId):
        DB.getCustomerAddress(customerId, addressId) #validate address exists
        return Response(200)

    def deleteAll(self,request,customerId):
        c = DB.getCustomer(customerId)
        c.addresses = {}
        return Response(200)

def run_rest_app():
    app = RESTResource((CustomerRESTService(),CustomerAddressRESTService()))

if __name__ == "__main__":

And the BDD showing off its different features


  • 0.0.16:
  • 0.0.15:
    • minor bug fixes in auto-converting responses to JSON and parsing arguments/paths with unexpectec characters
  • 0.0.14:
  • 0.0.13:
    • perf fix to avoid unnecessary string concatenation when doing URL routing, after code review (thanks to Gerald Tremblay)
  • 0.0.12:
    • backwards incompatible change: added advanced URL routing for nested REST services. CorePost object is gone, REST services are now just standard classes. They get wrapped in a RESTResource object (see sample above) when exposed
  • 0.0.11:
    • added support for request/response filters
  • 0.0.10:
    • removed dependency on txZMQ which was not needed at this point (yet)
  • 0.0.9:
  • 0.0.8:
    • support for serializing of classes to JSON,XML,YAML based on caller’s Accept header
    • separate routing functionality from CorePost Resource object, in preparation for future multicore support
  • 0.0.7:
    • automatic parsing of incoming content (JSON, YAML, XML)
    • routing by incoming content type
    • automatic response conversion based on caller’s Accept header (JSON/YAML
    • support for defer.returnValue() in @inlineCallbacks route methods
  • 0.0.6 - redesigned API around classes and methods, rather than functions and global objects (after feedback from Twisted devs)
  • 0.0.5 - added FormEncode validation for arguments
  • 0.0.4 - path argument extraction, mandatory argument error checking
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
CorePost-0.0.16.tar.gz (11.9 kB) Copy SHA256 Checksum SHA256 Source Apr 17, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting