Author: chrisz
Date: Tue Jan 11 09:22:48 2011
New Revision: 7201
URL: http://trac.turbogears.org/changeset/7201
Log:
Allow custom iterators as controller output, particularly because
the file_generator of CherryPy 3.2 is not really a generator any more.
Modified:
branches/1.5/turbogears/controllers.py
Modified: branches/1.5/turbogears/controllers.py
==============================================================================
--- branches/1.5/turbogears/controllers.py Tue Jan 11 08:49:16 2011
(r7200)
+++ branches/1.5/turbogears/controllers.py Tue Jan 11 09:22:48 2011
(r7201)
@@ -434,10 +434,11 @@
else:
assert isinstance(output,
- (basestring, dict, list, types.GeneratorType)), (
- "Method %s.%s() returned unexpected output. Output should "
- "be of type basestring, dict, list or generator." % (
- args[0].__class__.__name__, func.__name__))
+ (basestring, dict, list, types.GeneratorType)) or (
+ hasattr(output, '__iter__') and hasattr(output, 'next')), (
+ "Method %s.%s() returned unexpected output."
+ " Output should be of type basestring, dict, list or generator."
+ % (args[0].__class__.__name__, func.__name__))
if isinstance(output, dict):
template = output.pop("tg_template", template)