doc/book/en/A03a-concepts.en.txt
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 07 Jan 2009 14:42:43 +0100
changeset 345 31f88b2e3500
parent 301 e47150482ac1
child 403 ffc7dc7d2218
permissions -rw-r--r--
more translation and complements
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
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     3
Concepts
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     4
--------
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     5
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
     6
This section aims to provide you the keys of success with `CubicWeb`
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
     7
by clarifying the terms specific to our framework.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
     8
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     9
Global architecture
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    10
~~~~~~~~~~~~~~~~~~~
300
9c72b8684ed6 [doc] Switch graphic to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 296
diff changeset
    11
.. image:: images/archi_globale.en.png
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    12
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    13
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    14
`CubicWeb` framework is a server/client application framework. Those two 
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    15
parties communicates through RQL (`CubicWeb` query language implementation)
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    16
and ResultSet (which will be explained in :ref:`TermsVocabulary`).
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    17
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    18
The server manages all interactions with sources.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    19
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    20
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    21
.. note::
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    22
  For real, the client and server sides are integrated in the same
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    23
  process and interact directly, without the needs for distants
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    24
  calls using Pyro. It is important to note down that those two
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    25
  sides, client/server, are disjointed and it is possible to execute
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    26
  a couple of calls in distincts processes to balance the load of
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    27
  your web site on one or more machines.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    28
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    29
.. _TermsVocabulary:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    30
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    31
Terms and vocabulary
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    32
~~~~~~~~~~~~~~~~~~~~~
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    33
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    34
`CubicWeb` defines its own terminology. To make sure there is no confusion
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    35
while reading this book, we strongly recommand you take time to go through
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    36
the following definitions that are the basics to understand while
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    37
developing with `CubicWeb`.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    38
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    39
*schema*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    40
  The schema defines the data model of an application based on entities
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    41
  and relations, modeled with a comprehensive language made of Python
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    42
  classes based on `yams`_ library. This is the core piece
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    43
  of an application. It is initially defined in the file system and is
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    44
  stored in the database at the time an instance is created. `CubicWeb`
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    45
  provides a certain number of system entities included automatically as
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    46
  it is necessary for the core of `CubicWeb` and a library of
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    47
  cubes (which defined application entities) that can be explicitely 
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    48
  included if necessary.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    49
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    50
*entity type*
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    51
  An entity type is a set of attributes; the essential attribute of
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    52
  an entity is its key, named eid.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    53
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    54
*relation type*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    55
  Entities are linked to each others by relations. In `CubicWeb`
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    56
  relations are binary: by convention we name the first item of
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    57
  a relation the `subject` and the second the `object`.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    58
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    59
*final entity type*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    60
  Final types corresponds to the basic types such as string of characters,
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    61
  integers... Those types have a main property which is that they can
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    62
  only be used as `object` of a relation. The attributes of an entity
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    63
  (non final) are entities (finals).
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    64
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    65
*final relation type*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    66
  A relation is said final if its `object` is a final type. This is equivalent
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    67
  to an entity attribute.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    68
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    69
*relation definition*
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    70
  A relation definition is a 3-uple (subject entity type, relation type, object
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    71
  entity type), with an associated set of property such as cardinality, constraints...
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    72
  
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    73
*repository*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    74
  This is the RQL server side of `CubicWeb`. Be carefull not to get
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    75
  confused with a Mercurial repository or a debian repository.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    76
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    77
*source*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    78
  A data source is a container of data (SGBD, LDAP directory, `Google
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    79
  App Engine`'s datastore ...) integrated in the
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    80
  `CubicWeb` repository. This repository has at least one source, `system` which 
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    81
  contains the schema of the application, plain-text index and others
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    82
  vital informations for the system.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    83
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    84
*configuration*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    85
  It is possible to create differents configurations for an instance:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    86
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    87
  - ``repository`` : repository only, accessible for clients using Pyro
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    88
  - ``twisted`` : web interface only, access the repository using Pyro
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    89
  - ``all-in-one`` : web interface and repository in a single process. 
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    90
     The repository could be or not accessible using Pyro.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    91
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    92
*cube*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    93
  A cube is a model grouping one or multiple data types and/or views
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    94
  to provide a specific functionnality or a complete `CubicWeb` application
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
    95
  potentially using other cubes. The available cubes are located in the file
272
06077d56f2c4 [doc] Does not keep mercurial forest as the only reference for path description.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 229
diff changeset
    96
  system at `/path/to/forest/cubicweb/cubes` for a Mercurial forest installation,
06077d56f2c4 [doc] Does not keep mercurial forest as the only reference for path description.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 229
diff changeset
    97
  for a debian packages installation they will be located in 
06077d56f2c4 [doc] Does not keep mercurial forest as the only reference for path description.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 229
diff changeset
    98
  `/usr/share/cubicweb/cubes`.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    99
  Larger applications can be built faster by importing cubes,
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   100
  adding entities and relationships and overriding the
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   101
  views that need to display or edit informations not provided by
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   102
  cubes.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   103
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   104
*instance*
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   105
  An instance is a specific installation of one or multiple cubes. All the required 
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   106
  configuration files necessary for the well being of your web application
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   107
  are grouped in an instance. This will refer to the cube(s) your application
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   108
  is based on.
229
767ff7f5d5a7 [doc] Replace all : s/by example/for example/
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   109
  For example logilab.org and our intranet are two instances of a single
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   110
  cube jpl, developped internally.
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   111
  The instances are defined in the directory `/etc/cubicweb.d`.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   112
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   113
*application*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   114
  The term application is sometime used to talk about an instance
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   115
  and sometimes to talk of a cube depending on the context. 
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   116
  So we would like to avoid using this term and try to use *cube* and
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   117
  *instance* instead.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   118
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   119
*result set*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   120
  This object contains the results of an RQL query sent to the source
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   121
  and informations on the query.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   122
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   123
*Pyro*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   124
  `Python Remote Object`_, distributed objects system similar to Java's RMI
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   125
  (Remote Method Invocation), which can be used for the dialog between the web
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   126
  side of the framework and the RQL repository.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   127
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   128
*query language*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   129
  A full-blown query language named RQL is used to formulate requests
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   130
  to the database or any sources such as LDAP or `Google App Engine`'s 
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   131
  datastore.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   132
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   133
*views*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   134
  A view is applied to a `result set` to present it as HTML, XML,
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   135
  JSON, CSV, etc. Views are implemented as Python classes. There is no
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   136
  templating language.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   137
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   138
*generated user interface*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   139
  A user interface is generated on-the-fly from the schema definition:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   140
  entities can be created, displayed, updated and deleted. As display
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   141
  views are not very fancy, it is usually necessary to develop your
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   142
  own. Any generated view can be overridden by defining a new one with
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   143
  the same identifier.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   144
123
c5dd68070dea move registry details into their own chapter, add missing classmethod() for __select__ definition
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 120
diff changeset
   145
*rql*
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   146
 Relation Query Language in order to empasize the way of browsing relations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   147
 This query language is inspired by SQL but is highest level, its implementation
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   148
 generates SQL.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   149
123
c5dd68070dea move registry details into their own chapter, add missing classmethod() for __select__ definition
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 120
diff changeset
   150
 
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   151
.. _`Python Remote Object`: http://pyro.sourceforge.net/
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   152
.. _`yams`: http://www.logilab.org/project/yams/
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   153
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   154
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   155
`CubicWeb` engine
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   156
~~~~~~~~~~~~~~~~~
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   157
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   158
The engine in `CubicWeb` is a set of classes managing a set of objects loaded
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   159
dynamically at the startup of `CubicWeb` (*appobjects*). Those dynamics objects,
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   160
based on the schema or the library, are building the final application.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   161
The differents dymanic components are for example:
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   162
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   163
* client and server side
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   164
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   165
  - entities definition, containing the logic which enables application data manipulation
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   166
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   167
* client side
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   168
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   169
  - *views*, or more specifically
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   170
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   171
    - boxes
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   172
    - header and footer
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   173
    - forms
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   174
    - page templates
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   175
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   176
  - *actions*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   177
  - *controllers*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   178
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   179
* server side
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   180
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   181
  - notification hooks
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   182
  - notification views
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   183
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   184
The components of the engine are:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   185
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   186
* a frontal web (only twisted is available so far), transparent for dynamic objects
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   187
* an object that encapsulates the configuration
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   188
* a `registry` (`cubicweb.cwvreg`) containing the dynamic objects loaded automatically
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   189
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   190
Every *appobject* may access to the instance configuration using its *config* attribute
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   191
and to the registry using its *vreg* attribute.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   192
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   193
API Python/RQL
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   194
~~~~~~~~~~~~~~
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   195
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   196
The Python API developped to interface with RQL is inspired from the standard db-api,
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   197
with a Connection object having the methods cursor, rollback and commit essentially. 
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   198
The most important method is the `execute` method of a cursor :
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   199
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   200
`execute(rqlstring, args=None, eid_key=None, build_descr=True)`
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   201
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   202
:rqlstring: the RQL query to execute (unicode)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   203
:args: if the query contains substitutions, a dictionnary containing the values to use
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   204
:eid_key: 
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   205
   an implementation detail of the RQL queries cache implies that if a substitution
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   206
   is used to introduce an eid *susceptible to raise the ambiguities in the query
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   207
   type resolution*, then we have to specify the correponding key in the dictionnary
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   208
   through this argument
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   209
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   210
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   211
The `Connection` object owns the methods `commit` and `rollback`. You *should
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   212
never need to use them* during the development of the web interface based on
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   213
the `CubicWeb` framework as it determines the end of the transaction depending 
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   214
on the query execution success.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   215
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   216
.. note::
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   217
  While executing updates queries (SET, INSERT, DELETE), if a query generates
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   218
  an error related to security, a rollback is automatically done on the current
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   219
  transaction.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   220
  
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   221
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   222
The `Request` class (`cubicweb.web`)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   223
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   224
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   225
A request instance is created when an HTTP request is sent to the web server.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   226
It contains informations such as forms parameters, user authenticated, etc.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   227
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   228
**Globally, a request represents a user query, either through HTTP or not
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   229
(we also talk about RQL queries on the server side for example).**
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   230
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   231
An instance of `Request` has the following attributes:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   232
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   233
* `user`, instance of `cubicweb.common.utils.User` corresponding to the authenticated
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   234
  user
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   235
* `form`, dictionnary containing the values of a web form
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   236
* `encoding`, characters encoding to use in the response
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   237
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   238
But also:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   239
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   240
:Session data handling:
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   241
  * `session_data()`, returns a dictionnary containing all the session data
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   242
  * `get_session_data(key, default=None)`, returns a value associated to the given
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   243
    key or the value `default` if the key is not defined
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   244
  * `set_session_data(key, value)`, assign a value to a key
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   245
  * `del_session_data(key)`,  suppress the value associated to a key
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   246
    
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   247
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   248
:Cookies handling:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   249
  * `get_cookie()`, returns a dictionnary containing the value of the header
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   250
    HTTP 'Cookie'
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   251
  * `set_cookie(cookie, key, maxage=300)`, adds a header HTTP `Set-Cookie`,
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   252
    with a minimal 5 minutes length of duration by default (`maxage` = None
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   253
    returns a *session* cookie which will expire when the user closes the browser
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   254
    window)
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   255
  * `remove_cookie(cookie, key)`, forces a value to expire
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   256
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   257
:URL handling:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   258
  * `url()`, returns the full URL of the HTTP request
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   259
  * `base_url()`, returns the root URL of the web application
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   260
  * `relative_path()`, returns the relative path of the request
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   261
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   262
:And more...:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   263
  * `set_content_type(content_type, filename=None)`, adds the header HTTP
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   264
    'Content-Type'
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   265
  * `get_header(header)`, returns the value associated to an arbitrary header
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   266
    of the HTTP request
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   267
  * `set_header(header, value)`, adds an arbitrary header in the response
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   268
  * `cursor()` returns a RQL cursor on the session
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   269
  * `execute(*args, **kwargs)`, shortcut to ``.cursor().execute()``
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   270
  * `property_value(key)`, properties management (`EProperty`)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   271
  * dictionnary `data` to store data to share informations between components
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   272
    *while a request is executed*
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   273
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   274
Please note that this class is abstract and that a concrete implementation
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   275
will be provided by the *frontend* web used (in particular *twisted* as of
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   276
today). For the views or others that are executed on the server side,
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   277
most of the interface of `Request` is defined in the session associated
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   278
to the client.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   279
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   280
The `AppObject` class
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   281
~~~~~~~~~~~~~~~~~~~~~
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   282
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   283
In general:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   284
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   285
* we do not inherit directly from this class but from a more specific
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   286
  class such as `AnyEntity`, `EntityView`, `AnyRsetView`,
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   287
  `Action`...
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   288
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   289
* to be recordable, a subclass has to define its own register (attribute
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   290
  `__registry__`) and its identifier (attribute `id`). Usually we do not have
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   291
  to take care of the register, only the identifier `id`.
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   292
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   293
We can find a certain number of attributes and methods defined in this class 
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   294
and common to all the application objects.
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   295
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   296
At the recording, the following attributes are dynamically added to
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   297
the *subclasses*:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   298
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   299
* `vreg`, the `vregistry` of the application
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   300
* `schema`, the application schema
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   301
* `config`, the application configuration
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   302
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   303
We also find on instances, the following attributes:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   304
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   305
* `req`, `Request` instance
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   306
* `rset`, the *result set* associated to the object if necessary
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   307
* `cursor`, rql cursor on the session
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   308
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   309
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   310
:URL handling:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   311
  * `build_url(method=None, **kwargs)`, returns an absolute URL based on
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   312
    the given arguments. The *controller* supposed to handle the response,
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   313
    can be specified through the special parameter `method` (the connection
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   314
    is theoretically done automatically :).
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   315
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   316
  * `datadir_url()`, returns the directory of the application data
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   317
    (contains static files such as images, css, js...)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   318
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   319
  * `base_url()`, shortcut to `req.base_url()`
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   320
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   321
  * `url_quote(value)`, version *unicode safe* of the function `urllib.quote`
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   322
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   323
:Data manipulation:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   324
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   325
  * `etype_rset(etype, size=1)`, shortcut to `vreg.etype_rset()`
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   326
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   327
  * `eid_rset(eid, rql=None, descr=True)`, returns a *result set* object for
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   328
    the given eid
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   329
  * `entity(row, col=0)`, returns the entity corresponding to the data position
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   330
    in the *result set* associated to the object
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   331
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   332
  * `complete_entity(row, col=0, skip_bytes=True)`, is equivalent to `entity` but
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   333
    also call the method `complete()` on the entity before returning it
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   334
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   335
:Data formatting:
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   336
  * `format_date(date, date_format=None, time=False)` returns a string for a 
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   337
    mx date time according to application's configuration
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   338
  * `format_time(time)` returns a string for a mx date time according to
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   339
    application's configuration
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   340
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   341
:And more...:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   342
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   343
  * `external_resource(rid, default=_MARKER)`, access to a value defined in the
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   344
    configuration file `external_resource`
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   345
    
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   346
  * `tal_render(template, variables)`, renders a precompiled page template with 
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   347
    variables in the given dictionary as context
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   348
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   349
.. note::
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   350
  When we inherit from `AppObject` (even not directly), you *always* have to use
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   351
  **super()** to get the methods and attributes of the superclasses, and not
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   352
  use the class identifier.
229
767ff7f5d5a7 [doc] Replace all : s/by example/for example/
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   353
  For example, instead of writting: ::
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   354
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   355
      class Truc(PrimaryView):
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   356
          def f(self, arg1):
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   357
              PrimaryView.f(self, arg1)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   358
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   359
  You'd better write: ::
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   360
  
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   361
      class Truc(PrimaryView):
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   362
          def f(self, arg1):
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   363
              super(Truc, self).f(arg1)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   364
280
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   365
.. _cubesConcepts:
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   366
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   367
Cubes
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   368
~~~~~
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   369
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   370
What is a cube ?
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   371
````````````````
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   372
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   373
A cube is a model grouping one or more entity types and/or views associated
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   374
in order to provide a specific feature or even a complete application using
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   375
others cubes.
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   376
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   377
You can decide to write your own set of cubes if you wish to re-use the 
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   378
entity types you develop. Lots of cubes are available from the `CubicWeb
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   379
Forge`_ under a free software license.
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   380
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   381
.. _`CubicWeb Forge`: http://www.cubicweb.org/project/
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   382
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   383
.. _foundationsCube:
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   384
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   385
Standard structure for a cube
280
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   386
`````````````````````````````
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   387
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   388
A complex cube is structured as follows:
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   389
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   390
::
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   391
  
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   392
  mycube/
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   393
  |
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   394
  |-- data/
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   395
  |   |-- cubes.mycube.css
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   396
  |   |-- cubes.mycube.js  
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   397
  |   `-- external_resources
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   398
  |
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   399
  |-- debian/
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   400
  |   |-- changelog
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   401
  |   |-- compat
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   402
  |   |-- control
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   403
  |   |-- copyright
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   404
  |   |-- cubicweb-mycube.prerm
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   405
  |   `-- rules
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   406
  |
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   407
  |-- entities.py
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   408
  |
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   409
  |-- i18n/
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   410
  |   |-- en.po
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   411
  |   `-- fr.po
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   412
  |
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   413
  |-- __init__.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   414
  |
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   415
  |-- MANIFEST.in
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   416
  |
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   417
  |-- migration/
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   418
  |   |-- postcreate.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   419
  |   `-- precreate.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   420
  |
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   421
  |-- __pkginfo__.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   422
  |
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   423
  |-- schema.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   424
  |
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   425
  |-- setup.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   426
  |
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   427
  |-- site_cubicweb.py
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   428
  |
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   429
  |-- sobjects.py
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   430
  |
296
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   431
  |-- test/
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   432
  |   |-- data/
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   433
  |   |   `-- bootstrap_cubes
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   434
  |   |-- pytestconf.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   435
  |   |-- realdb_test_mycube.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   436
  |   `-- test_mycube.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   437
  |
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   438
  `-- views.py
65564e83853e [doc] Moves cube description from tutoriel to foundations.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 280
diff changeset
   439
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   440
    
229
767ff7f5d5a7 [doc] Replace all : s/by example/for example/
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   441
We can use simple Python module instead of packages, for example: 
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   442
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   443
::
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   444
  
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   445
  mycube/
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   446
  |
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   447
  |-- entities.py
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   448
  |-- hooks.py
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   449
  \-- views.py
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   450
    
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   451
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   452
where :
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   453
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   454
* ``schema`` contains the schema definition (server side only)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   455
* ``entities`` contains the entities definition (server side and web interface)
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   456
* ``sobjects`` contains hooks and/or views notifications (server side only)
280
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   457
* ``views`` contains the web interface components (web interface only)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   458
* ``test`` contains tests related to the application (not installed)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   459
* ``i18n`` contains messages catalogs for supported languages (server side and
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   460
  web interface)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   461
* ``data`` contains data files for static content (images, css, javascripts)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   462
  ...(web interface only)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   463
* ``migration`` contains initialization file for new instances (``postcreate.py``)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   464
  and a file containing dependencies of the component depending on the version
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   465
  (``depends.map``)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   466
* ``debian`` contains all the files managing debian packaging (you will find
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   467
  the usual files ``control``, ``rules``, ``changelog``... not installed)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   468
* file ``__pkginfo__.py`` provides component meta-data, especially the distribution
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   469
  and the current version (server side and web interface) or sub-cubes used by
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   470
  the cube.
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   471
 
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   472
 
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   473
At least you should have:
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   474
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   475
* the file ``__pkginfo__.py``
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   476
* the schema definition
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   477
  XXX false, we may want to have cubes which are only adding a service, 
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 300
diff changeset
   478
  no persistent data (eg embeding for instance)
119
7a56ca431d65 [doc] missing file
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   479
280
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   480
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   481
Standard library
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   482
````````````````
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   483
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   484
A library of standard cubes are available from `CubicWeb Forge`_
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   485
Cubes provide entities and views.
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   486
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   487
The available application entities are:
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   488
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   489
* addressbook: PhoneNumber and PostalAddress
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   490
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   491
* basket: Basket (like a shopping cart)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   492
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   493
* blog: Blog (a *very* basic blog)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   494
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   495
* classfolder: Folder (to organize things but grouping them in folders)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   496
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   497
* classtags: Tag (to tag anything)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   498
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   499
* file: File (to allow users to upload and store binary or text files)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   500
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   501
* link: Link (to collect links to web resources)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   502
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   503
* mailinglist: MailingList (to reference a mailing-list and the URLs
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   504
  for its archives and its admin interface)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   505
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   506
* person: Person (easily mixed with addressbook)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   507
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   508
* task: Task (something to be done between start and stop date)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   509
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   510
* zone: Zone (to define places within larger places, for example a
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   511
  city in a state in a country)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   512
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   513
The available system entities are:
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   514
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   515
* comment: Comment (to attach comment threads to entities)
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   516
ce829abf7c29 [doc] Improved tutoriel. Moved appropriate content to cubicweb foundations chapter. Adds section to fill about cubicweb-ctl shell.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 272
diff changeset
   517