Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

root/trunk/cherrypy/test/py25.py

Revision 1992 (checked in by fumanchu, 5 months ago)

Test for #829 (@tools.response.headers doesn't appear to work with response.stream True).

  • Property svn:eol-style set to native
Line 
1 """Test module for Python 2.5-specific syntax, like the @-decorator syntax."""
2
3 from cherrypy import expose, tools
4
5
6 class ExposeExamples(object):
7    
8     @expose
9     def no_call(self):
10         return "Mr E. R. Bradshaw"
11    
12     @expose()
13     def call_empty(self):
14         return "Mrs. B.J. Smegma"
15    
16     @expose("call_alias")
17     def nesbitt(self):
18         return "Mr Nesbitt"
19    
20     @expose(["alias1", "alias2"])
21     def andrews(self):
22         return "Mr Ken Andrews"
23    
24     @expose(alias="alias3")
25     def watson(self):
26         return "Mr. and Mrs. Watson"
27
28
29 class ToolExamples(object):
30    
31     @expose
32     @tools.response_headers(headers=[('Content-Type', 'application/data')])
33     def blah(self):
34         yield "blah"
35     # This is here to demonstrate that _cp_config = {...} overwrites
36     # the _cp_config attribute added by the Tool decorator. You have
37     # to write _cp_config[k] = v or _cp_config.update(...) instead.
38     blah._cp_config['response.stream'] = True
39
40
Note: See TracBrowser for help on using the browser.

Hosted by WebFaction

Log in as guest/cpguest to create tickets