doc/book/fr/01-introduction.fr.txt
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 12 Apr 2010 16:57:11 +0200
branchstable
changeset 5221 b851558456bb
parent 2789 39712da6f397
permissions -rw-r--r--
[doc/book] remove merged chapter
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     2
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     3
.. _Overview:
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     4
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
     5
Aperçu rapide de `CubicWeb`
49
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     6
===========================
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
     7
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
     8
`CubicWeb` nous permet de développer des instances d'applications web
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
     9
basées sur un ou plusieurs `cube`.
49
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    10
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
    11
Ce à quoi nous réferrons en parlant de `cube` est un modèle définissant
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
    12
des types de données et des vues. Un `cube` est un composant re-utilisable
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
    13
regroupé avec d'autres cubes sur le système de fichiers.
49
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    14
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
    15
Un `instance` réferre à une installation spécifique d'un ou plusieurs cubes
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
    16
où sont regroupés tous les fichiers de configuration de l'application web finale.
49
3d1f3e5246ff Improved first page.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    17
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
    18
Dans ce document, nous allons vous montrer comment créer un cube et l'utiliser
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
    19
dans une instance pour votre application web.
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    20
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    21
Créez votre cube
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    22
----------------
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    23
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    24
Après avoir installé votre environement de développement `CubicWeb`, vous pouvez
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    25
commencer à construire votre premier cube: ::
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    26
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    27
  cubicweb-ctl newcube blog
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    28
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    29
Cela va créer dans ``/path/to/forest/cubes`` une répertoire contenant ::
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    30
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    31
  blog/
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    32
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    33
  |-- data/
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    34
  |   |-- cubes.blog.css
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
    35
  |   |-- cubes.blog.js
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    36
  |   |-- external_resources
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    37
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    38
  |-- debian/
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    39
  |   |-- changelog
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    40
  |   |-- compat
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    41
  |   |-- control
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    42
  |   |-- copyright
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    43
  |   |-- cubicweb-blog.prerm
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    44
  |   |-- rules
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    45
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    46
  |-- entities.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    47
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    48
  |-- i18n/
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    49
  |   |-- en.po
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    50
  |   |-- fr.po
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    51
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    52
  |-- __init__.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    53
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    54
  |-- MANIFEST.in
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    55
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    56
  |-- migration/
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    57
  |   |-- postcreate.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    58
  |   |-- precreate.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    59
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    60
  |-- __pkginfo__.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    61
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    62
  |-- schema.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    63
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    64
  |-- setup.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    65
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    66
  |-- site_cubicweb.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    67
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    68
  |-- sobjects.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    69
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    70
  |-- test/
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    71
  |   |-- data/
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    72
  |       |-- bootstrap_cubes
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    73
  |   |-- pytestconf.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    74
  |   |-- realdb_test_blog.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    75
  |   |-- test_blog.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    76
  |
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    77
  |-- views.py
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    78
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    79
Toute modification apportée à votre modele de données devra
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
    80
etre effectué dans ce répertoire.
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    81
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    82
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    83
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    84
Définissez votre schéma de données
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    85
----------------------------------
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    86
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
    87
Le modèle de données ou schéma est au coeur d'une application `CubicWeb`.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
    88
C'est là où vous allez devoir définir le type de contenu que votre application
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
    89
