[ http://issues.apache.org/jira/browse/MODPYTHON-15?page=all ]
Nicolas Lehuen updated MODPYTHON-15: ------------------------------------ Fix Version: 3.3 (was: 3.2) Description: Suppose this function in a published module : def index(req) req.content_type = 'text/plain' yield '1\n' yield '2\n' yield '3\n' yield '4\n' When published, this module should return a text content with '1\n2\n3\n4\n'. This could also be useful with a file() object, since they are iterable ; this would provide another way to send a file, only slightly less performing than the send_file() method. Handy when you want to filter a file : def filter(req,filename): f = open(filename,'r') for line in f: yield re.sub('foo','bar',line) was: Suppose this function in a published module : def index(req) req.content_type = 'text/plain' yield '1\n' yield '2\n' yield '3\n' yield '4\n' When published, this module should return a text content with '1\n2\n3\n4\n'. This could also be useful with a file() object, since they are iterable ; this would provide another way to send a file, only slightly less performing than the send_file() method. Handy when you want to filter a file : def filter(req,filename): f = open(filename,'r') for line in f: yield re.sub('foo','bar',line) Environment: It's a little bit more complicated than expected, because it breaks some RPC / JSON code (which rely on str() being called on tuples or lists)... Plus we should implement chunked encoding when returning content produced by iterators, since we can't set the Content-Length header upfront. > Publisher : iterable return values should be corretly published > --------------------------------------------------------------- > > Key: MODPYTHON-15 > URL: http://issues.apache.org/jira/browse/MODPYTHON-15 > Project: mod_python > Type: Improvement > Versions: 3.1.3 > Reporter: Nicolas Lehuen > Assignee: Nicolas Lehuen > Priority: Minor > Fix For: 3.3 > > Suppose this function in a published module : > def index(req) > req.content_type = 'text/plain' > yield '1\n' > yield '2\n' > yield '3\n' > yield '4\n' > When published, this module should return a text content with '1\n2\n3\n4\n'. > This could also be useful with a file() object, since they are iterable ; > this would provide another way to send a file, only slightly less performing > than the send_file() method. Handy when you want to filter a file : > def filter(req,filename): > f = open(filename,'r') > for line in f: > yield re.sub('foo','bar',line) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira