[Twisted-Python] How to design REST API with Twisted?

Glyph Lefkowitz glyph at twistedmatrix.com
Thu Nov 12 19:53:40 MST 2015


> On Nov 12, 2015, at 7:33 AM, Wang Yan <snailcoder at 163.com> wrote:
> 
> Absolutely that's what I'm looking for! Thanks a lot!

Glad I could help!

> However, I'm wondering if Twisted and Klein support filtering results. For example, the User table in MySQL contains id, name and age fields. How can I get all users whose name are "Alan" and age > 16? It seems I need a filter, but I'm not sure how to implement such a filter or resource with Twisted and Klein.

Klein is pretty purely a web-facing framework; it just helps you built the HTTP stuff that answers queries.  It doesn't help you talk to a database at all; you have to figure out your own way to do that.  This is historically a weak area for Twisted, sadly; you might find https://pypi.python.org/pypi/twextpy/ <https://pypi.python.org/pypi/twextpy/> useful as this brings the state of the art forward somewhat.

https://twistedmatrix.com/trac/ticket/7917 <https://twistedmatrix.com/trac/ticket/7917> is a ticket to bring that stuff into Twisted itself; if you are interested in Twisted/Database interaction, perhaps you could help split up the code there into smaller branches that can be merged.

Thanks!

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20151112/0afe913a/attachment-0002.html>


More information about the Twisted-Python mailing list