aiohttp_jinja2-0.8.0/0000775000175000017500000000000012741211422015204 5ustar andrewandrew00000000000000aiohttp_jinja2-0.8.0/PKG-INFO0000664000175000017500000001356612741211422016314 0ustar andrewandrew00000000000000Metadata-Version: 1.1 Name: aiohttp_jinja2 Version: 0.8.0 Summary: jinja2 template renderer for aiohttp.web (http server for asyncio) Home-page: https://github.com/aio-libs/aiohttp_jinja2/ Author: Andrew Svetlov Author-email: andrew.svetlov@gmail.com License: Apache 2 Description: aiohttp_jinja2 ============== jinja2_ template renderer for `aiohttp.web`__. .. _jinja2: http://jinja.pocoo.org .. _aiohttp_web: https://aiohttp.readthedocs.io/en/latest/web.html __ aiohttp_web_ Installation ------------ Install from PyPI:: pip install aiohttp-jinja2 Developing ---------- Install requirement and launch tests:: pip install -r requirements-dev.txt py.test tests Usage ----- Before template rendering you have to setup *jinja2 environment* first:: app = web.Application() aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('/path/to/templates/folder')) After that you may to use template engine in your *web-handlers*. The most convenient way is to decorate a *web-handler*. Using the function based web handlers:: @aiohttp_jinja2.template('tmpl.jinja2') def handler(request): return {'name': 'Andrew', 'surname': 'Svetlov'} Or for `Class Based Views `:: class Handler(web.View): @aiohttp_jinja2.template('tmpl.jinja2') async def get(self): return {'name': 'Andrew', 'surname': 'Svetlov'} On handler call the ``aiohttp_jinja2.template`` decorator will pass returned dictionary ``{'name': 'Andrew', 'surname': 'Svetlov'}`` into template named ``tmpl.jinja2`` for getting resulting HTML text. If you need more complex processing (set response headers for example) you may call ``render_template`` function. Using a function based web handler:: async def handler(request): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', request, context) response.headers['Content-Language'] = 'ru' return response Or, again, a class based view:: class Handler(web.View): async def get(self): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', self.request, context) response.headers['Content-Language'] = 'ru' return response License ------- ``aiohttp_jinja2`` is offered under the Apache 2 license. CHANGES ======= 0.8.0 (2016-07-12) ------------------ - Add ability to render template without context #28 0.7.0 (2015-12-30) ------------------ - Add ability to decorate class based views (available in aiohttp 0.20) #18 - Upgrade aiohttp requirement to version 0.20.0+ 0.6.2 (2015-11-22) ------------------ - Make app_key parameter from render_string coroutine optional 0.6.0 (2015-10-29) ------------------ - Fix a bug in middleware (missed coroutine decorator) #16 - Drop Python 3.3 support (switched to aiohttp version v0.18.0) - Simplify context processors initialization by adding parameter to `setup()` 0.5.0 (2015-07-09) ------------------ - Introduce context processors #14 - Bypass StreamResponse #15 0.4.3 (2015-06-01) ------------------ - Fix distribution building: add manifest file 0.4.2 (2015-05-21) ------------------ - Make HTTPInternalServerError exceptions more verbose on console output 0.4.1 (2015-04-05) ------------------ - Documentation update 0.4.0 (2015-04-02) ------------------ - Add `render_string` method 0.3.1 (2015-04-01) ------------------ - Don't allow non-mapping context - Fix tiny documentation issues - Change the library logo 0.3.0 (2015-03-15) ------------------ - Documentation release 0.2.1 (2015-02-15) ------------------ - Fix `render_template` function 0.2.0 (2015-02-05) ------------------ - Migrate to aiohttp 0.14 - Add `status` parameter to template decorator - Drop optional `response` parameter 0.1.0 (2015-01-08) ------------------ - Initial release Platform: UNKNOWN Classifier: License :: OSI Approved :: Apache Software License Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Internet :: WWW/HTTP aiohttp_jinja2-0.8.0/tests/0000775000175000017500000000000012741211422016346 5ustar andrewandrew00000000000000aiohttp_jinja2-0.8.0/tests/test_simple_renderer.py0000664000175000017500000002124012741155016023143 0ustar andrewandrew00000000000000import asyncio import socket import re import unittest import aiohttp from aiohttp import web from aiohttp.multidict import CIMultiDict import aiohttp_jinja2 import jinja2 from unittest import mock class TestSimple(unittest.TestCase): def setUp(self): self.loop = asyncio.new_event_loop() asyncio.set_event_loop(None) def tearDown(self): self.loop.close() def find_unused_port(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('127.0.0.1', 0)) port = s.getsockname()[1] s.close() return port def make_request(self, app, method, path): headers = CIMultiDict() message = aiohttp.RawRequestMessage(method, path, aiohttp.HttpVersion(1, 1), headers, [], False, False) self.payload = mock.Mock() self.transport = mock.Mock() self.writer = mock.Mock() req = web.Request(app, message, self.payload, self.transport, self.writer, 15) return req @asyncio.coroutine def _create_app_with_template(self, template, func): """ Helper method that creates application with single handler that process request to root '/' with any http method and returns response for rendered `template` """ app = web.Application(loop=self.loop) aiohttp_jinja2.setup(app, loader=jinja2.DictLoader({ 'tmpl.jinja2': template })) app.router.add_route('*', '/', func) port = self.find_unused_port() handler = app.make_handler() srv = yield from self.loop.create_server( handler, '127.0.0.1', port) url = 'http://127.0.0.1:{}/'.format(port) resp = yield from aiohttp.request('GET', url, loop=self.loop) yield from handler.finish_connections() srv.close() self.addCleanup(srv.close) return resp def test_func(self): @aiohttp_jinja2.template('tmpl.jinja2') @asyncio.coroutine def func(request): return {'head': 'HEAD', 'text': 'text'} @asyncio.coroutine def go(): template = '

{{head}}

{{text}}' resp = yield from self._create_app_with_template(template, func) self.assertEqual(200, resp.status) txt = yield from resp.text() self.assertEqual('

HEAD

