doc/book/pyramid/quickstart.rst
author Denis Laxalde <denis.laxalde@logilab.fr>
Mon, 06 Mar 2017 14:19:20 +0100
changeset 12008 7694dcf5ad30
parent 11945 ef6b18c56b5a
child 12097 78a5c6a64fad
permissions -rw-r--r--
[etwist] Do not call repository's start_looping_tasks anymore and warn about this We are about to drop this method from Repository class and replace it by a blocking alternative. This is not compatible with how things currently work in a Twisted server implementation. So do not start repository "looping tasks" in Twisted server anymore and issue a warning about this. If someone is interested in restoring the "all-in-one" behavior where the repository runs within a Twisted server, they may start by implementing repository looping tasks using a Twisted mechanism such as, e.g., http://twistedmatrix.com/documents/current/core/howto/time.html and eventually provide the repository with a compatible scheduler instance so that is can register its periodic tasks. At the moment, we lack resources to do this (and maintain the Twisted server of CubicWeb in general). Related to #17057223.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     1
Quick start
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     2
===========
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     3
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
     4
.. highlight:: bash
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     5
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
     6
Prerequites
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
     7
-----------
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     8
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     9
-   Install everything (here with pip, possibly in a virtualenv)::
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    10
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    11
        pip install pyramid-cubicweb cubicweb-pyramid pyramid_debugtoolbar
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    12
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    13
-   Have a working Cubicweb instance, for example:
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    14
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    15
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    16
    -   Make sure CubicWeb is in user mode::
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    17
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    18
            export CW_MODE=user
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    19
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    20
    -   Create a CubicWeb instance, and install the 'pyramid' cube on it (see
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    21
        :ref:`configenv` for more details on this step)::
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    22
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    23
            cubicweb-ctl create pyramid myinstance
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    24
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    25
-   Edit your ``~/etc/cubicweb.d/myinstance/all-in-one.conf`` and set values for
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    26
    :confval:`pyramid-auth-secret` and :confval:`pyramid-session-secret`.
11631
faf279e33298 Merge with pyramid-cubicweb
Yann Voté <yann.vote@logilab.fr>
parents: 11587
diff changeset
    27
    *required if cubicweb.pyramid.auth and pyramid_cubiweb.session get
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    28
    included, which is the default*
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    29
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    30
From CubicWeb
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    31
-------------
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    32
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    33
-   Start the instance with the :ref:`'pyramid' command <cubicweb-ctl_pyramid>`
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    34
    instead of 'start'::
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    35
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    36
        cubicweb-ctl pyramid --debug myinstance
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    37
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    38
In a pyramid application
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    39
------------------------
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    40
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    41
-   Create a pyramid application
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    42
11631
faf279e33298 Merge with pyramid-cubicweb
Yann Voté <yann.vote@logilab.fr>
parents: 11587
diff changeset
    43
-   Include cubicweb.pyramid:
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    44
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    45
    .. code-block:: python
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    46
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    47
        def includeme(config):
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    48
            # ...
11631
faf279e33298 Merge with pyramid-cubicweb
Yann Voté <yann.vote@logilab.fr>
parents: 11587
diff changeset
    49
            config.include('cubicweb.pyramid')
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    50
            # ...
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    51
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    52
-   Configure the instance name (in the .ini file):
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    53
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    54
    .. code-block:: ini
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    55
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    56
        cubicweb.instance = myinstance
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    57
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    58
-   Configure the base-url and https-url in all-in-one.conf to match the ones
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    59
    of the pyramid configuration (this is a temporary limitation).
11945
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    60
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    61
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    62
Usage with pserve
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    63
-----------------
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    64
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    65
To run a Pyramid application using pserve_:
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    66
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    67
::
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    68
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    69
    pserve /path/to/development.ini instance=<appid>
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    70
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    71
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    72
.. _pserve: \
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    73
    http://docs.pylonsproject.org/projects/pyramid/en/latest/pscripts/pserve.html