doc/book/pyramid/quickstart.rst
author Laurent Peuch <cortex@worlddomination.be>
Fri, 12 Apr 2019 11:54:42 +0200
changeset 12573 9b883489279f
parent 12097 78a5c6a64fad
permissions -rw-r--r--
DeprecationWarning: Please use assertEqual instead.
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
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
     9
Install the *pyramid* flavour of CubicWeb (here with pip, possibly in a
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    10
virtualenv):
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    11
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    12
::
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    13
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    14
        pip install cubicweb[pyramid]
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    15
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    16
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    17
Instance creation and running
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    18
-----------------------------
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    19
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    20
In *backwards compatible* mode
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    22
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    23
In this mode, you can simply create an instance of kind ``all-in-one`` with
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    24
the ``cubicweb-ctl create`` command. You'll then need to add a ``pyramid.ini``
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    25
file in your instance directory, see :ref:`pyramid_settings` for details about the
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    26
content of this file.
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    27
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    28
Start the instance with the :ref:`'pyramid' command <cubicweb-ctl_pyramid>`
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    29
instead of 'start':
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    30
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    31
::
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    32
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    33
    cubicweb-ctl pyramid --debug myinstance
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    34
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    35
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    36
Without *backwards compatibility*
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    37
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    38
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    39
In this mode, you can create an instance of kind ``pyramid`` as follow:
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    40
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    41
::
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    42
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    43
    cubicweb-ctl create -c pyramid <cube_name> <instance_name>
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    44
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    45
This will bootstrap a ``development.ini`` file typical of a Pyramid
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    46
application in the instance's directory. The new instance may then be launched
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    47
by any WSGI server, for instance with pserve_:
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    48
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    49
::
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    50
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    51
    pserve etc/cubicweb.d/<instance_name>/development.ini
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    52
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    53
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    54
In a pyramid application
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    55
~~~~~~~~~~~~~~~~~~~~~~~~
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    56
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    57
-   Create a pyramid application
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    58
11631
faf279e33298 Merge with pyramid-cubicweb
Yann Voté <yann.vote@logilab.fr>
parents: 11587
diff changeset
    59
-   Include cubicweb.pyramid:
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    60
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    61
    .. code-block:: python
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    62
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    63
        def includeme(config):
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    64
            # ...
11631
faf279e33298 Merge with pyramid-cubicweb
Yann Voté <yann.vote@logilab.fr>
parents: 11587
diff changeset
    65
            config.include('cubicweb.pyramid')
11587
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    66
            # ...
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    67
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    68
-   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
    69
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    70
    .. code-block:: ini
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    71
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    72
        cubicweb.instance = myinstance
18dd303225cd [doc] Document embedding in a pyramid app
Christophe de Vienne <christophe@unlish.com>
parents: 11585
diff changeset
    73
12097
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    74
-   Configure the base-url in all-in-one.conf to match the ones of the pyramid
78a5c6a64fad [doc] Update the "quickstart" page of pyramid documentation
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11945
diff changeset
    75
    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
    76
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    77
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    78
.. _pserve: \
ef6b18c56b5a [skeleton] Add an entry point and configuration for running a Pyramid application
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11631
diff changeset
    79
    http://docs.pylonsproject.org/projects/pyramid/en/latest/pscripts/pserve.html