diff options
author | Nick Daly <Nick.M.Daly@gmail.com> | 2013-04-23 17:49:22 -0500 |
---|---|---|
committer | Nick Daly <Nick.M.Daly@gmail.com> | 2013-04-23 17:49:22 -0500 |
commit | f55c7a48ea534e342e6efbd4c7edaf1b1e07f61b (patch) | |
tree | fec45d97e4e976ef7ba5dde83f538fcf19092bc0 /vendor/CherryPy-3.2.0/py3/cherrypy/tutorial/tut08_generators_and_yield.py | |
parent | 157226f1b88bc090b677f9896aa62a0c734ebf14 (diff) |
Merged with James's upstream.
Hope I did it right. If I screwed up, withsqlite is borked.
Diffstat (limited to 'vendor/CherryPy-3.2.0/py3/cherrypy/tutorial/tut08_generators_and_yield.py')
-rw-r--r-- | vendor/CherryPy-3.2.0/py3/cherrypy/tutorial/tut08_generators_and_yield.py | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/vendor/CherryPy-3.2.0/py3/cherrypy/tutorial/tut08_generators_and_yield.py b/vendor/CherryPy-3.2.0/py3/cherrypy/tutorial/tut08_generators_and_yield.py deleted file mode 100644 index a6fbdc2..0000000 --- a/vendor/CherryPy-3.2.0/py3/cherrypy/tutorial/tut08_generators_and_yield.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -Bonus Tutorial: Using generators to return result bodies - -Instead of returning a complete result string, you can use the yield -statement to return one result part after another. This may be convenient -in situations where using a template package like CherryPy or Cheetah -would be overkill, and messy string concatenation too uncool. ;-) -""" - -import cherrypy - - -class GeneratorDemo: - - def header(self): - return "<html><body><h2>Generators rule!</h2>" - - def footer(self): - return "</body></html>" - - def index(self): - # Let's make up a list of users for presentation purposes - users = ['Remi', 'Carlos', 'Hendrik', 'Lorenzo Lamas'] - - # Every yield line adds one part to the total result body. - yield self.header() - yield "<h3>List of users:</h3>" - - for user in users: - yield "%s<br/>" % user - - yield self.footer() - index.exposed = True - - -import os.path -tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') - -if __name__ == '__main__': - # CherryPy always starts with app.root when trying to map request URIs - # to objects, so we need to mount a request handler root. A request - # to '/' will be mapped to HelloWorld().index(). - cherrypy.quickstart(GeneratorDemo(), config=tutconf) -else: - # This branch is for the test suite; you can ignore it. - cherrypy.tree.mount(GeneratorDemo(), config=tutconf) - |