devra gérer.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
    90
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    91
Votre modele de données est défini dans le fichier ``schema.py`` de votre cube
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    92
``blog`` comme suit.
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    93
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    94
::
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    95
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    96
  from cubicweb.schema import format_constraint
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    97
  class Blog(EntityType):
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    98
    title = String(maxsize=50, required=True)
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
    99
    description = String()
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   100
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   101
  class BlogEntry(EntityType):
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   102
    title = String(required=True, fulltextindexed=True, maxsize=256)
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   103
    publish_date = Date(default='TODAY')
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   104
    content = String(required=True, fulltextindexed=True)
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   105
    entry_of = SubjectRelation('Blog', cardinality='?*')
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   106
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   107
Un ``Blog`` a un titre et une description. Le titre est une chaîne
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   108
de caractères requise par la classe parente EntityType et ne doit
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   109
pas excéder 50 caractères. La description est une chaîne de
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   110
caractères sans contraintes.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   111
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   112
Une ``BlogEntry`` a un titre, une date de publication et du texte
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   113
étant son contenu. Le titre est une chaîne de caractères qui ne
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   114
doit pas excéder 100 caractères. La date de publication est de type Date et a
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   115
pour valeur par défaut TODAY, ce qui signifie que lorsqu'une
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   116
``BlogEntry`` sera créée, sa date de publication sera la date
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   117
courante a moins de modifier ce champ. Le texte est une chaîne de
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   118
caractères qui sera indexée en plein texte et sans contraintes.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   119
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   120
Une ``BlogEntry`` a aussi une relation nommée ``entry_of`` qui la
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   121
relie à un ``Blog``. La cardinalité ``?*`` signifie que BlogEntry
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   122
peut faire partie de zero a un Blog (``?`` signifie `zero ou un`) et
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   123
qu'un Blog peut avoir une infinité de BlogEntry (``*`` signifie
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   124
`n'importe quel nombre incluant zero`).
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   125
Par soucis de complétude, nous rappellerons que ``+`` signifie
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   126
`un ou plus`.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   127
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   128
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   129
Créez votre instance
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   130
--------------------
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   131
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   132
::
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   133
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   134
  cubicweb-ctl create blog blogdemo
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   135
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   136
Cette commande va créer un répertoire ``~/etc/cubicweb.d/blogdemo``
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   137
contenant tous les fichiers de configuration nécessaire au lancement
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   138
de votre application web.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   139
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   140
L'instance ``blogdemo`` est construite sur le cube ``blog``.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   141
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   142
Bienvenue dans votre application web
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   143
------------------------------------
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   144
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   145
Lancez votre application en exécutant : ::
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   146
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   147
  cubicweb-ctl start -D blogdemo
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   148
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   149
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   150
Vous pouvez à présent accéder  à votre application web vous permettant de
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   151
créer des blogs et d'y poster des messages en visitant l'URL http://localhost:8080/.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   152
Un premier formulaire d'authentification va vous être proposé. Par défaut,
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   153
l'application n'autorisera pas d'utilisateur anonyme à accéder a votre
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   154
application. Vous devrez donc utiliser l'utilisateur administrateur que
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   155
vous aurez crée lors de l'initialisation de votre base de données via
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   156
``cubicweb-ctl create``.
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   157
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   158
.. image:: images/login-form.png
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   159
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   160
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   161
Une fois authentifié, vous pouvez commencer à jouer avec votre
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   162
application et créer des entités. Bravo !
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   163
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   164
.. image:: images/blog-demo-first-page.png
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   165
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   166
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   167
Rappelez-vous que pour le moment, tout a été géré par la plate-forme
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   168
`CubicWeb` et que la seule chose qui a été fournie est le schéma de
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   169
données.
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   170
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   171
Créons des entités
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   172
------------------
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   173
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   174
Nous allons maintenant créer quelques entités dans notre application.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   175
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   176
Créez un Blog
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   177
~~~~~~~~~~~~~
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   178
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   179
Créons à présent quelques entités. Cliquez sur `[+]` sur la
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   180
droite du lien Blog. Appelez cette nouvelle entité Blog ``Tech-Blog``
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   181
et tapez pour la description ``everything about technology``,
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   182
puis validez le formulaire d'édition en cliquant sur le bouton
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   183
``Validate``.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   184
90
7fd4ffeb082b [doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 82
diff changeset
   185
.. image:: images/cbw-create-blog.fr.png
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   186
   :alt: from to create blog
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   187
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   188
En cliquant sur le logo situé dans le coin gauche de la fenêtre,
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   189
vous allez être redirigé vers la page d'accueil. Ensuite, si vous allez
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   190
sur le lien Blog, vous devriez voir la liste des entités Blog, en particulier
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   191
celui que vous venez juste de créer ``Tech-Blog``.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   192
90
7fd4ffeb082b [doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 82
diff changeset
   193
.. image:: images/cbw-list-one-blog.fr.png
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   194
   :alt: displaying a list of a single blog
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   195
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   196
Si vous cliquez sur ``Tech-Blog`` vous devriez obtenir une description
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   197
détaillée, ce qui dans notre cas, n'est rien de plus que le titre
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   198
et la phrase ``everything about technology``
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   199
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   200
Maintenant retournons sur la page d'accueil et créons un nouveau
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   201
Blog ``MyLife`` et retournons sur la page d'accueil, puis suivons
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   202
le lien Blog et nous constatons qu'à présent deux blogs sont listés.
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   203
90
7fd4ffeb082b [doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 82
diff changeset
   204
.. image:: images/cbw-list-two-blog.fr.png
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   205
   :alt: displaying a list of two blogs
71
69a4bf8f5e49 Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 54
diff changeset
   206
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   207
Créons un article
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   208
~~~~~~~~~~~~~~~~~
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   209
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   210
Revenons sur la page d'accueil et cliquons sur `[+]` à droite du lien
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   211
`articles`. Appellons cette nouvelle entité ``Hello World`` et introduisons
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   212
un peut de texte avant de ``Valider``. Vous venez d'ajouter un article
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   213
sans avoir précisé à quel Blog il appartenait. Dans la colonne de gauche
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   214
se trouve une boite intitulé ``actions``, cliquez sur le menu ``modifier``.
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   215
Vous êtes de retour sur le formulaire d'édition de l'article que vous
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   216
venez de créer, à ceci près que ce formulaire a maintenant une nouvelle
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   217
section intitulée ``ajouter relation``. Choisissez ``entry_of`` dans ce menu,
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   218
cela va faire apparaitre une deuxième menu déroulant dans lequel vous
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   219
allez pouvoir séléctionner le Blog ``MyLife``.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   220
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   221
Vous auriez pu aussi, au moment où vous avez crée votre article, sélectionner
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   222
``appliquer`` au lieu de ``valider`` et le menu ``ajouter relation`` serait apparu.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   223
90
7fd4ffeb082b [doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 82
diff changeset
   224
.. image:: images/cbw-add-relation-entryof.fr.png
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   225
   :alt: editing a blog entry to add a relation to a blog
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   226
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   227
Validez vos modifications en cliquant sur ``Valider``. L'entité article
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   228
qui est listée contient maintenant un lien vers le Blog auquel il
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   229
appartient, ``MyLife``.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   230
90
7fd4ffeb082b [doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 82
diff changeset
   231
.. image:: images/cbw-detail-one-blogentry.fr.png
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   232
   :alt: displaying the detailed view of a blogentry
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   233
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   234
Rappelez-vous que pour le moment, tout a été géré par la plate-forme
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   235
`CubicWeb` et que la seule chose qui a été fournie est le schéma de
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   236
données. D'ailleurs pour obtenir une vue graphique du schéma, visitez
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   237
le lien `Application schema`` a l'URL suivante :
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   238
http://localhost:8080/view?vid=schema
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   239
90
7fd4ffeb082b [doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 82
diff changeset
   240
.. image:: images/cbw-schema.fr.png
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   241
   :alt: graphical view of the schema (aka data-model)
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   242
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   243
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   244
Définissez les vues de vos données
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   245
----------------------------------
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   246
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   247
Le principe de sélection des vues
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   248
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   249
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   250
Une vue est une classe Python qui inclut:
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   251
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   252
  - un identifiant (tous les objets dans `CubicWeb` sont listés
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   253
    dans un registre et cet identifiant est utilisé comme la clé)
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   254
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   255
  - un filtre de sélection de `result sets` auxquels il
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   256
    peut s'appliquer
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   257
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   258
`CubicWeb` fournit un ensemble de vues standard pour le type d'objet
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   259
`EntityView`. vous poubez les trouver listées dans ``cubicweb/web/views``.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   260
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   261
Une vue est appliquée sur un `result set` qui représente l'ensemble
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   262
des entités que nous cherchons à appliquer. `CubicWeb` utilise un
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   263
sélecteur qui permet de calculer un score et d'identifier la vue
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   264
la plus adaptée au `result set` que nous voulons afficher. La librarie
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   265
standard des sélecteurs se trouve dans ``cubicweb.common.selector``
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   266
et une librairie des méthodes utilisées pour calculer les scores
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   267
est dans ``cubicweb.vregistry.vreq``.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   268
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   269
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   270
Il est possible de définir plusieurs vues ayant le meme identifiant
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   271
et d'y associer des sélecteurs et des filtres afin de permettre à
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   272
l'application de s'adapter au mieux aux données que nous avons
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   273
besoin d'afficher. Nous verrons cela plus en détails dans :ref:`DefinitionVues`.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   274
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   275
On peut citer l'exemple de la vue nommée ``primary`` qui est celle utilisée
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   276
pour visualiser une entité seule. Nous allons vous montrer comment modifier
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   277
cette vue.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   278
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   279
Modification des vues
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   280
~~~~~~~~~~~~~~~~~~~~~
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   281
Si vous souhaitez modifier la manière dont est rendue un article (`Blogentry`),
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   282
vous devez surcharger la vue ``primary`` définie dans le module ``views`` de
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   283
votre cube, ``cubes/blog/views.py``.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   284
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   285
Nous pourrions par exemple ajouter devant la date de publication un préfixe
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   286
indiquant que la date visualisée est la date de publication.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   287
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   288
Pour cela appliquez les modifications suivantes:
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   289
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   290
::
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   291
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   292
  from cubicweb.web.views import baseviews
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   293
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   294
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   295
  class BlogEntryPrimaryView(baseviews.PrimaryView):
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   296
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   297
    accepts = ('BlogEntry',)
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   298
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   299
    def render_entity_title(self, entity):
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   300
        self.w(u'<h1>%s</h1>' % html_escape(entity.dc_title()))
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   301
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   302
    def content_format(self, entity):
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   303
        return entity.view('reledit', rtype='content_format')
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   304
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   305
    def cell_call(self, row, col):
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   306
        entity = self.rset.get_entity(row, col)
54
e5cd878dc796 Add images folder to share images between book/fr and book/en.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 51
diff changeset
   307
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   308
        # display entity attributes with prefixes
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   309
        self.w(u'<h1>%s</h1>' % entity.title)
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   310
        self.w(u'<p>published on %s</p>' % entity.publish_date.strftime('%Y-%m-%d'))
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   311
        self.w(u'<p>%s</p>' % entity.content)
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   312
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   313
        # display relations
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   314
        siderelations = []
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   315
        if self.main_related_section:
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   316
            self.render_entity_relations(entity, siderelations)
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   317
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   318
.. note::
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   319
  Lors qu'une vue est modifiée il n'est pas nécessaire de relancer
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   320
  l'application. Sauvez juste le fichier Python et rechargez la page
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   321
  dans votre navigateur afin de visualiser les modifications.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   322
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   323
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   324
Nous pouvons voir que la date de publication est préfixée comme souhaitée.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   325
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   326
90
7fd4ffeb082b [doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 82
diff changeset
   327
.. image:: images/cbw-update-primary-view.fr.png
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   328
   :alt: modified primary view
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   329
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   330
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   331
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   332
Le code que nous avons modifié définit une vue primaire pour une entité de
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   333
type `BlogEntry`.
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   334
2789
39712da6f397 R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 93
diff changeset
   335
Etant donné que les vues sont appliquées sur des `result sets` et que
82
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   336
les `result sets` peuvent être des tableaux de données, il est indispensable
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   337
de récupérer l'entité selon ses coordonnées (row,col).
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   338
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   339
La méthode ``self.w()`` est utilisée pour afficher des données. En particulier
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   340
dans notre exemple, nous l'utilisons pour afficher des tags HTML et des valeurs
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   341
des attributs de notre entité.
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   342
57f37f7af21b Add more explanation on views in introduction.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 71
diff changeset
   343