Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.write not json serializing #5

Open
defrex opened this issue Sep 8, 2010 · 6 comments
Open

self.write not json serializing #5

defrex opened this issue Sep 8, 2010 · 6 comments

Comments

@defrex
Copy link
Owner

defrex commented Sep 8, 2010

self.write (in a handler), should take care of json serialization. In the case of 9a85201 however, it didn't work and I had to add it myself. It's not a huge deal for now.

@defrex
Copy link
Owner Author

defrex commented Sep 8, 2010

Oh, and the traceback:
[E 100908 12:39:14 web:813] Uncaught exception GET /categories/ (127.0.0.1)
HTTPRequest(protocol='http', host='127.0.0.1:8080', method='GET', uri='/categories/', version='HTTP/1.1', remote_ip='127.0.0.1', remote_ip='127.0.0.1', body='', headers={'Accept-Language': 'en-US,en;q=0.8', 'Accept-Encoding': 'gzip,deflate,sdch', 'Host': '127.0.0.1:8080', 'Accept': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5', 'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.53 Safari/534.3', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,_;q=0.3', 'Connection': 'keep-alive', 'Cookie': 'csrftoken=bf336314c7a145e9c40283a107a51110', 'Cache-Control': 'max-age=0'})
Traceback (most recent call last):
File "/home/defrex/code/connectsy/server/lib/tornado/tornado/web.py", line 770, in _execute
getattr(self, self.request.method.lower())(_args, **kwargs)
File "/home/defrex/code/connectsy/server/api/categories/handlers.py", line 62, in get
'name': 'Games & Activites\n'}
File "/home/defrex/code/connectsy/server/lib/tornado/tornado/web.py", line 350, in write
chunk = _utf8(chunk)
File "/home/defrex/code/connectsy/server/lib/tornado/tornado/web.py", line 1461, in _utf8
assert isinstance(s, str)
AssertionError

@defrex
Copy link
Owner Author

defrex commented Sep 8, 2010

Heh, I totally forgot about redmine. I'll switch this to there now...

@shz
Copy link
Contributor

shz commented Sep 8, 2010

Revert that change! self.write has to handle non-JSON, because we don't always use it in the responses (as an example, /token/).

You want self.output instead.

@defrex
Copy link
Owner Author

defrex commented Sep 8, 2010

oh, I see. There is code in there that's sending dics to self.write for some reason.

@shz
Copy link
Contributor

shz commented Sep 8, 2010

Hm, I suppose that's a bug then.

I may change dict.write in the future so that it automatically converts dicts to JSON, and writes a string through otherwise. In the meantime though, they're separate functions.

@defrex
Copy link
Owner Author

defrex commented Sep 8, 2010

My guess is that right now it will convert a dict but not a list, since that's what I'm passing through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants