Package cherrypy :: Package test :: Module py25
[hide private]
[frames] | no frames]

Source Code for Module cherrypy.test.py25

 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