doc/book/en/intro/concepts/index.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 21 Jan 2010 17:03:30 +0100
changeset 4319 3b72c7e6149d
parent 3283 4f53eb3f1331
child 4437 21f2e01fdd6a
permissions -rw-r--r--
fix #636936: read_permission relation should not be mandatory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     2
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
     3
.. _Concepts:
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
     4
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
     5
The Core Concepts of CubicWeb
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
     6
=============================
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
     7
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
     8
This section defines some terms and core concepts of the *CubicWeb*
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
     9
framework. To avoid confusion while reading this book, take time to go through
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    10
the following definitions and use this section as a reference during your
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    11
reading.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    12
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    13
.. _Cube:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    14
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    15
Cubes
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    16
-----
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    17
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    18
A cube is a software component made of three parts: its data model
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    19
(:file:`schema`), its logic (:file:`entities`) and its user interface
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    20
(:file:`views`).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    21
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    22
A cube can use other cubes as building blocks and assemble them to provide
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    23
a whole with richer functionnalities than its parts. The cubes `cubicweb-blog`_
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    24
and `cubicweb-comment`_ could be used to make a cube named *myblog* with
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    25
commentable blog entries.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    26
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    27
The `CubicWeb Forge`_ offers a large number of cubes developed by the community
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    28
and available under a free software license.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    29
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    30
The command ``cubicweb-ctl list`` displays the list of cubes installed on your
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    31
system.
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    32
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    33
On a Unix system, the available cubes are usually stored in the directory
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    34
:file:`/usr/share/cubicweb/cubes`. During development, the cubes are commonly
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    35
found in the directory :file:`/path/to/cubicweb_forest/cubes`. The environment
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    36
variable :envvar:`CW_CUBES_PATH` gives additionnal locations where to search for
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    37
cubes.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    38
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    39
.. _`CubicWeb Forge`: http://www.cubicweb.org/project/
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    40
.. _`cubicweb-blog`: http://www.cubicweb.org/project/cubicweb-blog
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    41
.. _`cubicweb-comment`: http://www.cubicweb.org/project/cubicweb-comment
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    42
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    43
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    44
Instances
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    45
---------
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    46
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    47
An instance is a runnable application installed on a computer and based on a
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    48
cube.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    49
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    50
The instance directory contains the configuration files. Several instances can
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    51
be created and based on the same cube. For exemple, several software forges can
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    52
be set up on one computer system based on the `cubicweb-forge`_ cube.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    53
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    54
.. _`cubicweb-forge`: http://www.cubicweb.org/project/cubicweb-forge
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    55
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    56
Instances can be of three different types: all-in-one, web engine or data
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    57
repository. For applications that support high traffic, several web (front-end)
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    58
and data (back-end) instances can be set-up to share the load.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    59
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    60
.. image:: ../../images/archi_globale.en.png
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    61
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    62
The command ``cubicweb-ctl list`` also displays the list of instances
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    63
installed on your system.
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    64
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    65
On a Unix system, the instances are usually stored in the directory
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    66
:file:`/etc/cubicweb.d/`. During development, the :file:`~/etc/cubicweb.d/`
2445
6f065b366d14 rename environment variables
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2279
diff changeset
    67
directory is looked up, as well as the paths in :envvar:`CW_INSTANCES_DIR`
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    68
environment variable.
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    69
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    70
The term application is used to refer to "something that should do something as a
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2445
diff changeset
    71
whole", eg more like a project and so can refer to an instance or to a cube,
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2445
diff changeset
    72