text', txt) self.loop.run_until_complete(go()) def test_render_class_based_view(self): class MyView(web.View): @aiohttp_jinja2.template('tmpl.jinja2') @asyncio.coroutine def get(self): return {'head': 'HEAD', 'text': 'text'} @asyncio.coroutine def go(): template = '

{{head}}

{{text}}' resp = yield from self._create_app_with_template(template, MyView) self.assertEqual(200, resp.status) txt = yield from resp.text() self.assertEqual('

HEAD

text', txt) self.loop.run_until_complete(go()) def test_meth(self): class Handler: @aiohttp_jinja2.template('tmpl.jinja2') @asyncio.coroutine def meth(self, request): return {'head': 'HEAD', 'text': 'text'} @asyncio.coroutine def go(): template = '

{{head}}

{{text}}' handler = Handler() resp = yield from self._create_app_with_template(template, handler.meth) self.assertEqual(200, resp.status) txt = yield from resp.text() self.assertEqual('

HEAD

text', txt) self.loop.run_until_complete(go()) def test_convert_func_to_coroutine(self): @aiohttp_jinja2.template('tmpl.jinja2') def func(request): return {'head': 'HEAD', 'text': 'text'} @asyncio.coroutine def go(): template = '

{{head}}

{{text}}' resp = yield from self._create_app_with_template(template, func) txt = yield from resp.text() self.assertEqual('

HEAD

text', txt) self.loop.run_until_complete(go()) def test_render_not_initialized(self): @asyncio.coroutine def func(request): return aiohttp_jinja2.render_template('template', request, {}) @asyncio.coroutine def go(): app = web.Application(loop=self.loop) app.router.add_route('GET', '/', func) req = self.make_request(app, 'GET', '/') msg = "Template engine is not initialized, " \ "call aiohttp_jinja2.setup(..., app_key={}" \ ") first".format(aiohttp_jinja2.APP_KEY) with self.assertRaisesRegex(web.HTTPInternalServerError, re.escape(msg)) as ctx: yield from func(req) self.assertEqual(msg, ctx.exception.text) self.loop.run_until_complete(go()) def test_set_status(self): @aiohttp_jinja2.template('tmpl.jinja2', status=201) def func(request): return {'head': 'HEAD', 'text': 'text'} @asyncio.coroutine def go(): template = '

{{head}}

{{text}}' resp = yield from self._create_app_with_template(template, func) self.assertEqual(201, resp.status) txt = yield from resp.text() self.assertEqual('

HEAD

text', txt) self.loop.run_until_complete(go()) def test_render_template(self): @asyncio.coroutine def func(request): return aiohttp_jinja2.render_template( 'tmpl.jinja2', request, {'head': 'HEAD', 'text': 'text'}) @asyncio.coroutine def go(): template = '

{{head}}

{{text}}' resp = yield from self._create_app_with_template(template, func) self.assertEqual(200, resp.status) txt = yield from resp.text() self.assertEqual('

HEAD

text', txt) self.loop.run_until_complete(go()) def test_template_not_found(self): @asyncio.coroutine def func(request): return aiohttp_jinja2.render_template('template', request, {}) @asyncio.coroutine def go(): app = web.Application(loop=self.loop) aiohttp_jinja2.setup(app, loader=jinja2.DictLoader({})) app.router.add_route('GET', '/', func) req = self.make_request(app, 'GET', '/') with self.assertRaises(web.HTTPInternalServerError) as ctx: yield from func(req) self.assertEqual("Template 'template' not found", ctx.exception.text) self.loop.run_until_complete(go()) def test_render_not_mapping(self): @aiohttp_jinja2.template('tmpl.jinja2') @asyncio.coroutine def func(request): return 123 @asyncio.coroutine def go(): app = web.Application(loop=self.loop) aiohttp_jinja2.setup(app, loader=jinja2.DictLoader( {'tmpl.jinja2': 'tmpl'})) app.router.add_route('GET', '/', func) req = self.make_request(app, 'GET', '/') msg = "context should be mapping, not " with self.assertRaisesRegex(web.HTTPInternalServerError, re.escape(msg)) as ctx: yield from func(req) self.assertEqual(msg, ctx.exception.text) self.loop.run_until_complete(go()) def test_render_without_context(self): @aiohttp_jinja2.template('tmpl.jinja2') def func(request): pass @asyncio.coroutine def go(): template = '

{{text}}

' resp = yield from self._create_app_with_template(template, func) self.assertEqual(200, resp.status) txt = yield from resp.text() self.assertEqual('

