doc/book/devrepo/entityclasses/data-as-objects.rst
author David Douard <david.douard@logilab.fr>
Tue, 24 Apr 2018 14:04:43 +0200
branch3.26
changeset 12420 1c0dce14c3b5
parent 10491 c67bcee93248
child 12556 d1c659d70368
permissions -rw-r--r--
[test/rset] flake8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     1
Access to persistent data
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
--------------------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
3283
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2476
diff changeset
     4
Python-level access to persistent data is provided by the
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2476
diff changeset
     5
:class:`Entity <cubicweb.entity>` class.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     6
5893
4469f85ace9f [doc] proof-reading and improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5879
diff changeset
     7
.. XXX this part is not clear. refactor it.
4469f85ace9f [doc] proof-reading and improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5879
diff changeset
     8
4469f85ace9f [doc] proof-reading and improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5879
diff changeset
     9
An entity class is bound to a schema entity type. Descriptors are added when
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    10
classes are registered in order to initialize the class according to its schema:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
5893
4469f85ace9f [doc] proof-reading and improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5879
diff changeset
    12
* the attributes defined in the schema appear as attributes of these classes
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
5893
4469f85ace9f [doc] proof-reading and improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5879
diff changeset
    14
* the relations defined in the schema appear as attributes of these classes,
4469f85ace9f [doc] proof-reading and improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5879
diff changeset
    15
  but are lists of instances
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    16
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    17
`Formatting and output generation`:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    18
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    19
* :meth:`view(__vid, __registry='views', **kwargs)`, applies the given view to the entity
10222
75d6096216d7 [docstrings] fix project-wide English language mistake
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents: 8492
diff changeset
    20
  (and returns a unicode string)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    21
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    22
* :meth:`absolute_url(*args, **kwargs)`, returns an absolute URL including the base-url
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    23
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    24
* :meth:`rest_path()`, returns a relative REST URL to get the entity
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    25
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    26
* :meth:`printable_value(attr, value=_marker, attrtype=None, format='text/html', displaytime=True)`,
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    27
  returns a string enabling the display of an attribute value in a given format
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    28
  (the value is automatically recovered if necessary)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    29
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    30
`Data handling`:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    31
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    32
* :meth:`as_rset()`, converts the entity into an equivalent result set simulating the
5893
4469f85ace9f [doc] proof-reading and improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5879
diff changeset
    33
  request `Any X WHERE X eid _eid_`
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    34
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    35
* :meth:`complete(skip_bytes=True)`, executes a request that recovers at
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    36
  once all the missing attributes of an entity
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    37
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    38
* :meth:`get_value(name)`, returns the value associated to the attribute name given
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    39
  in parameter
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    40
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    41
* :meth:`related(rtype, role='subject', limit=None, entities=False)`,
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    42
  returns a list of entities related to the current entity by the
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    43
  relation given in parameter
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    44
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    45
* :meth:`unrelated(rtype, targettype, role='subject', limit=None)`,
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    46
  returns a result set corresponding to the entities not (yet)
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    47
  related to the current entity by the relation given in parameter
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    48
  and satisfying its constraints
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    49
8483
4ba11607d84a [entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5893
diff changeset
    50
* :meth:`cw_set(**kwargs)`, updates entity's attributes and/or relation with the
4ba11607d84a [entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5893
diff changeset
    51
  corresponding values given named parameters. To set a relation where this
4ba11607d84a [entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5893
diff changeset
    52
  entity is the object of the relation, use `reverse_<relation>` as argument
4ba11607d84a [entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5893
diff changeset
    53
  name.  Values may be an entity, a list of entities, or None (meaning that all
4ba11607d84a [entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5893
diff changeset
    54
  relations of the given type from or to this object should be deleted).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    55
8483
4ba11607d84a [entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5893
diff changeset
    56
* :meth:`copy_relations(ceid)`, copies the relations of the entities having the eid
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    57
  given in the parameters on the current entity
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    58
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    59
* :meth:`cw_delete()` allows to delete the entity
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    60
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    61
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
    62
The :class:`AnyEntity` class
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    63
----------------------------
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    64
5879
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
    65
To provide a specific behavior for each entity, we can define a class
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    66
inheriting from `cubicweb.entities.AnyEntity`. In general, we define this class
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    67
in `mycube.entities` module (or in a submodule if we want to split code among
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    68
multiple files) so that it will be available on both server and client side.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    69
3283
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2476
diff changeset
    70
The class `AnyEntity` is a sub-class of Entity that add methods to it,
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2476
diff changeset
    71
and helps specializing (by further subclassing) the handling of a
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2476
diff changeset
    72
given entity type.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    73
5144
5a09bea07302 [doc/book] a new chapter on how to use the ORM
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4442
diff changeset
    74
Most methods defined for `AnyEntity`, in addition to `Entity`, add
5a09bea07302 [doc/book] a new chapter on how to use the ORM
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4442
diff changeset
    75
support for the `Dublin Core`_ metadata.
5a09bea07302 [doc/book] a new chapter on how to use the ORM
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4442
diff changeset
    76
5a09bea07302 [doc/book] a new chapter on how to use the ORM
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4442
diff changeset
    77
.. _`Dublin Core`: http://dublincore.org/
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    78
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    79
`Standard meta-data (Dublin Core)`:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    80
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    81
* :meth:`dc_title()`, returns a unicode string corresponding to the
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    82
  meta-data `Title` (used by default is the first non-meta attribute
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    83
  of the entity schema)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    84
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    85
* :meth:`dc_long_title()`, same as dc_title but can return a more
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    86
  detailed title
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    87
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    88
* :meth:`dc_description(format='text/plain')`, returns a unicode string
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    89
  corresponding to the meta-data `Description` (looks for a
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    90
  description attribute by default)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    91
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    92
* :meth:`dc_authors()`, returns a unicode string corresponding to the meta-data
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    93
  `Authors` (owners by default)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    94
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    95
* :meth:`dc_creator()`, returns a unicode string corresponding to the
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    96
  creator of the entity
5144
5a09bea07302 [doc/book] a new chapter on how to use the ORM
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4442
diff changeset
    97
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
    98
* :meth:`dc_date(date_format=None)`, returns a unicode string corresponding to
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    99
  the meta-data `Date` (update date by default)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   100
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
   101
* :meth:`dc_type(form='')`, returns a string to display the entity type by
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   102
  specifying the preferred form (`plural` for a plural form)
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   103
8492
8ec7cc28b501 [doc] use :meth: and remove doc to deprecated methods
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8483
diff changeset
   104
* :meth:`dc_language()`, returns the language used by the entity
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   105
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   106
Inheritance
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   107
-----------
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   108
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   109
When describing a data model, entities can inherit from other entities as is
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   110
common in object-oriented programming.
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   111
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   112
You have the possibility to redefine whatever pleases you, as follow:
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   113
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   114
.. sourcecode:: python
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   115
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   116
    from cubes.OTHER_CUBE import entities
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   117
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   118
    class EntityExample(entities.EntityExample):
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   119
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   120
        def dc_long_title(self):
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   121
            return '%s (%s)' % (self.name, self.description)
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   122
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   123
The most specific entity definition will always the one used by the
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   124
ORM. For instance, the new EntityExample above in mycube replaces the
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   125
one in OTHER_CUBE. These types are stored in the `etype` section of
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   126
the `vregistry`.
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
   127
5879
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   128
Notice this is different than yams schema inheritance, which is an
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   129
experimental undocumented feature.
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   130
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   131
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   132
Application logic
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   133
-----------------
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3283
diff changeset
   134
5879
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   135
While a lot of custom behaviour and application logic can be
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   136
implemented using entity classes, the programmer must be aware that
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   137
adding new attributes and method on an entity class adds may shadow
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   138
schema-level attribute or relation definitions.
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   139
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   140
To keep entities clean (mostly data structures plus a few universal
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   141
methods such as listed above), one should use `adapters` (see
7d3044271a29 [doc] update book for adapters
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5400
diff changeset
   142
:ref:`adapters`).