# Path: nudge/json.py
# def json_encode(o):
#     return _encoder.encode(o)
# 
# Path: nudge/error.py
# DEFAULT_ERROR_CODE = 500
# DEFAULT_ERROR_CONTENT_TYPE = "application/json; charset=UTF-8"
# DEFAULT_ERROR_CONTENT = '{"message": "%s", "code": %i}' % (
#     "Internal Server Error",
#     DEFAULT_ERROR_CODE,
# )
# class JsonErrorHandler(object):
# class HTTPError(Exception):
# class SecurityException(Exception):
#     def __call__(self, exp, req=None, log_assert=True):
# def handle_exception(exp, exp_handlers, default_handler=None):
#     def __init__(self, status_code, message=None):


import base64
import types
from cStringIO import StringIO
from nudge.json import json_encode
from nudge.error import HTTPException, SecurityException
class InsecureJson(object):
    ''' See the notes above for Json. This does not check returned types. '''
    def __call__(self, result):
        if result == None:
            raise HTTPException(404)
        return Result(
            content=json_encode(result),
            content_type='application/json; charset=UTF-8',
            http_status=200,
        )

REDIRECT_TEMPLATE = """
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>Moved</TITLE>
</HEAD>
<BODY>
<H2>Moved</H2>
<A HREF="%s">The requested URL has moved here.</A>
</BODY>
</HTML>"""

class Redirect(object):
    def __init__(self, http_status=302):
        self.http_status = http_status

    def redirect(self, uri, http_status=302, headers=None):
        if headers:
            headers['Location'] = uri

# Path: nudge/json.py
# def json_encode(o):
#     return _encoder.encode(o)
# 
# Path: nudge/error.py
# DEFAULT_ERROR_CODE = 500
# DEFAULT_ERROR_CONTENT_TYPE = "application/json; charset=UTF-8"
# DEFAULT_ERROR_CONTENT = '{"message": "%s", "code": %i}' % (
#     "Internal Server Error",
#     DEFAULT_ERROR_CODE,
# )
# class JsonErrorHandler(object):
# class HTTPError(Exception):
# class SecurityException(Exception):
#     def __call__(self, exp, req=None, log_assert=True):
# def handle_exception(exp, exp_handlers, default_handler=None):
#     def __init__(self, status_code, message=None):


# Path: nudge/renderer.py
import base64
import types
from cStringIO import StringIO
from nudge.json import json_encode
from nudge.error import HTTPException, SecurityException

class InsecureJson(object):
    ''' See the notes above for Json. This does not check returned types. '''
    def __call__(self, result):
        if result == None:
            raise HTTPException(404)
        return Result(
            content=json_encode(result),
            content_type='application/json; charset=UTF-8',
            http_status=200,
        )

REDIRECT_TEMPLATE = """
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>Moved</TITLE>
</HEAD>
<BODY>
<H2>Moved</H2>
<A HREF="%s">The requested URL has moved here.</A>
</BODY>
</HTML>"""

class Redirect(object):
    def __init__(self, http_status=302):
        self.http_status = http_status

    def redirect(self, uri, http_status=302, headers=None):
        if headers:
            headers['Location'] = uri

        else: