doc/book/pyramid/quickstart.rst
author Denis Laxalde <denis.laxalde@logilab.fr>
Fri, 27 Jan 2017 11:05:07 +0100
changeset 11945 ef6b18c56b5a
parent 11631 faf279e33298
child 12097 78a5c6a64fad
permissions -rw-r--r--
[skeleton] Add an entry point and configuration for running a Pyramid application We add a `pyramid_main` function in __init__.py that instantiate the WSGI application using "cubicweb.pyramid"; this is defined as an entry point (in setup.py) so that pserve_ can find it. Alongside comes a development.ini file which includes basic settings so that running a Pyramid+CubicWeb application works (only the "instance=<appid>" may be passed as a command-line argument). Logging is also configured there, but only includes the cube at stake and cubicweb (others could be added if needed). .. _perse: \ http://docs.pylonsproject.org/projects/pyramid/en/1.8-branch/pscripts/pserve.html

Quick start
===========

.. highlight:: bash

Prerequites
-----------

-   Install everything (here with pip, possibly in a virtualenv)::

        pip install pyramid-cubicweb cubicweb-pyramid pyramid_debugtoolbar

-   Have a working Cubicweb instance, for example:


    -   Make sure CubicWeb is in user mode::

            export CW_MODE=user

    -   Create a CubicWeb instance, and install the 'pyramid' cube on it (see
        :ref:`configenv` for more details on this step)::

            cubicweb-ctl create pyramid myinstance

-   Edit your ``~/etc/cubicweb.d/myinstance/all-in-one.conf`` and set values for
    :confval:`pyramid-auth-secret` and :confval:`pyramid-session-secret`.
    *required if cubicweb.pyramid.auth and pyramid_cubiweb.session get
    included, which is the default*

From CubicWeb
-------------

-   Start the instance with the :ref:`'pyramid' command <cubicweb-ctl_pyramid>`
    instead of 'start'::

        cubicweb-ctl pyramid --debug myinstance

In a pyramid application
------------------------

-   Create a pyramid application

-   Include cubicweb.pyramid:

    .. code-block:: python

        def includeme(config):
            # ...
            config.include('cubicweb.pyramid')
            # ...

-   Configure the instance name (in the .ini file):

    .. code-block:: ini

        cubicweb.instance = myinstance

-   Configure the base-url and https-url in all-in-one.conf to match the ones
    of the pyramid configuration (this is a temporary limitation).


Usage with pserve
-----------------

To run a Pyramid application using pserve_:

::

    pserve /path/to/development.ini instance=<appid>


.. _pserve: \
    http://docs.pylonsproject.org/projects/pyramid/en/latest/pscripts/pserve.html