Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/twisted_8_1/twisted/flow/web.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 #
5 # Author: Clark Evans (cce@clarkevans.com)
6
7 """ flow.web
8
9 This contains wrappers to apply flow to components in twisted.web.*
10
11 """
12 from controller import Deferred
13 from twisted.web import resource, server
14 from twisted.python.failure import Failure
15
16 class Resource(resource.Resource):
17 """
18 A resource which uses flow in its page generation.
19
20 Use it like this::
21
22 from __future__ import generators
23 from twisted.flow import flow
24
25 def render(req):
26 req.write("<html><head><title>Delayed</title></head>")
27 req.write("<body><h1>Delayed WebPage</h1>")
28 yield flow.Cooperate(5)
29 req.write("<p>Delayed Content</p></body></html>")
30
31 if __name__=='__main__':
32 from twisted.internet import reactor
33 from twisted.web.server import Site
34 from twisted.flow.web import Resource
35 print "visit http://localhost:8081/ to view"
36 reactor.listenTCP(8081,Site(Resource(render)))
37 reactor.run()
38 """
39 def __init__(self, gen):
40 resource.Resource.__init__(self)
41 self.gen = gen
42
43 def isLeaf(self):
44 return true
45
46 def render(self, req):
47 self.d = Deferred(self.gen(req))
48 self.d.addErrback(lambda fail: fail.printTraceback())
49 self.d.addBoth(lambda ret: req.finish() or ret)
50 return server.NOT_DONE_YET
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/flow/topfiles/setup.py ('k') | third_party/twisted_8_1/twisted/flow/wrap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698