doc/book/en/intro/concepts/index.rst
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Fri, 19 Jun 2009 20:38:32 +0200
branchstable
changeset 2172 cf8f9180e63e
parent 1714 a721966779be
child 2175 16d3c37c5d28
permissions -rw-r--r--
delete-trailing-whitespace
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
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
     3
The Core Concepts of CubicWeb
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
     4
=============================
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
     5
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
     6
.. toctree::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
     7
   :maxdepth: 1
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
     8
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
     9
------------------------------
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    10
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    11
This section aims to provide you the keys of success with *CubicWeb*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    12
by clarifying the terms specific to our framework. If you want to do anything
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    13
serious with CubicWeb, you should understand concepts in those lines.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    14
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    15
*CubicWeb* defines its own terminology. To make sure there is no confusion
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    16
while reading this book, we strongly recommand you take time to go through
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    17
the following definitions that are the basics to understand while
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    18
developing with *CubicWeb*.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    19
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    20
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    21
.. _Cube:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    22
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    23
Cubes
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    24
-----
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    25
** Construct your application by assembling cubes **
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    26
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    27
A cube provides a specific functionality, or a complete *CubicWeb*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    28
application usually by assembling other cubes.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    29
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    30
It's usually composed of a data model, some logic to manipulate it and some parts
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    31
of web interface.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    32
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    33
You can decide to write your own set of cubes if you wish to re-use the
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    34
entity types you develop or/and if you have specific needs not covered by
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    35
cubes are available from the `CubicWeb Forge`_ under a free software license.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    36
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    37
Available cubes on your system are defined in the directory
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    38
:file:`/usr/share/cubicweb/cubes` when using a system wide installation.  For people
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    39
using the mercurial repository of cubicweb, the :file:`/path/to/forest/cubicweb/cubes`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    40
directory is used. You can specify additional location using the :envvar:`CW_CUBES_PATH`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    41
environment variable, using ':' as separator.
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
.. _`CubicWeb Forge`: http://www.cubicweb.org/project/
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    44
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    45
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    46
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    47
Instances
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    48
----------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    49
** *CubicWeb* framework is a server/client application framework**
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    50
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    51
An instance is a specific installation of one or multiple cubes. All the required
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    52
configuration files necessary for the well being of your web application are
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    53
grouped in an instance. This will refer to the cube(s) your application is based
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    54
on.  For example logilab.org and our intranet are two instances of a single cube
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    55
`jpl`
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    56
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    57
We recommand not to define schema, entities or views in the instance
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    58
file system itself but in the cube, in order to maintain re-usability of
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    59
entities and their views. We strongly recommand to develop cubes which
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    60
could be used in other instances (modular approach).
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    61
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    62
An instance usually usually consists into a web interface which is talking to a
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    63
rql repository, itself connected to a SQL database, all into a single
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    64
process. You can have some more complicated configurations using several web
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    65
front-ends talking to a rql repository using `Pyro`_, databases replication...
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    66
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    67
.. image:: ../../images/archi_globale.en.png
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    68
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    69
The term application is sometimes used to talk about an instance and sometimes to
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    70
talk of a cube depending on the context.  So we would like to avoid using this
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    71
term and try to use *cube* and *instance* instead.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    72
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    73
Data Repository
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    74
~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    75
The repository (Be carefull not to get confused with a Mercurial repository or a
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    76
debian repository!) manages all interactions with various data sources by
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    77
providing access to them using uniformly using the Relation Query Language (RQL).  The
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    78
web interface and the repository communicate using this language.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    79
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    80
Usually, the web server and repository sides are integrated in the same process and
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    81
interact directly, without the need for distant calls using Pyro. But, it is
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    82
important to note that those two sides, client/server, are disjointed and it is
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    83
possible to execute a couple of calls in distinct processes to balance the load
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    84
of your web site on one or more machines.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    85
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    86
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    87
A data source is a container of data integrated in the *CubicWeb* repository. A
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    88
repository has at least one source, named `system`, which contains the schema of
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    89
the application, plain-text index and other vital informations for the
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    90
system. You'll find source for SQL databases, LDAP servers, other RQL
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    91
repositories and even mercurial /svn repositories or `Google App Engine`'s
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    92
datastore.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    93
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    94
Web interface
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    95
~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    96
By default the web server provides a generated interface based on its schema.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    97
Entities can be created, displayed, updated and deleted. As display views are not
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    98
very fancy, it is usually necessary to develop your own.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    99
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   100
Instances are defined on your system in the directory :file:`/etc/cubicweb.d` when
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   101
using a system wide installation.  For people using the mercurial repository of
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   102
cubicweb, the :file:`etc` directory is searched in the user home directory. You can
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   103
also specify an alternative directory using the :envvar:`CW_REGISTRY` environment
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   104
variable.
466
bef394c66f10 updated list of cubes in the doc
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 404
diff changeset
   105
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   106
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   107
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   108
Schema
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   109
------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   110
** *CubicWeb* is schema driven **
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   111
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   112
The schema describes the persistent data model using entities and
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   113
relations. It is modeled with a comprehensive language made of Python classes based on
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   114
the `yams`_ library.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   115
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   116
When you create a new cubicweb instance, the schema is stored in the database,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   117
and it will usually evolves as you upgrade cubicweb and used cubes.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   118
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   119
*CubicWeb* provides a certain number of system entities included
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   120
sytematically (necessary for the core of *CubicWeb*, notably the schema itself).
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   121
You will also find a library of cubes which defines more piece of schema for standard needs.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   122
necessary.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   123
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   124
*CubicWeb* add some metadata to every entity type, such as the eid (a global
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   125
  identifier, unique into an instance), entity's creation date...
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   126
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   127
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   128
Attributes may be of the following types:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   129
  `String`, `Int`, `Float`, `Boolean`, `Date`, `Time`, `Datetime`,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   130
  `Interval`, `Password`, `Bytes`.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   131
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   132
New in 3.2: RichString
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   133
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   134
see :ref:`yams.BASE_TYPES`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   135
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   136
Data level security is defined by setting permissions on entity and relation types.
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   137
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   138
A schema consist of parts detailed below.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   139
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   140
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   141
Entity type
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   142
~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   143
An *entity type* defines set of attributes and is used in some relations. It may
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   144
have some permissions telling who can read/add/update/delete entities of this type.
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
Relation type
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   147
~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   148
A *relation type* is used to define a semantic relation between two entity types.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   149
It may have some permissions telling who can read/add/delete relation of this type.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   150
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   151
In *CubicWeb* relations are ordered and binary: by convention we name the first
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   152
item of a relation the `subject` and the second the `object`.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   153
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   154
Relation definition
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   155
~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   156
A *relation definition* is a 3-uple (*subject entity type*, *relation type*, *object
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   157
entity type*), with an associated set of property such as cardinality, constraints...
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   158
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   159
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   160
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   161
Dynamic objects for reusable components
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   162
---------------------------------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   163
** Dynamic objects management or how CubicWeb provides really reusable components **
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   164
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   165
Application objects
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   166
~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   167
Beside a few core functionalities, almost every feature of the framework is
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   168
acheived by dynamic objects (`application objects` or `appobjects`) stored in a
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   169
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
   170
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
   171
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
   172
