Ticket #1743 (closed defect: wontfix)

Opened 4 years ago

Last modified 2 years ago

[patch] wsgi must return strings

Reported by: pythy Assigned to: pythy
Priority: normal Milestone:
Component: Nevow Severity: normal
Keywords: nevow wsgi Cc:
Estimated Completion (YYYY/MM/DD): Branch:
Author:

Description

nevow.wsgi returns non-strings in WSGI requests. It tested with wsgiref basic WSGI-server and nevow's example app. Patch and test-code are attached.

Attachments

nevow_wsgi.py (1.5 kB) - added by pythy on 11/14/06 23:25:03.
wsgiref+nevow example
nevow_wsgi.patch (1.4 kB) - added by pythy on 11/14/06 23:26:04.
patch for nevow.wsgi
test_wsgi.py (1.8 kB) - added by pythy on 11/30/06 04:46:41.
unittest for nevow.wsgi, which failes if bug #1743 not fixed
test_wsgi-2.py (3.2 kB) - added by pythy on 12/03/06 21:48:56.
Unit-test for ticket #1743, without wsgiref dependence

Change History

11/14/06 23:25:03 changed by pythy

  • attachment nevow_wsgi.py added.

wsgiref+nevow example

11/14/06 23:26:04 changed by pythy

  • attachment nevow_wsgi.patch added.

patch for nevow.wsgi

11/15/06 09:59:04 changed by exarkun

  • owner changed from exarkun to pythy.

What does it return if you don't have str()?

Could you turn the example into a set of unit tests?

11/15/06 22:17:03 changed by pythy

I'm newbie in Nevow, so unit-tests are too hard for me.

Step-by-step reproduction is:

1. Write basic WSGI-app (taken from examples/wsgi/test-cgi.py

2. Put this app to any WSGI-server, for ex., from wsgiref

3. Open in browser, got traceback:

Traceback (most recent call last):
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 93, in run
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 133, in finish_response
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 105, in application
    result = request.process()
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 197, in process
    pageContext = self.site.getPageContextForRequestContext(requestContext)
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 42, in getPageContextForRequestContext
    ctx.tag, path, pageContext)
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 62, in handleSegment
    newres = inevow.IResource(newres, persist=True)
TypeError: __call__() got an unexpected keyword argument 'persist'

4. Remove presist=True in nevow.wsgi in line 62

5. Restart app, open it in browser, got traceback:

Traceback (most recent call last):
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 93, in run
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 133, in finish_response
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 105, in application
    result = request.process()
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 199, in process
    return self.gotPageContext(pageContext)
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 215, in gotPageContext
    html = ''.join(list(html))
  File "/usr/local/lib/python2.4/site-packages/nevow/flat/ten.py", line 115, in iterflatten
    writer(tags.raw(''.join(straccum)))
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 377, in write
    self._write(data)
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 209, in write
AssertionError: write() argument must be string

6. Put str() in write(data), restart app, open it in browser, click to link "a", got traceback:

Traceback (most recent call last):
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 93, in run
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 133, in finish_response
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 108, in application
    request.write('') # send headers now
  File "/usr/local/lib/python2.4/site-packages/nevow/wsgi.py", line 373, in write
    self._write = self.start_response(
  File "/usr/local/egg/lib/python2.4/site-packages/wsgiref-0.1.2-py2.4.egg/wsgiref/handlers.py", line 185, in start_response
AssertionError: Header values must be strings

7. Add header-sanitizing (sHeaders = [(str(k), str(v)) for k,v in self.outgoingHeaders]), restart app, play with it, all clean.

11/30/06 04:46:41 changed by pythy

  • attachment test_wsgi.py added.

unittest for nevow.wsgi, which failes if bug #1743 not fixed

11/30/06 04:49:07 changed by pythy

Unit-test is ready

12/03/06 21:48:56 changed by pythy

  • attachment test_wsgi-2.py added.

Unit-test for ticket #1743, without wsgiref dependence

07/15/08 13:11:06 changed by exarkun

  • status changed from new to closed.
  • resolution set to wontfix.
  • branch changed.
  • author changed.

nevow.wsgi is deprecated and will be removed at some point. twisted.web should be used for wsgi instead (once twisted.web2.wsgi is ported).

jethro@divmod.org