Navigation Menu

Skip to content

Commit

Permalink
Add connection management documentation for CherryPy
Browse files Browse the repository at this point in the history
  • Loading branch information
stenci committed Sep 21, 2016
1 parent 3953132 commit 670f486
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/peewee/database.rst
Expand Up @@ -757,6 +757,23 @@ In your application `main()` make sure `MyRequest` is used as `request_factory`:
config = Configurator(settings=settings, ...)
config.set_request_factory(MyRequest)
CherryPy
^^^^^^^^

See `Publish/Subscribe pattern <http://docs.cherrypy.org/en/latest/extend.html#publish-subscribe-pattern>`_.

.. code-block:: python
def _db_connect():
db.connect()
def _db_close():
if not db.is_closed():
db.close()
cherrypy.engine.subscribe('before_request', _db_connect)
cherrypy.engine.subscribe('after_request', _db_close)
Other frameworks
^^^^^^^^^^^^^^^^

Expand Down

0 comments on commit 670f486

Please sign in to comment.