Changeset 1415
- Timestamp:
- 10/27/06 13:14:09
- Files:
-
- trunk/cherrypy/_cprequest.py (modified) (1 diff)
- trunk/cherrypy/_cptools.py (modified) (1 diff)
- trunk/cherrypy/lib/cptools.py (modified) (1 diff)
- trunk/cherrypy/test/test_core.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cprequest.py
r1406 r1415 540 540 elif isinstance(value, types.FileType): 541 541 value = file_generator(value) 542 elif isinstance(value, types.GeneratorType):543 value = flattener(value)544 542 elif value is None: 545 543 value = [] 546 544 obj._body = value 547 548 549 def flattener(input):550 """Yield the given input, recursively iterating over each result (if needed)."""551 for x in input:552 if not isinstance(x, types.GeneratorType):553 yield x554 else:555 for y in flattener(x):556 yield y557 545 558 546 trunk/cherrypy/_cptools.py
r1375 r1415 322 322 _d.digest_auth = Tool('on_start_resource', auth.digest_auth) 323 323 _d.trailing_slash = Tool('before_handler', cptools.trailing_slash) 324 _d.flatten = Tool('before_finalize', cptools.flatten) 324 325 325 326 del _d, cptools, encoding, auth, static, tidy trunk/cherrypy/lib/cptools.py
r1412 r1415 332 332 raise cherrypy.HTTPRedirect(new_url) 333 333 334 def flatten(): 335 """Wrap response.body in a generator that recursively iterates over body. 336 337 This allows cherrypy.response.body to consist of 'nested generators'; 338 that is, a set of generators that yield generators. 339 """ 340 import types 341 def flattener(input): 342 for x in input: 343 if not isinstance(x, types.GeneratorType): 344 yield x 345 else: 346 for y in flattener(x): 347 yield y 348 response = cherrypy.response 349 response.body = flattener(response.body) 350 trunk/cherrypy/test/test_core.py
r1400 r1415 215 215 def as_dblyield(self): 216 216 yield self.as_yield() 217 as_dblyield._cp_config = {'tools.flatten.on': True} 217 218 218 219 def as_refyield(self):

