[Twisted-web] CorePost - a tiny Flask-style REST microframework for twisted.web
Jacek Furmankiewicz
jacek99 at gmail.com
Sat Sep 3 23:28:29 EDT 2011
Hi, I just uploaded CorePost 0.0.5 to PyPi.
CorePost is a REST microframework built on top of the core twisted.web APIs,
providing a Flask-inspired API for building REST applications.
Version 0.0.5 integrates FormEncode for integrated path/form/query argument
validation,
similar to the way Pylons/TurboGears use it.
Example:
from corepost.web import CorePost, validate
from corepost.enums import Http
from formencode import Schema, validators
app = CorePost()
class TestSchema(Schema):
allow_extra_fields = True
childId = validators.Regex(regex="^value1|value2$")
@app.route("/validate/<int:rootId>/schema",Http.POST)
@validate(schema=TestSchema)
def postValidateSchema(request,rootId,childId,**kwargs):
'''Validate using a common schema'''
return "%s - %s - %s" % (rootId,childId,kwargs)
@app.route("/validate/<int:rootId>/custom",Http.POST)
@validate(childId=validators.Regex(regex="^value1|value2$"))
def postValidateCustom(request,rootId,childId,**kwargs):
'''Validate using argument-specific validators'
return "%s - %s - %s" % (rootId,childId,kwargs)
More docs on our site:
https://github.com/jacek99/corepost
Any feedback is welcome
Cheers,
Jacek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20110903/5c946d4f/attachment.htm
More information about the Twisted-web
mailing list