Skip to content

Commit

Permalink
:fix: dependencies and response content
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdd committed Jun 5, 2016
1 parent f029aff commit 8615fba
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = u'0.3'
version = u'0.4'
# The full version, including alpha/beta/rc tags.
release = u'0.3'
release = u'0.4'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion link/wsgi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

__version__ = '0.3'
__version__ = '0.4'

CONF_BASE_PATH = 'link/wsgi'
19 changes: 13 additions & 6 deletions link/wsgi/resp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from link.wsgi import CONF_BASE_PATH

from httplib import responses as httpresponses
from six import string_types
from six.moves.http_client import responses as httpresponses
from six import string_types, binary_type
import json


Expand Down Expand Up @@ -56,16 +56,23 @@ def content(self, value):
if value is None:
value = ''

elif not isinstance(value, string_types) and not isiterable(value):
elif not isinstance(value, string_types):
try:
value = json.dumps(value)

except ValueError:
value = str(value)

value = value.splitlines()
if not isiterable(value, exclude=string_types):
value = [
'{0}\n'.format(v)
for v in value.splitlines()
]

self._content = value
self._content = [
v.encode('utf-8')
for v in value
]
self['Content-Length'] = sum([len(c) for c in self._content])

@property
Expand All @@ -84,7 +91,7 @@ def status(self, value):

@property
def headers(self):
return list(self._headers.items())
return [(k, str(v)) for k, v in self._headers.items()]

def __getitem__(self, item):
"""
Expand Down
5 changes: 3 additions & 2 deletions link/wsgi/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from inspect import isclass
from re import match
import traceback
import logging


Expand Down Expand Up @@ -167,10 +168,10 @@ def dispatch(self, req, resp):
if middleware.after(req, resp, handler):
break

except Exception as err:
except Exception:
# if any error happens, return a 500 internal error
resp.status = 500
resp.content = str(err)
resp.content = traceback.format_exc()

else:
# if the method was not configured for the route, return a
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
b3j0f.conf>=0.3.13
b3j0f.conf>=0.3.16
six>=1.10.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
AUTHOR_EMAIL = 'david.jose.delassus@gmail.com'
LICENSE = 'MIT'
REQUIREMENTS = [
'b3j0f.conf==0.3.13',
'b3j0f.conf==0.3.16',
'six==1.10.0'
]

Expand Down

0 comments on commit 8615fba

Please sign in to comment.