Issue Details (XML | Word | Printable)

Key: MODPYTHON-15
Type: Improvement Improvement
Status: Reopened Reopened
Priority: Minor Minor
Assignee: Nicolas Lehuen
Reporter: Nicolas Lehuen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Publisher : iterable return values should be corretly published

Created: 29/Jan/05 09:14 PM   Updated: 13/Aug/06 07:49 AM
Return to search
Component/s: None
Affects Version/s: 3.1.3
Fix Version/s: None

Time Tracking:
Not Specified


 Description  « Hide
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)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #201794 Sat Jun 25 22:18:48 UTC 2005 nlehuen New publishing code for the publisher.

- Solves MODPYTHON-15 "iterable return values should be corretly published"
- Also takes care of selecting a proper encoding when the returned objects are Unicode strings. It parses the Content-Type header to select the encoding, or chooses UTF-8 if no encoding is given.
- Returning nothing is now allowed. Nothing is returned to the client.

Unit tests have been made to ensure that there was no regression.
Files Changed
MODIFY /httpd/mod_python/trunk/test/htdocs/tests.py
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/publisher.py
MODIFY /httpd/mod_python/trunk/test/test.py
MODIFY /httpd/mod_python/trunk/src/include/mpversion.h

Repository Revision Date User Message
ASF #355725 Sat Dec 10 09:16:06 UTC 2005 nlehuen Reverted MODPYTHON-15 to fix MODPYTHON-97 ; we'll get back to this in mod_python 3.3.
Files Changed
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/publisher.py
MODIFY /httpd/mod_python/trunk/test/test.py
MODIFY /httpd/mod_python/trunk/Doc/appendixc.tex