vregistry according to the context.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   173
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   174
Application objects are stored in the registry using a two level hierarchy :
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   175
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   176
  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
   177
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   178
The base class of appobjects is `AppRsetObject` (module `cubicweb.appobject`).
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   179
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   180
The `vregistry`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   181
~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   182
At startup, the `registry` or registers base, inspects a number of directories
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   183
looking for compatible classes definition. After a recording process, the objects
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   184
are assigned to registers so that they can be selected dynamically while the
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   185
application is running.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   186
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   187
Selectors
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
Each appobject has a selector, which is used to score how well it suits to a
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   190
given context by returning a score.  A score of 0 means the object doesn't apply
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   191
to the context. The score is used to choose the most pertinent object: the "more"
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   192
the appobject suits the context the higher the score.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   193
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   194
CubicWeb provides a set of basic selectors which may be parametrized and combined
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   195
using binary `&` and `|` operators to provide a custom selector (which can be
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   196
itself reused...).
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   197
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   198
There is 3 current ways to retreive some appobject from the repository:
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   199
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   200
* 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
   201
  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
   202
  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
   203
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   204
* get all appobjects applying to a context by specifying a registry.In
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   205
  that case, every objects with the a postive score are selected.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   206
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   207
* 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
   208
  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
   209
  object in that cell.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   210
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   211
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
   212
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
   213
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   214
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   215
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
   216
mode to let you know that the engine was not able to identify the view to
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   217
apply. This error is silented 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
   218
higher score is picked.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   219
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   220
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
   221
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   222
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
   223
``ObjectNotFound`` exception is raised.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   224
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   225
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
   226
properly defined.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   227
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   228
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   229
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   230
The RQL query language
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   231
----------------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   232
**No needs for a complicated ORM when you've a powerful query language**
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   233
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   234
All the persistant data in a CubicWeb application is retreived and modified by using the
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   235
Relation Query Language.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   236
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   237
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
   238
emphasize browsing relations.
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
db-api
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   241
~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   242
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
   243
XXX feed me
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   244
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   245
Result set
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   246
~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   247
XXX feed me
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   248
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   249
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   250
Views
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
** *CubicWeb* is data driven **
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   253
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   254
XXX feed me.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   255
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   256
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   257
Hooks
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   258
-----
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   259
** *CubicWeb* provides an extensible data repository **
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   260
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   261
XXX feed me.
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   262
466
bef394c66f10 updated list of cubes in the doc
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 404
diff changeset
   263
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   264
.. _`Python Remote Object`: http://pyro.sourceforge.net/
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   265
.. _`yams`: http://www.logilab.org/project/yams/