[Twisted-Python] Re: Teach Me Twisted?
alex clemesha
clemesha at gmail.com
Wed Jan 23 19:10:59 EST 2008
Hi there,
Thanks Steve Holden for organizing this, it's a great idea.
I've been using twisted for about a year now and I love it,
I'm a classic case of (as you can read all over the web):
"after the learning curve, you'll love Twisted"
so, yeah, more learning materials would be great for those starting out.
Some nice topics might include:
a) Start off simple with a "twisted.web2" example (everyone "gets" http)
b) then plug that into a simple sqlite database using "twisted.enterprise"
c) then plug some simple usage of "twisted.pb" that does something
in the backend, that gets presented to the pages being served by "
twisted.web2"
d) Show how using "twistd" is really convient
(i.e. "twistd -ny server.tac" and "twistd -y server.tac", with some logging
capability, etc)
Anyways, these are just random ideas, but they are things that took me a
while to
get going with, but now I find them so clean and useful.
Regarding Paul's post:
I did something like that a few month back and had a hard time gathering
> all the pieces of information ;) I still can't believe I have to parse
> raw response strings to handle POST ;))
You don't! This is all you need:
from twisted.web2 import resource, http, http_headers
CTYPE = {'content-type': http_headers.MimeType('text', 'html',
{'charset':'utf-8'})}
GetSomePostData(resource.PostableResource):
def render(self, request):
postval0 = request.args.get("val0", [""])[0]
postval1 = request.args.get("val1", [""])[0]
html = myhtmltemplates.comment_form_response(postval0, postval1)
#for example
return http.Response(200, CTYPE, html)
- Alex
>
>
> cheers
> Paul
>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20080123/c4f124dd/attachment.htm
More information about the Twisted-Python
mailing list