', txt) self.loop.run_until_complete(go()) aiohttp_jinja2-0.8.0/tests/test_jinja_globals.py0000664000175000017500000000206712704762176022602 0ustar andrewandrew00000000000000import aiohttp import aiohttp_jinja2 import asyncio import jinja2 import pytest from aiohttp import web def test_get_env(loop): app = web.Application(loop=loop) aiohttp_jinja2.setup(app, loader=jinja2.DictLoader( {'tmpl.jinja2': "tmpl"})) env = aiohttp_jinja2.get_env(app) assert isinstance(env, jinja2.Environment) assert env is aiohttp_jinja2.get_env(app) @pytest.mark.run_loop def test_url(create_server, loop): @aiohttp_jinja2.template('tmpl.jinja2') @asyncio.coroutine def index(request): return {} @asyncio.coroutine def other(request): return app, url = yield from create_server() aiohttp_jinja2.setup(app, loader=jinja2.DictLoader( {'tmpl.jinja2': "{{ url('other', parts={'name': 'John_Doe'})}}"})) app.router.add_route('GET', '/', index) app.router.add_route('GET', '/user/{name}', other, name='other') resp = yield from aiohttp.request('GET', url, loop=loop) assert 200 == resp.status txt = yield from resp.text() assert '/user/John_Doe' == txt aiohttp_jinja2-0.8.0/tests/conftest.py0000664000175000017500000001563412704762176020576 0ustar andrewandrew00000000000000import asyncio import collections import gc import logging import pytest import re import socket import sys import warnings from aiohttp import web class _AssertWarnsContext: """A context manager used to implement TestCase.assertWarns* methods.""" def __init__(self, expected, expected_regex=None): self.expected = expected if expected_regex is not None: expected_regex = re.compile(expected_regex) self.expected_regex = expected_regex self.obj_name = None def __enter__(self): # The __warningregistry__'s need to be in a pristine state for tests # to work properly. for v in sys.modules.values(): if getattr(v, '__warningregistry__', None): v.__warningregistry__ = {} self.warnings_manager = warnings.catch_warnings(record=True) self.warnings = self.warnings_manager.__enter__() warnings.simplefilter("always", self.expected) return self def __exit__(self, exc_type, exc_value, tb): self.warnings_manager.__exit__(exc_type, exc_value, tb) if exc_type is not None: # let unexpected exceptions pass through return try: exc_name = self.expected.__name__ except AttributeError: exc_name = str(self.expected) first_matching = None for m in self.warnings: w = m.message if not isinstance(w, self.expected): continue if first_matching is None: first_matching = w if (self.expected_regex is not None and not self.expected_regex.search(str(w))): continue # store warning for later retrieval self.warning = w self.filename = m.filename self.lineno = m.lineno return # Now we simply try to choose a helpful failure message if first_matching is not None: __tracebackhide__ = True assert 0, '"{}" does not match "{}"'.format( self.expected_regex.pattern, str(first_matching)) if self.obj_name: __tracebackhide__ = True assert 0, "{} not triggered by {}".format(exc_name, self.obj_name) else: __tracebackhide__ = True assert 0, "{} not triggered".format(exc_name) _LoggingWatcher = collections.namedtuple("_LoggingWatcher", ["records", "output"]) class _CapturingHandler(logging.Handler): """ A logging handler capturing all (raw and formatted) logging output. """ def __init__(self): logging.Handler.__init__(self) self.watcher = _LoggingWatcher([], []) def flush(self): pass def emit(self, record): self.watcher.records.append(record) msg = self.format(record) self.watcher.output.append(msg) class _AssertLogsContext: """A context manager used to implement TestCase.assertLogs().""" LOGGING_FORMAT = "%(levelname)s:%(name)s:%(message)s" def __init__(self, logger_name=None, level=None): self.logger_name = logger_name if level: self.level = logging._nameToLevel.get(level, level) else: self.level = logging.INFO self.msg = None def __enter__(self): if isinstance(self.logger_name, logging.Logger): logger = self.logger = self.logger_name else: logger = self.logger = logging.getLogger(self.logger_name) formatter = logging.Formatter(self.LOGGING_FORMAT) handler = _CapturingHandler() handler.setFormatter(formatter) self.watcher = handler.watcher self.old_handlers = logger.handlers[:] self.old_level = logger.level self.old_propagate = logger.propagate logger.handlers = [handler] logger.setLevel(self.level) logger.propagate = False return handler.watcher def __exit__(self, exc_type, exc_value, tb): self.logger.handlers = self.old_handlers self.logger.propagate = self.old_propagate self.logger.setLevel(self.old_level) if exc_type is not None: # let unexpected exceptions pass through return False if len(self.watcher.records) == 0: __tracebackhide__ = True assert 0, ("no logs of level {} or higher triggered on {}" .format(logging.getLevelName(self.level), self.logger.name)) @pytest.yield_fixture def warning(): yield _AssertWarnsContext @pytest.yield_fixture def log(): yield _AssertLogsContext @pytest.fixture def unused_port(): def f(): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind(('127.0.0.1', 0)) return s.getsockname()[1] return f @pytest.yield_fixture def loop(request): loop = asyncio.new_event_loop() asyncio.set_event_loop(None) yield loop loop.stop() loop.run_forever() loop.close() gc.collect() asyncio.set_event_loop(None) @pytest.yield_fixture def create_server(loop, unused_port): app = handler = srv = None @asyncio.coroutine def create(*, debug=False, ssl_ctx=None, proto='http', **kwargs): nonlocal app, handler, srv app = web.Application(loop=loop, **kwargs) port = unused_port() handler = app.make_handler(debug=debug, keep_alive_on=False) srv = yield from loop.create_server(handler, '127.0.0.1', port, ssl=ssl_ctx) if ssl_ctx: proto += 's' url = "{}://127.0.0.1:{}".format(proto, port) return app, url yield create @asyncio.coroutine def finish(): yield from handler.finish_connections() yield from app.finish() srv.close() yield from srv.wait_closed() loop.run_until_complete(finish()) @pytest.mark.tryfirst def pytest_pycollect_makeitem(collector, name, obj): if collector.funcnamefilter(name): if not callable(obj): return item = pytest.Function(name, parent=collector) if 'run_loop' in item.keywords: return list(collector._genfunctions(name, obj)) @pytest.mark.tryfirst def pytest_pyfunc_call(pyfuncitem): """ Run asyncio marked test functions in an event loop instead of a normal function call. """ if 'run_loop' in pyfuncitem.keywords: funcargs = pyfuncitem.funcargs loop = funcargs['loop'] testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} loop.run_until_complete(pyfuncitem.obj(**testargs)) return True def pytest_runtest_setup(item): if 'run_loop' in item.keywords and 'loop' not in item.fixturenames: # inject an event loop fixture for all async tests item.fixturenames.append('loop') aiohttp_jinja2-0.8.0/tests/test_context_processors.py0000664000175000017500000000452112704762176023747 0ustar andrewandrew00000000000000import aiohttp import aiohttp_jinja2 import asyncio import jinja2 import pytest @pytest.mark.run_loop def test_context_processors(create_server, loop): @aiohttp_jinja2.template('tmpl.jinja2') @asyncio.coroutine def func(request): return {'bar': 2} app, url = yield from create_server( middlewares=[ aiohttp_jinja2.context_processors_middleware]) aiohttp_jinja2.setup(app, loader=jinja2.DictLoader( {'tmpl.jinja2': 'foo: {{ foo }}, bar: {{ bar }}, path: {{ request.path }}'})) app['aiohttp_jinja2_context_processors'] = ( aiohttp_jinja2.request_processor, asyncio.coroutine( lambda request: {'foo': 1, 'bar': 'should be overwriten'}), ) app.router.add_route('GET', '/', func) resp = yield from aiohttp.request('GET', url, loop=loop) assert 200 == resp.status txt = yield from resp.text() assert 'foo: 1, bar: 2, path: /' == txt @pytest.mark.run_loop def test_context_is_response(create_server, loop): @aiohttp_jinja2.template('tmpl.jinja2') def func(request): return aiohttp.web_exceptions.HTTPForbidden() app, url = yield from create_server() aiohttp_jinja2.setup(app, loader=jinja2.DictLoader( {'tmpl.jinja2': "template"})) app.router.add_route('GET', '/', func) resp = yield from aiohttp.request('GET', url, loop=loop) assert 403 == resp.status yield from resp.release() @pytest.mark.run_loop def test_context_processors_new_setup_style(create_server, loop): @aiohttp_jinja2.template('tmpl.jinja2') @asyncio.coroutine def func(request): return {'bar': 2} app, url = yield from create_server() aiohttp_jinja2.setup( app, loader=jinja2.DictLoader( {'tmpl.jinja2': 'foo: {{ foo }}, bar: {{ bar }}, ' 'path: {{ request.path }}'}), context_processors=(aiohttp_jinja2.request_processor, asyncio.coroutine( lambda request: { 'foo': 1, 'bar': 'should be overwriten'}))) app.router.add_route('GET', '/', func) resp = yield from aiohttp.request('GET', url, loop=loop) assert 200 == resp.status txt = yield from resp.text() assert 'foo: 1, bar: 2, path: /' == txt aiohttp_jinja2-0.8.0/CHANGES.txt0000664000175000017500000000300412741154472017025 0ustar andrewandrew00000000000000CHANGES ======= 0.8.0 (2016-07-12) ------------------ - Add ability to render template without context #28 0.7.0 (2015-12-30) ------------------ - Add ability to decorate class based views (available in aiohttp 0.20) #18 - Upgrade aiohttp requirement to version 0.20.0+ 0.6.2 (2015-11-22) ------------------ - Make app_key parameter from render_string coroutine optional 0.6.0 (2015-10-29) ------------------ - Fix a bug in middleware (missed coroutine decorator) #16 - Drop Python 3.3 support (switched to aiohttp version v0.18.0) - Simplify context processors initialization by adding parameter to `setup()` 0.5.0 (2015-07-09) ------------------ - Introduce context processors #14 - Bypass StreamResponse #15 0.4.3 (2015-06-01) ------------------ - Fix distribution building: add manifest file 0.4.2 (2015-05-21) ------------------ - Make HTTPInternalServerError exceptions more verbose on console output 0.4.1 (2015-04-05) ------------------ - Documentation update 0.4.0 (2015-04-02) ------------------ - Add `render_string` method 0.3.1 (2015-04-01) ------------------ - Don't allow non-mapping context - Fix tiny documentation issues - Change the library logo 0.3.0 (2015-03-15) ------------------ - Documentation release 0.2.1 (2015-02-15) ------------------ - Fix `render_template` function 0.2.0 (2015-02-05) ------------------ - Migrate to aiohttp 0.14 - Add `status` parameter to template decorator - Drop optional `response` parameter 0.1.0 (2015-01-08) ------------------ - Initial release aiohttp_jinja2-0.8.0/Makefile0000664000175000017500000000141212704762176016662 0ustar andrewandrew00000000000000# Some simple testing tasks (sorry, UNIX only). flake: flake8 aiohttp_jinja2 tests test: flake py.test -s ./tests/ cov cover coverage: py.test --cov=aiohttp_jinja2 --cov-report=html --cov-report=term ./tests/ @echo "open file://`pwd`/htmlcov/index.html" clean: rm -rf `find . -name __pycache__` rm -f `find . -type f -name '*.py[co]' ` rm -f `find . -type f -name '*~' ` rm -f `find . -type f -name '.*~' ` rm -f `find . -type f -name '@*' ` rm -f `find . -type f -name '#*#' ` rm -f `find . -type f -name '*.orig' ` rm -f `find . -type f -name '*.rej' ` rm -f .coverage rm -rf coverage rm -rf build rm -rf cover doc: make -C docs html @echo "open file://`pwd`/docs/_build/html/index.html" .PHONY: all build venv flake test vtest testloop cov clean doc aiohttp_jinja2-0.8.0/LICENSE0000664000175000017500000002606512704762176016242 0ustar andrewandrew00000000000000Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2015-2016 Andrew Svetlov Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. aiohttp_jinja2-0.8.0/README.rst0000664000175000017500000000454112741154423016706 0ustar andrewandrew00000000000000aiohttp_jinja2 ============== jinja2_ template renderer for `aiohttp.web`__. .. _jinja2: http://jinja.pocoo.org .. _aiohttp_web: https://aiohttp.readthedocs.io/en/latest/web.html __ aiohttp_web_ Installation ------------ Install from PyPI:: pip install aiohttp-jinja2 Developing ---------- Install requirement and launch tests:: pip install -r requirements-dev.txt py.test tests Usage ----- Before template rendering you have to setup *jinja2 environment* first:: app = web.Application() aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('/path/to/templates/folder')) After that you may to use template engine in your *web-handlers*. The most convenient way is to decorate a *web-handler*. Using the function based web handlers:: @aiohttp_jinja2.template('tmpl.jinja2') def handler(request): return {'name': 'Andrew', 'surname': 'Svetlov'} Or for `Class Based Views `:: class Handler(web.View): @aiohttp_jinja2.template('tmpl.jinja2') async def get(self): return {'name': 'Andrew', 'surname': 'Svetlov'} On handler call the ``aiohttp_jinja2.template`` decorator will pass returned dictionary ``{'name': 'Andrew', 'surname': 'Svetlov'}`` into template named ``tmpl.jinja2`` for getting resulting HTML text. If you need more complex processing (set response headers for example) you may call ``render_template`` function. Using a function based web handler:: async def handler(request): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', request, context) response.headers['Content-Language'] = 'ru' return response Or, again, a class based view:: class Handler(web.View): async def get(self): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', self.request, context) response.headers['Content-Language'] = 'ru' return response License ------- ``aiohttp_jinja2`` is offered under the Apache 2 license. aiohttp_jinja2-0.8.0/setup.py0000664000175000017500000000264412704762176016744 0ustar andrewandrew00000000000000import codecs from setuptools import setup import os import re with codecs.open(os.path.join(os.path.abspath(os.path.dirname( __file__)), 'aiohttp_jinja2', '__init__.py'), 'r', 'latin1') as fp: try: version = re.findall(r"^__version__ = '([^']+)'$", fp.read(), re.M)[0] except IndexError: raise RuntimeError('Unable to determine version.') def read(f): return open(os.path.join(os.path.dirname(__file__), f)).read().strip() install_requires = ['aiohttp>=0.20', 'jinja2>=2.7'] tests_require = install_requires + ['nose'] setup(name='aiohttp_jinja2', version=version, description=("jinja2 template renderer for aiohttp.web " "(http server for asyncio)"), long_description='\n\n'.join((read('README.rst'), read('CHANGES.txt'))), classifiers=[ 'License :: OSI Approved :: Apache Software License', 'Intended Audience :: Developers', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Topic :: Internet :: WWW/HTTP'], author='Andrew Svetlov', author_email='andrew.svetlov@gmail.com', url='https://github.com/aio-libs/aiohttp_jinja2/', license='Apache 2', packages=['aiohttp_jinja2'], install_requires=install_requires, include_package_data=True) aiohttp_jinja2-0.8.0/aiohttp_jinja2/0000775000175000017500000000000012741211422020111 5ustar andrewandrew00000000000000aiohttp_jinja2-0.8.0/aiohttp_jinja2/__init__.py0000664000175000017500000000746012741154512022237 0ustar andrewandrew00000000000000import asyncio import functools import jinja2 from collections import Mapping from aiohttp import web from aiohttp.abc import AbstractView __version__ = '0.8.0' __all__ = ('setup', 'get_env', 'render_template', 'template') APP_KEY = 'aiohttp_jinja2_environment' REQUEST_CONTEXT_KEY = 'aiohttp_jinja2_context' APP_CONTEXT_PROCESSORS_KEY = 'aiohttp_jinja2_context_processors' def setup(app, *args, app_key=APP_KEY, context_processors=(), **kwargs): env = jinja2.Environment(*args, **kwargs) app[app_key] = env if context_processors: app[APP_CONTEXT_PROCESSORS_KEY] = context_processors app.middlewares.append(context_processors_middleware) def url(__aiohttp_jinja2_route_name, **kwargs): return app.router[__aiohttp_jinja2_route_name].url(**kwargs) env.globals['url'] = url env.globals['app'] = app return env def get_env(app, *, app_key=APP_KEY): return app.get(app_key) def render_string(template_name, request, context, *, app_key=APP_KEY): env = request.app.get(app_key) if env is None: text = ("Template engine is not initialized, " "call aiohttp_jinja2.setup(..., app_key={}) first" "".format(app_key)) # in order to see meaningful exception message both: on console # output and rendered page we add same message to *reason* and # *text* arguments. raise web.HTTPInternalServerError(reason=text, text=text) try: template = env.get_template(template_name) except jinja2.TemplateNotFound as e: raise web.HTTPInternalServerError( text="Template '{}' not found".format(template_name)) from e if not isinstance(context, Mapping): text = "context should be mapping, not {}".format(type(context)) # same reason as above raise web.HTTPInternalServerError(reason=text, text=text) if REQUEST_CONTEXT_KEY in request: for k, v in request.get(REQUEST_CONTEXT_KEY, {}).items(): if k not in context: context[k] = v text = template.render(context) return text def render_template(template_name, request, context, *, app_key=APP_KEY, encoding='utf-8'): response = web.Response() if context is None: context = {} text = render_string(template_name, request, context, app_key=app_key) response.content_type = 'text/html' response.charset = encoding response.text = text return response def template(template_name, *, app_key=APP_KEY, encoding='utf-8', status=200): def wrapper(func): @asyncio.coroutine @functools.wraps(func) def wrapped(*args): if asyncio.iscoroutinefunction(func): coro = func else: coro = asyncio.coroutine(func) context = yield from coro(*args) if isinstance(context, web.StreamResponse): return context # Supports class based views see web.View if isinstance(args[0], AbstractView): request = args[0].request else: request = args[-1] response = render_template(template_name, request, context, app_key=app_key, encoding=encoding) response.set_status(status) return response return wrapped return wrapper @asyncio.coroutine def context_processors_middleware(app, handler): @asyncio.coroutine def middleware(request): request[REQUEST_CONTEXT_KEY] = {} for processor in app[APP_CONTEXT_PROCESSORS_KEY]: request[REQUEST_CONTEXT_KEY].update( (yield from processor(request))) return (yield from handler(request)) return middleware @asyncio.coroutine def request_processor(request): return {'request': request} aiohttp_jinja2-0.8.0/MANIFEST.in0000664000175000017500000000023012704762176016755 0ustar andrewandrew00000000000000include CHANGES.txt include LICENSE include README.rst include Makefile graft aiohttp_jinja2 graft docs graft examples graft tests global-exclude *.pyc aiohttp_jinja2-0.8.0/docs/0000775000175000017500000000000012741211422016134 5ustar andrewandrew00000000000000aiohttp_jinja2-0.8.0/docs/aiohttp-icon.ico0000664000175000017500000000627612704762176021261 0ustar andrewandrew00000000000000  ( @팋ttt椤lllhhhhhh`r|qOtPakl񋋋kkklllllllllkjjlmnp[T9]t9l:s?]q8IRtZdltuvkkklllRbl5Xmf46HKj~bq|NgyOlBG4]vJ6U]hoa?c}IeyV\z}IlG?e~7|VEd{PizCfSe:^vL{Hj4hA^pqrslqtGbvJdwXkzWkznuz}}}b9@dzGiBd}Ni}Oj~Qj|OhzDcxAavFbtTse=5p4Yq3rW/>oJf{Wiݐz;3CCOlTMaa[rpcsCllbGQSc\W=9l?`z2pHDAK[Rd扔zZZlSQfGEckqnru=]vA_xBayDc{He|If~HgIg~Ig~Gf}Vl}cq{x|`ayPQyUV}\CNHg-=]g5@azGcyIcw7k>s@m?d}EgDf}KfyjrxffyNNyMMxLLwMMuquvRer9c=-4Dc0o:IbwRMOJBd|Ff|DkjjlJJuLLwII{IIcx=lCc|>b{\sHau<\u>^w@^wA_wB`xB_xA^wVgv^ktgounstjpsbjpNao[r:[r;[q:Yp6Vp6TnAYmU`jlllkkk첲;=.*?cH<;2t/g3Zy8Vn3TlO^illljjjllllllwww59VtUOF97,KGߎjjjlllllllllD8<6-4dT0HHKylll]E#76,^kդpaiohttp_jinja2-0.8.0/docs/conf.py0000664000175000017500000002350712723110014017435 0ustar andrewandrew00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # aiohttp_jinja2 documentation build configuration file, created by # sphinx-quickstart on Sun Mar 22 12:04:15 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os import codecs import re _docs_path = os.path.dirname(__file__) _version_path = os.path.abspath(os.path.join(_docs_path, '..', 'aiohttp_jinja2', '__init__.py')) with codecs.open(_version_path, 'r', 'latin1') as fp: try: _version_info = re.search(r"^__version__ = '" r"(?P\d+)" r"\.(?P\d+)" r"\.(?P\d+)" r"(?P.*)?'$", fp.read(), re.M).groupdict() except IndexError: raise RuntimeError('Unable to determine version.') # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) import alabaster # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.3' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode', 'alabaster', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = 'aiohttp_jinja2' copyright = '2015-2016 Andrew Svetlov' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '{major}.{minor}'.format(**_version_info) # The full version, including alpha/beta/rc tags. release = '{major}.{minor}.{patch}-{tag}'.format(**_version_info) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { 'logo': 'aiohttp-icon-128x128.png', 'description': 'jinja2 template renderer for aiohttp.web', 'github_user': 'aio-libs', 'github_repo': 'aiohttp_jinja2', 'github_button': True, 'github_banner': True, 'travis_button': True, 'pre_bg': '#FFF6E5', 'note_bg': '#E5ECD1', 'note_border': '#BFCF8C', 'body_text': '#482C0A', 'sidebar_text': '#49443E', 'sidebar_header': '#4B4032', } # Add any paths that contain custom themes here, relative to this directory. html_theme_path = [alabaster.get_path()] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. html_favicon = 'aiohttp-icon.ico' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. html_sidebars = { '**': [ 'about.html', 'navigation.html', 'searchbox.html', ] } # Additional templates that should be rendered to pages, maps page names to # template names. # html_additional_pages = {} # If false, no module index is generated. # html_domain_indices = True # If false, no index is generated. # html_use_index = True # If true, the index is split into individual pages for each letter. # html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'aiohttp_jinja2doc' # -- Options for LaTeX output --------------------------------------------- # The paper size ('letterpaper' or 'a4paper'). # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # 'preamble': '', latex_elements = { } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'aiohttp_jinja2.tex', 'aiohttp\\_jinja2 Documentation', 'Andrew Svetlov', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # latex_use_parts = False # If true, show page references after internal links. # latex_show_pagerefs = False # If true, show URL addresses after external links. # latex_show_urls = False # Documents to append as an appendix to all manuals. # latex_appendices = [] # If false, no module index is generated. # latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'aiohttp_jinja2', 'aiohttp_jinja2 Documentation', ['Andrew Svetlov'], 1) ] # If true, show URL addresses after external links. # man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'aiohttp_jinja2', 'aiohttp_jinja2 Documentation', 'Andrew Svetlov', 'aiohttp_jinja2', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. # texinfo_appendices = [] # If false, no module index is generated. # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. # texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'http://docs.python.org/3': None, 'https://aiohttp.readthedocs.io/en/stable': None, 'http://jinja2.pocoo.org/docs/dev': None} aiohttp_jinja2-0.8.0/docs/make.bat0000664000175000017500000001507512704762176017571 0ustar andrewandrew00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\aiohttp_jinja2.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\aiohttp_jinja2.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) :end aiohttp_jinja2-0.8.0/docs/Makefile0000664000175000017500000001521212704762176017615 0ustar andrewandrew00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/aiohttp_jinja2.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/aiohttp_jinja2.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/aiohttp_jinja2" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/aiohttp_jinja2" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." aiohttp_jinja2-0.8.0/docs/_static/0000775000175000017500000000000012741211422017562 5ustar andrewandrew00000000000000aiohttp_jinja2-0.8.0/docs/_static/aiohttp-icon-128x128.png0000664000175000017500000005605312704762176023652 0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Fvrjk#Hq9*;|ⴠ[ n<8>#qYUeYv# 8qgggܿd$nwPr{O>(*_5y î+ A뛼c.mĊk!;C'{ ;/$R.*Ff.oJ*0sPտS(ǎVVH AVn+KL Jl^'zF}sʲ$cۣHs@_tXC FNﳵ,!(yM^ kꅄabyip窢FP9=+ 4:z^jr]16DQUx F]0 avAV P)@p=ŨQwoҹ2ƺjݻ +TauwYv@E\z,/;z=c4"}evR5ۘ S* d0a@v)g y)H1h#UVY}z?wpɛ<( yS^{4Ml^JE=EьJLS߿ϕ+WFEDx?NRx; @ ![H gnB H.HыDw)Vұ!QNר(&2*>;ۄpk, VEH9bZY@I^[muƣ,#˲%>zf3ffflg!hsu6lE\Fx0*I5_!o9,O/62}f@ecݔa)UY@骉Cl:|oqŘa#!IAG]Dyh}k gQ'OgH}L&&z `E\\\p5a:Rbs*34-e%a֚ Hsu^5SQ)"L:eY0 9JQ|CX2g`@Љ x<ӧ.e:>y~f͵>΂ *TY<~,km_ #?4]C4f_1o3HGo0yTvLY ATX6X=ׁQϡn| AsrHccJ(fLZ ox\6dK_d22f9% ut+mWG0R5mpKWх;#6o?(g.yހH!)?O4M~qw]󼡙_||& :t(.'ofgHv-g`2$η I+ܒASv'@yA/@'d^3,O(j~ϳ zuZkX(l >a31{{{(dS| z_Lq~Vs']_hq6`N H!RQtJ`3ґC1AyzI\ܫG}Y{j'wir~~NMYgm/,PJ1 888h{5/=$Rhm>\YEAY͝srr6/ІOEF#ik\vk׮5']Y߃W{$I_vwM)Eܽ{w}#',Y>~\~W_}A:'@׿k/:.>_lҭw*̫еX~||( SᲀhO"z=ku-?x5qXYՀןּⲮܧ}ՅigF>:Ds2eIENDB`aiohttp_jinja2-0.8.0/docs/index.rst0000664000175000017500000001641512741154423020013 0ustar andrewandrew00000000000000.. aiohttp_jinja2 documentation master file, created by sphinx-quickstart on Sun Mar 22 12:04:15 2015. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. aiohttp_jinja2 ============== .. module:: aiohttp_jinja2 .. currentmodule:: aiohttp_jinja2 .. highlight:: python :term:`jinja2` template renderer for :ref:`aiohttp.web`. Usage ----- Before template rendering you have to setup *jinja2 environment* (:class:`jinja2.Environment`) first:: app = web.Application() aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('/path/to/templates/folder')) After that you may use template engine in your :term:`web-handlers`. The most convenient way is to decorate a :term:`web-handler`. Using the function based web handlers:: @aiohttp_jinja2.template('tmpl.jinja2') def handler(request): return {'name': 'Andrew', 'surname': 'Svetlov'} Or the class-based views (:class:`aiohttp.web.View`):: class Handler(web.View): @aiohttp_jinja2.template('tmpl.jinja2') async def get(self): return {'name': 'Andrew', 'surname': 'Svetlov'} On handler call the :func:`template` decorator will pass returned dictionary ``{'name': 'Andrew', 'surname': 'Svetlov'}`` into template named ``"tmpl.jinja2"`` for getting resulting HTML text. If you need more complex processing (set response headers for example) you may call :func:`render_template` function. Using a function based web handler:: async def handler(request): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', request, context) response.headers['Content-Language'] = 'ru' return response Or, again, a class-based view (:class:`aiohttp.web.View`):: class Handler(web.View): async def get(self): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', self.request, context) response.headers['Content-Language'] = 'ru' return response Context processors is a way to add some variables to each template context. It works like :attr:`jinja2.Environment().globals`, but calculate variables each request. So if you need to add global constants it will be better to use :attr:`jinja2.Environment().globals` directly. But if you variables depends of request (e.g. current user) you have to use context processors. Context processors is following last-win strategy. Therefore a context processor could rewrite variables delivered with previous one. In order to use context processors create required processors:: async def foo_processor(request): return {'foo': 'bar'} And pass them into :func:`setup`:: aiohttp_jinja2.setup( app, context_processors=[foo_processor, aiohttp_jinja2.request_processor], loader=loader) As you can see, there is a built-in :func:`request_processor`, which adds current :class:`aiohttp.web.Request` into context of templates under ``'request'`` name. By default there are two aiohttp specific :attr:`jinja2.Environment().globals` available in templates: - ``url``: Resolve a named route url - ``app``: Use any properties on the app instance

