Skip to content

Commit

Permalink
Rename toolbar_middleware_factory to just middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed May 26, 2015
1 parent 69bdb74 commit 2dd9052
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGES
=======

0.0.2 (2015-05-26)
^^^^^^^^^^^^^^^^^^

* Redesign UI look-and-feel

* Rename `toolbar_middleware_factory` to just `middleware`.


0.0.1 (2015-05-18)
^^^^^^^^^^^^^^^^^^
Expand Down
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ your ``aiohttp.web.Application``, and call ``aiohttp_debugtoolbar.setup``
import aiohttp_debugtoolbar
app = web.Application(loop=loop,
middlewares=[aiohttp_debugtoolbar.toolbar_middleware_factory])
middlewares=[aiohttp_debugtoolbar.middleware])
aiohttp_debugtoolbar.setup(app)
Expand Down Expand Up @@ -78,8 +78,8 @@ Full Example
@asyncio.coroutine
def init(loop):
# add aiohttp_debugtoolbar middleware to you application
app = web.Application(loop=loop, middlewares=[aiohttp_debugtoolbar
.toolbar_middleware_factory])
app = web.Application(loop=loop,
middlewares=[aiohttp_debugtoolbar.middleware])
# install aiohttp_debugtoolbar
aiohttp_debugtoolbar.setup(app)
Expand All @@ -104,7 +104,8 @@ Full Example
lookup.put_string('index.html', template)
app.router.add_route('GET', '/', basic_handler, name='index')
app.router.add_route('GET', '/exc', exception_handler, name='exc_example')
app.router.add_route('GET', '/exc',
exception_handler, name='exc_example')
handler = app.make_handler()
srv = yield from loop.create_server(handler, '127.0.0.1', 9000)
Expand Down
4 changes: 2 additions & 2 deletions aiohttp_debugtoolbar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__version__ = '0.0.1'

from .middlewares import toolbar_middleware_factory
from .middlewares import toolbar_middleware_factory, middleware
from .main import setup, APP_KEY

__all__ = ['setup', 'toolbar_middleware_factory', 'APP_KEY']
__all__ = ['setup', 'middleware', 'toolbar_middleware_factory', 'APP_KEY']
9 changes: 7 additions & 2 deletions aiohttp_debugtoolbar/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from .tbtools.tbtools import get_traceback
from .utils import addr_in, REDIRECT_CODES, APP_KEY, TEMPLATE_KEY, hexlify

__all__ = ['toolbar_middleware_factory']
__all__ = ['toolbar_middleware_factory', 'middleware']
HTML_TYPES = ('text/html', 'application/xhtml+xml')


@asyncio.coroutine
def toolbar_middleware_factory(app, handler):
def middleware(app, handler):

if APP_KEY not in app:
raise RuntimeError('Please setup debug toolbar with '
Expand Down Expand Up @@ -143,6 +143,11 @@ def toolbar_middleware(request):

return toolbar_middleware


# Deprecated, will drop it in 0.3+
toolbar_middleware_factory = middleware


toolbar_html_template = """\
<script type="text/javascript">
var fileref=document.createElement("link")
Expand Down
4 changes: 2 additions & 2 deletions demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import aiohttp_jinja2
import aiohttp_mako
from aiohttp import web
from aiohttp_debugtoolbar import toolbar_middleware_factory


logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -81,7 +80,8 @@ def test_jinja2_exc(request):

@asyncio.coroutine
def init(loop):
app = web.Application(loop=loop, middlewares=[toolbar_middleware_factory])
app = web.Application(loop=loop,
middlewares=[aiohttp_debugtoolbar.middleware])

aiohttp_debugtoolbar.setup(app, intercept_exc='debug')

Expand Down

0 comments on commit 2dd9052

Please sign in to comment.