doc/tutorials/base/blog-in-five-minutes.rst
author Philippe Pepiot <ph@itsalwaysdns.eu>
Tue, 31 Mar 2020 19:15:03 +0200
changeset 12957 0c973204033a
parent 12922 3d3e34813d25
permissions -rw-r--r--
[server] prevent returning closed cursor to the database pool In since c8c6ad8 init_repository use repo.internal_cnx() instead of repo.system_source.get_connection() so it use the pool and we should not close cursors from the pool before returning it back. Otherwise we may have "connection already closed" error. This bug only trigger when connection-pool-size = 1. Since we are moving to use a dynamic pooler we need to get this fixed. This does not occur with sqlite since the connection wrapper instantiate new cursor everytime, but this occur with other databases.
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
12658
fdd7165fe1f3 [doc] Update documentation to match current Debian packages
Jérémy Bobbio <jeremy.bobbio@irq7.fr>
parents: 12530
diff changeset
    11
    python3-cubicweb, cubicweb-ctl, 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
12921
1adf23942954 [doc] Add requirement for gettext and graphviz
Elodie Thieblin <ethieblin@logilab.fr>
parents: 12658
diff changeset
    13
.. Note::
1adf23942954 [doc] Add requirement for gettext and graphviz
Elodie Thieblin <ethieblin@logilab.fr>
parents: 12658
diff changeset
    14
1adf23942954 [doc] Add requirement for gettext and graphviz
Elodie Thieblin <ethieblin@logilab.fr>
parents: 12658
diff changeset
    15
    You may also require extra Debian packages such as::
1adf23942954 [doc] Add requirement for gettext and graphviz
Elodie Thieblin <ethieblin@logilab.fr>
parents: 12658
diff changeset
    16
1adf23942954 [doc] Add requirement for gettext and graphviz
Elodie Thieblin <ethieblin@logilab.fr>
parents: 12658
diff changeset
    17
        gettext, graphviz
1adf23942954 [doc] Add requirement for gettext and graphviz
Elodie Thieblin <ethieblin@logilab.fr>
parents: 12658
diff changeset
    18
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    19
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
    20
:ref:`SourceInstallation` and :ref:`WindowsInstallation`).
4431
e597e0ca67cd Updated CW tutorial.
Adrien Chauve <adrien.chauve@logilab.fr>
parents: 4143
diff changeset
    21
12362
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    22
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
    23
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    24
   virtualenv venv
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    25
   source venv/bin/activate
12922
3d3e34813d25 [doc, blog tutorial] Remove cubicweb-dev from pip dependencies
Elodie Thieblin <ethieblin@logilab.fr>
parents: 12921
diff changeset
    26
   pip install cubicweb[pyramid] cubicweb-blog
12362
aa3581fc685c [doc] how to install pyramid or twisted application server
Laurent Peuch <cortex@worlddomination.be>
parents: 10491
diff changeset
    27
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2174
diff changeset
    28
Then create and initialize your instance::
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1715
diff changeset
    29
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
    30
    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
    31
12436
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    32
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
    33
`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
    34
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    35
.. Note::
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    36
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    37
   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
    38
   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
    39
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    40
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
    41
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
    42
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
    43
and configured (see :ref:`PostgresqlConfiguration`), it's highly recommended to
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    44
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
    45
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
    46
12530
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    47
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
    48
:ref:`pyramid_settings`.
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    49
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    50
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
    51
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
    52
12530
9d88e1177c35 Remove Twisted web server
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12491
diff changeset
    53
    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
    54
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    55
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
    56
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
    57
12436
d24f45087808 [doc] improve blog tutorial first steps and explain common errors
Laurent Peuch <cortex@worlddomination.be>
parents: 12362
diff changeset
    58
.. _AboutFileSystemPermissions:
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    59
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    60
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
    61
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    62
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    63
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
    64
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
    65
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
    66
environment variable: ::
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    67
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    68
  export CW_MODE=user
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    69
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    70
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
    71
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    72
More information about how to configure your own environment is
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    73
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
    74
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    75
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    76
Instance parameters
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    77
~~~~~~~~~~~~~~~~~~~
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
    78
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    79
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
    80
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
    81
:file:`/etc/cubicweb.d/myblog` directory.
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    82
5432
ee246e1813c6 [doc] various small improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5253
diff changeset
    83
Then relaunch the database creation::
4143
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    84
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    85
     cubicweb-ctl db-create myblog
e6d936eef7aa [mq]: doc
Charles Hébert
parents: 2175
diff changeset
    86
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    87
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
    88
: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
    89
6835
87e2641d75f7 [doc] major rework of the simple blog tutorial
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6833
diff changeset
    90
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
    91
6837
7562418985ef tutorial proof reading
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6835
diff changeset
    92
This is it. Your blog is functional and running. Visit http://localhost:8080 and enjoy it!