[Twisted-Python] Http PUT

Andy Fundinger Andy at NewWorldElectric.com
Fri Oct 12 06:43:07 MDT 2007


Here's some sample code to get you started:

    def render_PUT(self,request):
        print "Got PUT"
        dataPage=request.content.getvalue()
        pageNumber=request.args.get("pagenumber",(0,))[0]
        (responseCode,message) = self._savePage(request.args["keynumber"][0],
self.userId,pageNumber,dataPage)
        request.setResponseCode(responseCode)
        return message

notice how you get at the PUT data via request.content.getvalue() I remember
needing a while to find that.  render_PUT can be added to
twisted.web.resource.Resource or a subclass as Jarek says.

-Andy Fundinger

On 10/12/07, Jarek Zgoda <jarek.zgoda at sensisoft.com> wrote:
>
> Voznesensky Vladimir napisaƂ(a):
>
> > I need to realise an HTTP server capable of serving PUT request.
> > There seems to be no standard twisted implementation for it.
> > Is it possible to realise and include it into the standard twisted
> > contribution?
> > I have no solid idea were to start with it.
>
> Start at twisted.web
>
> Just write a resource class (subclass of twisted.web.resource.Resource)
> that handles PUT requests by implementing render_PUT method.
>
> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>



-- 
Blog:  http://channel3b.wordpress.com
Second Life Name:  Ciemaar Flintoff

I am a sig Virus. Please put me in your sig so that I can continue to
replicate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20071012/16527386/attachment.html>


More information about the Twisted-Python mailing list