From: Fredrik Tolf Date: Sun, 2 Mar 2014 04:12:14 +0000 (+0100) Subject: Fixed stringwrap iteration bug. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=62113fc6dabec39f06a1f86f4ea6f73975f0acdf;p=wrw.git Fixed stringwrap iteration bug. --- diff --git a/wrw/util.py b/wrw/util.py index 8eed5a0..7c42eae 100644 --- a/wrw/util.py +++ b/wrw/util.py @@ -7,16 +7,6 @@ def wsgiwrap(callable): wrapper.__wrapped__ = callable return wrapper -def stringwrap(charset): - def dec(callable): - def wrapper(*args, **kwargs): - bk = callable(*args, **kwargs) - for string in bk: - yield string.encode(charset) - wrapper.__wrapped__ = callable - return wrapper - return dec - def formparams(callable): spec = inspect.getargspec(callable) def wrapper(req): @@ -120,6 +110,16 @@ def pregen(callable): wrapper.__wrapped__ = callable return wrapper +def stringwrap(charset): + def dec(callable): + @pregen + def wrapper(*args, **kwargs): + for string in callable(*args, **kwargs): + yield string.encode(charset) + wrapper.__wrapped__ = callable + return wrapper + return dec + class sessiondata(object): @classmethod def get(cls, req, create=True):