Roundup Tracker - Issues

Issue 2550800

classification
jinja2 template engine occurs the TypeError in twisted web + wsgi.
Type: crash Severity: major
Components: Web interface Versions: devel
process
Status: closed fixed
:
: : ber, pcaulagi, spikeekips
Priority: : patch

Created on 2013-03-15 08:48 by spikeekips, last changed 2013-03-22 05:01 by pcaulagi.

Files
File name Uploaded Description Edit Remove
roundup-jinja2.patch spikeekips, 2013-03-15 08:48
Messages
msg4822 Author: [hidden] (spikeekips) Date: 2013-03-15 08:48
I was running the roundup using wsgi in twisted web(latest 12.3.0). When I created new project with jinja2 template engine, I got this exceptions.

	Traceback (most recent call last):
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/application/app.py", line 402, in startReactor
	    self.config, oldstdout, oldstderr, self.profiler, reactor)
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/application/app.py", line 323, in 
runReactorWithLogging
	    reactor.run()
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/internet/base.py", line 1173, in run
	    self.mainLoop()
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/internet/base.py", line 1182, in mainLoop
	    self.runUntilCurrent()
	--- <exception caught here> ---
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/internet/base.py", line 778, in runUntilCurrent
	    f(*a, **kw)
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/web/wsgi.py", line 274, in wsgiWrite
	    self.request.write(bytes)
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/web/server.py", line 220, in write
	    http.Request.write(self, data)
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/web/http.py", line 980, in write
	    self.transport.writeSequence(toChunk(data))
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/internet/_newtls.py", line 204, in writeSequence
	    FileDescriptor.writeSequence(self, iovec)
	  File "/Volumes/Userland/Users/spikeekips/workspace/roundup/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.8-x86_64.egg/twisted/internet/abstract.py", line 371, in writeSequence
	    raise TypeError("Data must not be unicode")
	exceptions.TypeError: Data must not be unicode

This exception was caused, `Jinja2ProxyPageTemplate` does return the valid `unicode` instead of `str`, so I patched roundup like this.

    diff -x '.*.swp' -x '*.txt' -uNr a/roundup/cgi/engine_jinja2.py b/roundup/cgi/engine_jinja2.py
    --- a/roundup/cgi/engine_jinja2.py        2013-03-05 23:56:45.000000000 +0900
    +++ b/roundup/cgi/engine_jinja2.py        2013-03-15 17:35:57.000000000 +0900
    @@ -75,7 +75,7 @@
             # [ ] limit the information passed to the minimal necessary set
             c = context(client, self, classname, request)
             c.update({'options': options})
    -        return self._tpl.render(c)
    +        return self._tpl.render(c).encode(client.charset, )

         def __getitem__(self, name):
             # [ ] figure out what are these for


Thanks.
msg4823 Author: [hidden] (pcaulagi) Date: 2013-03-15 10:00
Thanks!  We were discussing this on the devel list - 
https://lists.sourceforge.net/lists/listinfo/roundup-devel.

I have patched your changes - 
http://roundup.hg.sourceforge.net/hgweb/roundup/roundup/rev/cf22ac054c08
msg4827 Author: [hidden] (ber) Date: 2013-03-21 21:27
Pradip, you should be able to close issues that others have created now.
Can you test it with this one (as it seems to be resolved from what I've 
seen.)
msg4828 Author: [hidden] (pcaulagi) Date: 2013-03-22 05:01
Thanks Bernhard!
History
Date User Action Args
2013-03-22 05:01:01pcaulagisetmessages: + msg4828
2013-03-22 04:59:05pcaulagisetstatus: new -> closed
resolution: fixed
2013-03-21 21:27:40bersetnosy: + ber
messages: + msg4827
2013-03-15 10:00:53pcaulagisetnosy: + pcaulagi
messages: + msg4823
2013-03-15 08:48:22spikeekipscreate