Merge pull request #1440 from stevepiercy/1.5-branch
backports from master to 1.5 branch
| | |
| | | Next release |
| | | ============ |
| | | |
| | | Docs |
| | | ---- |
| | | |
| | | - Removed logging configuration from Quick Tutorial ini files except for |
| | | scaffolding- and logging-related chapters to avoid needing to explain it too |
| | | early. |
| | | |
| | | - Clarify a previously-implied detail of the ``ISession.invalidate`` API |
| | | documentation. |
| | | |
| | | Bug Fixes |
| | | --------- |
| | | |
| | | - Work around a bug introduced in Python 2.7.7 on Windows where |
| | | ``mimetypes.guess_type`` returns Unicode rather than str for the content |
| | | type, unlike any previous version of Python. See |
| | |
| | | |
| | | - Fix an issue whereby predicates would be resolved as maybe_dotted in the |
| | | introspectable but not when passed for registration. This would mean that |
| | | add_route_predicate for example can not take a string and turn it into the |
| | | actual callable function. |
| | | ``add_route_predicate`` for example can not take a string and turn it into |
| | | the actual callable function. |
| | | See https://github.com/Pylons/pyramid/pull/1306 |
| | | |
| | | - Fix ``pyramid.testing.setUp`` to return a ``Configurator`` with a proper |
| | | package. Previously it was not possible to do package-relative includes |
| | | using the returned ``Configurator`` during testing. There is now a |
| | | ``package`` argument that can override this behavior as well. |
| | | See https://github.com/Pylons/pyramid/pull/1322 |
| | | |
| | | - Removed non-ascii copyright symbol from templates, as this was |
| | | causing the scaffolds to fail for project generation on some systems. |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial, sqlalchemy |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [logger_sqlalchemy] |
| | | level = INFO |
| | | handlers = |
| | | qualname = sqlalchemy.engine |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | Analysis |
| | | ======== |
| | | |
| | | ``pyramid_debugtoolbar`` is a full-fledged Python package, |
| | | available on PyPI just like thousands of other Python packages. Thus we |
| | | start by installing the ``pyramid_debugtoolbar`` package into our |
| | | virtual environment using normal Python package installation commands. |
| | | ``pyramid_debugtoolbar`` is a full-fledged Python package, available on PyPI |
| | | just like thousands of other Python packages. Thus we start by installing the |
| | | ``pyramid_debugtoolbar`` package into our virtual environment using normal |
| | | Python package installation commands. |
| | | |
| | | The ``pyramid_debugtoolbar`` Python package is also a Pyramid add-on, |
| | | which means we need to include its add-on configuration into our web |
| | | application. We could do this with imperative configuration in |
| | | ``tutorial/__init__.py`` by using ``config.include``. Pyramid also |
| | | supports wiring in add-on configuration via our ``development.ini`` |
| | | using ``pyramid.includes``. We use this to load the configuration for |
| | | the debugtoolbar. |
| | | The ``pyramid_debugtoolbar`` Python package is also a Pyramid add-on, which |
| | | means we need to include its add-on configuration into our web application. We |
| | | could do this with imperative configuration in ``tutorial/__init__.py`` by |
| | | using ``config.include``. Pyramid also supports wiring in add-on configuration |
| | | via our ``development.ini`` using ``pyramid.includes``. We use this to load |
| | | the configuration for the debugtoolbar. |
| | | |
| | | You'll now see an attractive (and collapsible) menu in the right of |
| | | your browser, providing introspective access to debugging information. |
| | | Even better, if your web application generates an error, |
| | | you will see a nice traceback on the screen. When you want to disable |
| | | this toolbar, no need to change code: you can remove it from |
| | | ``pyramid.includes`` in the relevant ``.ini`` configuration file (thus |
| | | showing why configuration files are handy.) |
| | | You'll now see an attractive button on the right side of your browser, which |
| | | you may click to provide introspective access to debugging information in a |
| | | new browser tab. Even better, if your web application generates an error, you |
| | | will see a nice traceback on the screen. When you want to disable this |
| | | toolbar, no need to change code: you can remove it from ``pyramid.includes`` |
| | | in the relevant ``.ini`` configuration file (thus showing why configuration |
| | | files are handy.) |
| | | |
| | | Note that the toolbar mutates the HTML generated by our app and uses jQuery to |
| | | overlay itself. If you are using the toolbar while you're developing and you |
| | | start to experience otherwise inexplicable client-side weirdness, you can shut |
| | | it off by commenting out the ``pyramid_debugtoolbar`` line in |
| | | Note that the toolbar injects a small amount of html/css into your app just |
| | | before the closing ``</body>`` tag in order to display itself. If you start |
| | | to experience otherwise inexplicable client-side weirdness, you can shut it |
| | | off by commenting out the ``pyramid_debugtoolbar`` line in |
| | | ``pyramid.includes`` temporarily. |
| | | |
| | | .. seealso:: See also :ref:`pyramid_debugtoolbar <toolbar:overview>`. |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | :linenos: |
| | | |
| | | #. Rather than implement a new view, we will "stack" another decorator |
| | | on the ``hello`` view: |
| | | on the ``hello`` view in ``views.py``: |
| | | |
| | | .. literalinclude:: json/tutorial/views.py |
| | | :linenos: |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $VENV/bin/python |
| | | |
| | | # Windows |
| | | # Use your browser to download: |
| | | # https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.p |
| | | # ...into c:\projects\quick_tutorial\ez_setup.py |
| | | # |
| | | # Use your web browser to download this file: |
| | | # https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py |
| | | # |
| | | # ...and save it to: |
| | | # c:\projects\quick_tutorial\ez_setup.py |
| | | # |
| | | # Then run the following command: |
| | | |
| | | c:\> %VENV%\Scripts\python ez_setup.py |
| | | |
| | | If ``wget`` complains with a certificate error, then run this command instead: |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | use = egg:pyramid#wsgiref |
| | | host = 0.0.0.0 |
| | | port = 6543 |
| | | |
| | | # Begin logging configuration |
| | | |
| | | [loggers] |
| | | keys = root, tutorial |
| | | |
| | | [logger_tutorial] |
| | | level = DEBUG |
| | | handlers = |
| | | qualname = tutorial |
| | | |
| | | [handlers] |
| | | keys = console |
| | | |
| | | [formatters] |
| | | keys = generic |
| | | |
| | | [logger_root] |
| | | level = INFO |
| | | handlers = console |
| | | |
| | | [handler_console] |
| | | class = StreamHandler |
| | | args = (sys.stderr,) |
| | | level = NOTSET |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | |
| | | # End logging configuration |
| | |
| | | ``invalidate`` is implementation-dependent, but it should have |
| | | the effect of completely dissociating any data stored in the |
| | | session with the current request. It might set response |
| | | values (such as one which clears a cookie), or it might not.""" |
| | | values (such as one which clears a cookie), or it might not. |
| | | |
| | | An invalidated session may be used after the call to ``invalidate`` |
| | | with the effect that a new session is created to store the data. This |
| | | enables workflows requiring an entirely new session, such as in the |
| | | case of changing privilege levels or preventing fixation attacks. |
| | | """ |
| | | |
| | | def changed(): |
| | | """ Mark the session as changed. A user of a session should |