Beispiel #1
0
from fugue.interceptors.basic import Interceptor
from fugue.interceptors.nevow import _enter_nevow, _error_nevow, _leave_nevow
from fugue.util import namespace

_ns = namespace(__name__)
TWISTED_REQUEST = _ns('request')


def _finish_request(context):
    """
    Calls ``finish`` on the Twisted request.
    """
    context.get(TWISTED_REQUEST).finish()
    return context


_enter_twisted = _enter_nevow(TWISTED_REQUEST)

_leave_twisted = _leave_nevow(TWISTED_REQUEST, finish=_finish_request)

_error_twisted = _error_nevow(TWISTED_REQUEST, finish=_finish_request)


def twisted():
    """
    An interceptor that converts a Twisted request into a standard request map
    on enter and writes the response back to Twisted on leave. The Twisted
    request is expected to exist at the context key `TWISTED_REQUEST`.
    """
    return Interceptor(name='twisted',
                       enter=_enter_twisted,
Beispiel #2
0
from fugue.util import namespace


_ns = namespace('fugue')
REQUEST = _ns('request')
RESPONSE = _ns('response')
ROUTE = _ns('route')
EXECUTION_ID = _ns('execution_id')
QUEUE = _ns('queue')
STACK = _ns('stack')
ERROR = _ns('error')
SUPPRESSED = _ns('suppressed')
TERMINATORS = _ns('terminators')
Beispiel #3
0
 def test_namespace(self):
     """
     Create a function that prefixes names.
     """
     ns = namespace(__name__)
     self.assertThat(ns('foo'), Equals(__name__ + '/foo'))