Welcome to {{ app['name'] }}

Index Page Library Installation -------------------- The :mod:`aiohttp_jinja2` can be installed by pip:: $ pip3 install aiohttp_jinja2 Source code ----------- The project is hosted on `GitHub `_. Please feel free to file an issue on `bug tracker `_ if you have found a bug or have some suggestion for library improvement. The library uses `Travis `_ for Continuous Integration. IRC channel ----------- You can discuss the library on Freenode_ at **#aio-libs** channel. .. _Freenode: http://freenode.net .. _aiohttp_jinja2-reference: Reference --------- .. data:: APP_KEY The key name in :class:`aiohttp.web.Application` dictionary, ``'aiohttp_jinja2_environment'`` for storing :term:`jinja2` environment object (:class:`jinja2.Environment`). Usually you don't need to operate with *application* manually, left it to :mod:`aiohttp_jinja2` functions. .. function:: get_env(app, app_key=APP_KEY) Return :class:`jinja2.Environment` object which has stored in the *app* (:class:`aiohttp.web.Application` instance). *app_key* is an optional key for application dict, :const:`APP_KEY` by default. .. function:: render_string(template_name, request, context, *, \ app_key=APP_KEY) Return :class:`str` which contains template *template_name* filled with *context*. *request* is a parameter from :term:`web-handler`, :class:`aiohttp.web.Request` instance. *app_key* is an optional key for application dict, :const:`APP_KEY` by default. .. function:: render_template(template_name, request, context, *, \ app_key=APP_KEY, encoding='utf-8') Return :class:`aiohttp.web.Response` which contains template *template_name* filled with *context*. *request* is a parameter from :term:`web-handler`, :class:`aiohttp.web.Request` instance. *app_key* is an optional key for application dict, :const:`APP_KEY` by default. *encoding* is response encoding, ``'utf-8'`` by default. Returned response has *Content-Type* header set to ``'text/html'``. .. function:: setup(app, *args, app_key=APP_KEY, **kwargs) Initialize :class:`jinja2.Environment` object. *app* is :class:`aiohttp.web.Application` instance. *args* and *kawargs* are passed into environment constructor. *app_key* is an optional key for application dict, :const:`APP_KEY` by default. The functions is rougly equivalent for:: def setup(app, *args, app_key=APP_KEY, **kwargs): env = jinja2.Environment(*args, **kwargs) app[app_key] = env return env .. decorator:: template(template_name, *, app_key=APP_KEY, encoding='utf-8',\ status=200) Decorate :term:`web-handler` to convert returned :class:`dict` context into :class:`aiohtttp.web.Response` filled with *template_name* template. *app_key* is an optional key for application dict, :const:`APP_KEY` by default. *encoding* is response encoding, ``'utf-8'`` by default. *status* is *HTTP status code* for returned response, *200* (OK) by default. Returned response has *Content-Type* header set to ``'text/html'``. License ------- :mod:`aiohttp_jinja2` is offered under the Apache 2 license. Glossary -------- .. if you add new entries, keep the alphabetical sorting! .. glossary:: jinja2 A modern and designer-friendly templating language for Python. See http://jinja.pocoo.org/ web-handler An endpoint that returns http response. Indices and tables ================== * :ref:`genindex` * :ref:`search` aiohttp_jinja2-0.8.0/aiohttp_jinja2.egg-info/0000775000175000017500000000000012741211422021603 5ustar andrewandrew00000000000000aiohttp_jinja2-0.8.0/aiohttp_jinja2.egg-info/PKG-INFO0000664000175000017500000001356612741211422022713 0ustar andrewandrew00000000000000Metadata-Version: 1.1 Name: aiohttp-jinja2 Version: 0.8.0 Summary: jinja2 template renderer for aiohttp.web (http server for asyncio) Home-page: https://github.com/aio-libs/aiohttp_jinja2/ Author: Andrew Svetlov Author-email: andrew.svetlov@gmail.com License: Apache 2 Description: aiohttp_jinja2 ============== jinja2_ template renderer for `aiohttp.web`__. .. _jinja2: http://jinja.pocoo.org .. _aiohttp_web: https://aiohttp.readthedocs.io/en/latest/web.html __ aiohttp_web_ Installation ------------ Install from PyPI:: pip install aiohttp-jinja2 Developing ---------- Install requirement and launch tests:: pip install -r requirements-dev.txt py.test tests Usage ----- Before template rendering you have to setup *jinja2 environment* first:: app = web.Application() aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('/path/to/templates/folder')) After that you may to use template engine in your *web-handlers*. The most convenient way is to decorate a *web-handler*. Using the function based web handlers:: @aiohttp_jinja2.template('tmpl.jinja2') def handler(request): return {'name': 'Andrew', 'surname': 'Svetlov'} Or for `Class Based Views `:: class Handler(web.View): @aiohttp_jinja2.template('tmpl.jinja2') async def get(self): return {'name': 'Andrew', 'surname': 'Svetlov'} On handler call the ``aiohttp_jinja2.template`` decorator will pass returned dictionary ``{'name': 'Andrew', 'surname': 'Svetlov'}`` into template named ``tmpl.jinja2`` for getting resulting HTML text. If you need more complex processing (set response headers for example) you may call ``render_template`` function. Using a function based web handler:: async def handler(request): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', request, context) response.headers['Content-Language'] = 'ru' return response Or, again, a class based view:: class Handler(web.View): async def get(self): context = {'name': 'Andrew', 'surname': 'Svetlov'} response = aiohttp_jinja2.render_template('tmpl.jinja2', self.request, context) response.headers['Content-Language'] = 'ru' return response License ------- ``aiohttp_jinja2`` is offered under the Apache 2 license. CHANGES ======= 0.8.0 (2016-07-12) ------------------ - Add ability to render template without context #28 0.7.0 (2015-12-30) ------------------ - Add ability to decorate class based views (available in aiohttp 0.20) #18 - Upgrade aiohttp requirement to version 0.20.0+ 0.6.2 (2015-11-22) ------------------ - Make app_key parameter from render_string coroutine optional 0.6.0 (2015-10-29) ------------------ - Fix a bug in middleware (missed coroutine decorator) #16 - Drop Python 3.3 support (switched to aiohttp version v0.18.0) - Simplify context processors initialization by adding parameter to `setup()` 0.5.0 (2015-07-09) ------------------ - Introduce context processors #14 - Bypass StreamResponse #15 0.4.3 (2015-06-01) ------------------ - Fix distribution building: add manifest file 0.4.2 (2015-05-21) ------------------ - Make HTTPInternalServerError exceptions more verbose on console output 0.4.1 (2015-04-05) ------------------ - Documentation update 0.4.0 (2015-04-02) ------------------ - Add `render_string` method 0.3.1 (2015-04-01) ------------------ - Don't allow non-mapping context - Fix tiny documentation issues - Change the library logo 0.3.0 (2015-03-15) ------------------ - Documentation release 0.2.1 (2015-02-15) ------------------ - Fix `render_template` function 0.2.0 (2015-02-05) ------------------ - Migrate to aiohttp 0.14 - Add `status` parameter to template decorator - Drop optional `response` parameter 0.1.0 (2015-01-08) ------------------ - Initial release Platform: UNKNOWN Classifier: License :: OSI Approved :: Apache Software License Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Internet :: WWW/HTTP aiohttp_jinja2-0.8.0/aiohttp_jinja2.egg-info/top_level.txt0000664000175000017500000000001712741211422024333 0ustar andrewandrew00000000000000aiohttp_jinja2 aiohttp_jinja2-0.8.0/aiohttp_jinja2.egg-info/requires.txt0000664000175000017500000000003212741211422024176 0ustar andrewandrew00000000000000aiohttp>=0.20 jinja2>=2.7 aiohttp_jinja2-0.8.0/aiohttp_jinja2.egg-info/dependency_links.txt0000664000175000017500000000000112741211422025651 0ustar andrewandrew00000000000000 aiohttp_jinja2-0.8.0/aiohttp_jinja2.egg-info/SOURCES.txt0000664000175000017500000000076512741211422023477 0ustar andrewandrew00000000000000CHANGES.txt LICENSE MANIFEST.in Makefile README.rst setup.py aiohttp_jinja2/__init__.py aiohttp_jinja2.egg-info/PKG-INFO aiohttp_jinja2.egg-info/SOURCES.txt aiohttp_jinja2.egg-info/dependency_links.txt aiohttp_jinja2.egg-info/requires.txt aiohttp_jinja2.egg-info/top_level.txt docs/Makefile docs/aiohttp-icon.ico docs/conf.py docs/index.rst docs/make.bat docs/_static/aiohttp-icon-128x128.png tests/conftest.py tests/test_context_processors.py tests/test_jinja_globals.py tests/test_simple_renderer.pyaiohttp_jinja2-0.8.0/setup.cfg0000664000175000017500000000007312741211422017025 0ustar andrewandrew00000000000000[egg_info] tag_date = 0 tag_build = tag_svn_revision = 0