depending on the context. This book will try to use *application*, *cube* and
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    73
*instance* as appropriate.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    74
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    75
Data Repository
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    76
---------------
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    77
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    78
The data repository [#]_ provides access to one or more data sources (including
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    79
SQL databases, LDAP repositories, Mercurial or Subversion version control
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    80
systems, other CubicWeb instance repositories, GAE's DataStore, etc).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    81
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    82
All interactions with the repository are done using the Relation Query Language
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    83
(RQL). The repository federates the data sources and hides them from the
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    84
querier, which does not realize when a query spans accross several data sources
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    85
and requires running sub-queries and merges to complete.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    86
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    87
It is common to run the web engine and the repository in the same process (see
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    88
instances of type all-in-one above), but this is not a requirement. A repository
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    89
can be set up to be accessed remotely using Pyro (`Python Remote Objects`_) and
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    90
act as a server.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    91
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    92
Some logic can be attached to events that happen in the repository, like
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    93
creation of entities, deletion of relations, etc. This is used for example to
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    94
send email notifications when the state of an object changes. See `Hooks` below.
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    95
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    96
.. _[#]: not to be confused with a Mercurial repository or a Debian repository.
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    97
.. _`Python Remote Objects`: http://pyro.sourceforge.net/
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    98
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    99
Web Engine
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   100
----------
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   101
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   102
The web engine replies to http requests and runs the user interface
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   103
and most of the application logic.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   104
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   105
By default the web engine provides a default user interface based on
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   106
the data model of the instance. Entities can be created, displayed,
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   107
updated and deleted. As the default user interface is not very fancy,
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   108
it is usually necessary to develop your own.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   109
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   110
Schema (Data Model)
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   111
-------------------
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   112
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   113
The data model of a cube is described as an entity-relationship schema using a
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   114
comprehensive language made of Python classes imported from the yams_ library.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   115
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   116
.. _yams: http://www.logilab.org/project/yams/
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   117
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   118
An `entity type` defines a set of attributes and is used in some relations.
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   119
Attributes may be of the following types: `String`, `Int`, `Float`, `Boolean`,
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   120
`Date`, `Time`, `Datetime`, `Interval`, `Password`, `Bytes`, `RichString`. See
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   121
:ref:`yams.BASE_TYPES` for details.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   122
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   123
A `relation type` is used to define an oriented binary relation between two
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   124
entity types.  The left-hand part of a relation is named the `subject` and the
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   125
right-hand part is named the `object`.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   126
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   127
A `relation definition` is a triple (*subject entity type*, *relation type*, *object
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   128
entity type*) associated with a set of properties such as cardinality,
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   129
constraints, etc.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   130
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   131
Permissions can be set on entity types and relation types to control who will be
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   132
able to create, read, update or delete entities and relations.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   133
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   134
Some meta-data necessary to the system is added to the data model. That includes
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   135
entities like users and groups, the entities used to store the data model
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   136
itself and attributes like unique identifier, creation date, creator, etc.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   137
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   138
When you create a new *CubicWeb* instance, the schema is stored in the database.
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   139
When the cubes the instance is based on evolve, they may change their data model
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   140
and provide migration scripts that will be executed when the administrator will
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   141
run the upgrade process for the instance.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   142
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   143
Registries and Objects
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   144
----------------------
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   145
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   146
Application objects
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   147
~~~~~~~~~~~~~~~~~~~
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   148
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   149
Beside a few core functionalities, almost every feature of the framework is
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   150
achieved by dynamic objects (`application objects` or `appobjects`) stored in a
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   151
two-levels registry (the `vregistry`). Each object is affected to a registry with
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   152
an identifier in this registry. You may have more than one object sharing an
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   153
identifier in the same registry, At runtime, appobjects are selected in the
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   154
vregistry according to the context.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   155
2535
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2476
diff changeset
   156
Application objects are stored in the registry using a two-level hierarchy :
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   157
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   158
  object's `__registry__` : object's `id` : [list of app objects]
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   159
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   160
The base class of appobjects is `AppObject` (module `cubicweb.appobject`).
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   161
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   162
The `vregistry`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   163
~~~~~~~~~~~~~~~
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   164
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   165
At startup, the `registry` inspects a number of directories looking
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   166
for compatible classes definition. After a recording process, the
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   167
objects are assigned to registers so that they can be selected
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   168
dynamically while the instance is running.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   169
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   170
Selectors
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   171
~~~~~~~~~
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   172
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   173
Each appobject has a selector, that is used to compute how well the object fits
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   174
a given context. The better the object fits the context, the higher the score.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   175
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   176
CubicWeb provides a set of basic selectors that may be parametrized. Selectors
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   177
can be combined with the binary operators `&` and `|` to build more complex
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   178
selector that can be combined too.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   179
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   180
There are three common ways to retrieve some appobject from the repository:
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   181
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   182
* get the most appropriate objects by specifying a registry and an identifier. In
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   183
  that case, the object with the greatest score is selected. There should always
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   184
  be a single appobject with a greater score than others.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   185
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   186
* get all appobjects applying to a context by specifying a registry. In
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   187
  that case, every object with the a postive score is selected.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   188
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   189
* get the object within a particular registry/identifier. In that case no
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   190
  selection process is involved, the vregistry will expect to find a single
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   191
  object in that cell.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   192
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   193
Selector sets are the glue that tie views to the data model. Using them
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   194
appropriately is an essential part of the construction of well behaved cubes.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   195
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   196
When no score is higher than the others, an exception is raised in development
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   197
mode to let you know that the engine was not able to identify the view to
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   198
apply. This error is silenced in production mode and one of the objects with the
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   199
higher score is picked.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   200
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   201
If no object has a positive score, ``NoSelectableObject`` exception is raised.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   202
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   203
If no object is found for a particular registry and identifier,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   204
``ObjectNotFound`` exception is raised.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   205
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   206
In such cases you would need to review your design and make sure your views are
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   207
properly defined.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   208
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   209
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   210
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   211
The RQL query language
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   212
----------------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   213
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   214
**No need for a complicated ORM when you have a powerful query language**
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   215
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2445
diff changeset
   216
All the persistent data in a CubicWeb instance is retrieved and modified by using the
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   217
Relation Query Language.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   218
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   219
This query language is inspired by SQL but is on a higher level in order to
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   220
emphasize browsing relations.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   221
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   222
db-api
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   223
~~~~~~
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   224
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   225
The repository exposes a `db-api`_ like api but using the RQL instead of SQL.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   226
XXX feed me
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   227
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   228
Result set
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   229
~~~~~~~~~~
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   230
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   231
Every request made (using RQL) to the data repository returns an
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   232
object we call a Result Set. It enables easy use of the retrieved
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   233
data, providing a translation layer between the backend's native
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   234
datatypes and *CubicWeb* schema's EntityTypes.
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   235
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   236
Result sets provide access to the raw data, yielding either basic
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   237
Python data types, or schema-defined high-level entities, in a
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   238
straightforward way.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   239
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   240
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   241
Views
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   242
-----
2279
b4e970513117 [doc] improve description of core concepts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   243
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   244
** *CubicWeb* is data driven **
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   245
3283
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3258
diff changeset
   246
The view system is loosely coupled to data through a selection
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3258
diff changeset
   247
system. Views are, in essence, defined by an id, a selection predicate
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3258
diff changeset
   248
and an entry point (generaly producing html).
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3258
diff changeset
   249
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   250
XXX feed me.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   251
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   252
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   253
Hooks
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   254
-----
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   255
** *CubicWeb* provides an extensible data repository **
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   256
3258
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   257
The data model defined using Yams types allows to express the data
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   258
model in a comfortable way. However several aspects of the data model
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   259
can not be expressed there. For instance:
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   260
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   261
* managing computed attributes
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   262
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   263
* enforcing complicated structural invariants
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   264
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   265
* real-world side-effects linked to data events (email notification
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   266
  being a prime example)
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   267
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   268
The hook system is much like the triggers of an SQL database engine,
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   269
except that:
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   270
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   271
* it is not limited to one specific SQL backend (every one of them
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   272
  having an idiomatic way to encode triggers), nor to SQL backends at
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   273
  all (think about LDAP or a Subversion repository)
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   274
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   275
* it is well-coupled to the rest of the framework
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   276
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   277
Hooks are basically functions that dispatch on both:
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   278
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   279
* events : after/before add/update/delete on entities/relations
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   280
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   281
* entity or relation types
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   282
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   283
They are an essential building block of any moderately complicated
6536ee4f37f7 update the documentation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
   284
cubicweb application.