doc/tutorials/base/blog-in-five-minutes.rst
author Denis Laxalde <denis.laxalde@logilab.fr>
Thu, 21 Mar 2019 14:33:54 +0100
changeset 12530 9d88e1177c35
parent 12491 540904e0ff0f
child 12658 fdd7165fe1f3
permissions -rw-r--r--
Remove Twisted web server Twisted web server is not used anymore and has been superseded by pyramid many years ago. Furthermore, our usage is not compatible with Python 3. So we drop the "etwist" sub-package. As a consequence, "all-in-one" configuration type gets dropped as it was Twisted-specific. We resurrect it in cubicweb/pyramid/config.py by only keeping options used by the "pyramid". Similarly, we introduce a AllInOneCreateHandler in cubicweb/pyramid/pyramidctl.py that is basically the one that lived in cubicweb/etwist/twctl.py and is used to create the "all-in-one" instance. Added a TODO here about "pyramid.ini" that could be generated at the end of bootstrap() method. In cubicweb/devtools/httptest.py, CubicWebServerTC is now equivalent to CubicWebWsgiTC and the latter is dropped.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     2
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
     3
.. _TutosBaseBlogFiveMinutes:
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     4
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2174
diff changeset
     5
Get a blog running in five minutes!
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2174
diff changeset
     6
-----------------------------------
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     7
6833
8fe4b003c1bc [doc] some ReST syntax fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5432
diff changeset
     8
For Debian or Ubuntu users, first install the following packages
8fe4b003c1bc [doc] some ReST syntax fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5432
diff changeset
     9
(:ref:`DebianInstallation`)::
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    10
12530
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    11
    cubicweb, cubicweb-dev, cubicweb-pyramid, cubicweb-blog
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    12
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    13
Windows or Mac OS X users must install |cubicweb| from source (see
6833
8fe4b003c1bc [doc] some ReST syntax fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5432
diff changeset
    14
:ref:`SourceInstallation` and :ref:`WindowsInstallation`).
4431
e597e0ca67cd Updated CW tutorial.
Adrien Chauve <adrien.chauve@logilab.fr>
parents: 4143
diff changeset
    15
12362
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    16
You can also install those packages using pip in a virtualenv::
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    17
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    18
   virtualenv venv
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    19
   source venv/bin/activate
12530
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    20
   pip install cubicweb[pyramid] cubicweb-dev cubicweb-blog
12362
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    21
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2174
diff changeset
    22
Then create and initialize your instance::
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1715
diff changeset
    23
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    24
    cubicweb-ctl create blog myblog
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    25
12436
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    26
The `blog` argument is the cube on which you want to base your instance and
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    27
`myblog` is the name of your instance.
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    28
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    29
.. Note::
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    30
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    31
   If you get an a permission error of this kind `OSError: [Errno 13]
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    32
   Permission denied: '/etc/cubicweb.d/myblog'`, read the :ref:`next section`.
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    33
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    34
You'll be asked a few questions, and you can keep the default answer for most of
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    35
them. The one question you'll have to think about is the database you'll want to
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    36
use for that instance. For a quick test, if you don't have `postgresql` installed
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    37
and configured (see :ref:`PostgresqlConfiguration`), it's highly recommended to
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    38
choose `sqlite` when asked for which database driver to use, since it has a much
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    39
simple setup (no database server needed).
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    40
12530
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    41
Then, you need to setup the CubicWeb Pyramid interface, as document at
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    42
:ref:`pyramid_settings`.
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    43
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    44
One the process is completed (including database initialisation), you can start
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    45
your instance by using: ::
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    46
12530
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    47
    cubicweb-ctl pyramid -D myblog
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    48
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    49
The `-D` option activates the debugging mode. Removing it will launch the instance
12530
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    50
as a daemon in the background.
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    51
12436
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    52
.. _AboutFileSystemPermissions:
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    53
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    54
About file system permissions
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    56
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    57
Unless you installed from sources, the above commands assume that you have root
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    58
access to the :file:`/etc/` directory. In order to initialize your instance as a
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    59
regular user, within your home directory, you can use the :envvar:`CW_MODE`
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    60
environment variable: ::
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    61
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    62
  export CW_MODE=user
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    63
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    64
then create a :file:`~/etc/cubicweb.d` directory that will hold your instances.
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    65
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    66
More information about how to configure your own environment is
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    67
available in :ref:`ResourceMode`.
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    68
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    69
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    70
Instance parameters
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    71
~~~~~~~~~~~~~~~~~~~
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    72
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    73
If you would like to change database parameters such as the database host or the
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    74
user name used to connect to the database, edit the `sources` file located in the
6833
8fe4b003c1bc [doc] some ReST syntax fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5432
diff changeset
    75
:file:`/etc/cubicweb.d/myblog` directory.
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    76
5432
ee246e1813c6 [doc] various small improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5253
diff changeset
    77
Then relaunch the database creation::
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    78
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    79
     cubicweb-ctl db-create myblog
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    80
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    81
Other parameters, like web server or emails parameters, can be modified in the
12436
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    82
:file:`/etc/cubicweb.d/myblog/all-in-one.conf` file (or :file:`~/etc/cubicweb.d/myblog/all-in-one.conf` depending on your configuration.)
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    83
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    84
You'll have to restart the instance after modification in one of those files.
1210
47a3eb4bbe66 [doc] Adds a short section on how to launch a blog based on the packages cubicweb and cubicweb-blog.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    85
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    86
This is it. Your blog is functional and running. Visit http://localhost:8080 and enjoy it!