Source code for ramverk.wsgi

from werkzeug.utils import cached_property
from werkzeug.wsgi  import SharedDataMiddleware, responder


[docs]def middleware_mixin(mixin): """Decorate a class as a middleware mixin. A special `pipeline` method is passed the WSGI application to wrap, and the pipeline is transformed into a cooperative :meth:`__call__` override.""" pipeline = mixin.pipeline del mixin.pipeline @cached_property def _middlewares(self): return {} @responder def __call__(self, environ, start_response): app = super(mixin, self).__call__ if mixin not in self._middlewares: self._middlewares[mixin] = pipeline(self, app) return self._middlewares[mixin] mixin._middlewares = _middlewares mixin.__call__ = __call__ return mixin
@middleware_mixin
[docs]class SharedDataMiddlewareMixin(object): """Serve static files for an application.""" @cached_property
[docs] def shared_data(self): """Mapping of public paths to files/directories or tuples of ``(module, directory)``. The default serves up the `static` directory under the application module on ``/static``. See :class:`~werkzeug.wsgi.SharedDataMiddleware` for more information.""" return {'/static': (self.module, 'static')}
def pipeline(self, app): return SharedDataMiddleware(app, self.shared_data)
@middleware_mixin class EasterEggMiddlewareMixin(object): #pragma: no cover def pipeline(self, app): from werkzeug._internal import _easteregg return _easteregg(app)

Project Versions