doc/book/fr/sect_creation_instance.txt
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Thu, 13 Nov 2008 02:29:41 +0100
changeset 50 d642f43eb87d
parent 40 doc/devmanual_fr/sect_creation_instance.txt@0857f1fd76cf
permissions -rw-r--r--
brutal hg mv
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     2
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     3
===================================
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     4
Creation de votre premiere instance
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     5
===================================
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     6
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     7
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     8
Qu'est-ce qu'une instance?
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     9
==========================
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    10
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    11
Une instance CubicWeb consiste en un dossier situe dans ``~/etc/cubicweb.d``
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    12
qui permettra de lancer une application web. Une instance est cree a partir
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    13
d'un ou plusieurs cubes.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    14
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    15
Nous recommandons de ne pas definir de schema, entites ou vues dans l'instance 
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    16
meme si cela est possible dans un but de re-utilisabilite des entities et de leurs
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    17
vues. Nous conseillons plutot de developper des cubes qui pourront par la suite
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    18
etre utilises dans d'autres instances (approche modulaire).
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    19
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    20
L'instance n'est qu'un conteneur referrant a des cubes et a des parametres
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    21
des configuration de l'application web.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    22
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    23
Qu'est-ce qu'un cube?
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    24
=====================
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    25
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    26
Un cube definit des entities, leur vues, leur schemas et leur workflow 
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    27
dans un repertoire independant situe dans ``/path/to/forest/cubicweb/cubes/``.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    28
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    29
Lors de la creation d'une instance, vous avez la possibilite de lister
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    30
le ou les cubes que votre instance va utiliser. Utiliser un cube signifie
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    31
avoir a disposition dans votre instance les entites definies dans le schema
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    32
de votre cube ainsi que les vues et les workflows.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    33
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    34
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    35
.. note::
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    36
   Les commandes utilisees ci-apres sont detaillees dans la section
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    37
   dediee a :ref:`cubicweb-ctl`.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    38
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    39
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    40
Création d'un cube
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    41
==================
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    42
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    43
Commençons par créer un squelette qui nous servira de base au développement de
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    44
notre cube ou application ::
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    45
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    46
  cd ~/hg
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    47
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    48
  cubicweb-ctl newtemplate moncube
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    49
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    50
  # répondre aux questions
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    51
  hg init moncube
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    52
  cd moncube
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    53
  hg add .
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    54
  hg ci
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    55
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    56
A partir de là si tout va bien, votre cube devrait être affiché par
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    57
`cubicweb-ctl list` dans la section *Available components*, si ce n'est pas le cas
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    58
revoir la section :ref:`ConfigurationEnv`.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    59
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    60
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    61
Pour utiliser un cube, il faut le mentionner dans la variable
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    62
__use__ du fichier __pkginfo__ de l'application. Cette variable
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    63
contrôle à la fois le packaging de l'application (dépendances gérées
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    64
par les utilitaires système comme les outils APT) et les composants
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    65
effectivement utilisables lors de la création de la base
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    66
(import_erschema('Moncomposant') ne fonctionne pas sinon).
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    67
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    68
Création d'une instance de développement
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    69
========================================
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    70
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    71
Maintenant que nous avons notre squelette de modèle, on peut en créer une
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    72
instance afin de voir ce que tout ça donne dans un simple navigateur web.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    73
Nous allons utiliser une configuration `all-in-one` afin de simplifier les
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    74
choses ::
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    75
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    76
  cubicweb-ctl create -c all-in-one moncube moninstance
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    77
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    78
Une série de questions vont être posées, la réponse par défaut est généralement
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    79
suffisante. Vous pourrez de toute façon modifier la configuration par la suite
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    80
en éditant les fichiers générés. Lorsqu'un login/mot de passe d'accès au sgbd
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    81
vous est demandé, il est recommandé d'utiliser l'utilisateur créé lors de la
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    82
:ref:`ConfigurationPostgres`.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    83
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    84
Il est important de distinguer ici l'utilisateur utilisé pour accéder au sgbd,
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    85
et l'utilisateur utilisé pour s'authentifier dans l'application cubicweb. Lorsque
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    86
l'application cubicweb démarre, elle utilise le login/mot de passe sgdb pour
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    87
récupérer le schéma et gérer les transactions bas-niveau. En revanche, lorsque
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    88
`cubicweb-ctl create` vous demande un login/mot de passe `manager` pour cubicweb, il
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    89
s'agit d'un utilisateur qui sera créé dans l'application `cubicweb` pour pouvoir
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    90
s'y connecter dans un premier temps et l'administrer. Il sera par la suite possible
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    91
de créer des utilisateurs différents pour l'application.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    92
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    93
A l'issue de cette commande, la définition de votre instance se trouve dans
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    94
*~/etc/cubicweb.d/moninstance/*. Pour la lancer, il suffit de taper ::
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    95
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    96
  cubicweb-ctl start -D moninstance
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    97
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    98
L'option `-D` indique le *debug mode* : l'instance ne passe pas en mode serveur
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    99
et ne se déconnecte pas du terminal, ce qui simplifie le dépannage en cas de non
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   100
démarrage de l'instance. Vous pouvez ensuite allez voir ce que ça donne en
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   101
pointant votre navigateur sur l'url `http://localhost:8080` (le n° de port
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   102
dépend de votre configuration). Pour vous authentifier vous pouvez utiliser le
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   103
login/mot de passe administrateur que vous avez spécifié lors de la création de
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   104
l'instance.
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   105
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   106
Pour arrêter l'instance, un Ctrl-C dans la fenêtre où vous l'avez lancé
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   107
suffit. Si l'option `-D` a été omise, il faut taper ::
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   108
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   109
  cubicweb-ctl stop moninstance
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   110
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   111
Voilà, tout est en place pour démarrer le développement du modèle...
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   112
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   113
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   114
Utilisation de cubicweb-liveserver
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   115
----------------------------------
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   116
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   117
Afin de tester rapidement un nouveau cube, on peut également
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   118
utiliser le script `cubicweb-liveserver` qui permet de créer une
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   119
application en mémoire (utilisant une base de données SQLite par
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   120
défaut) et la rendre accessible via un serveur web::
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   121
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   122
  cubicweb-ctl live-server moncomposant
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   123
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   124
ou bien, pour utiliser une base de données existante (SQLite ou postgres)::
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   125
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   126
  cubicweb-ctl live-server -s monfichier_sources moncomposant
0857f1fd76cf Add link to installation in front page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
   127