doc/book/en/development/entityclasses/data-as-objects.rst
changeset 4437 21f2e01fdd6a
parent 3283 4f53eb3f1331
child 4442 7bc0e4ed4109
equal deleted inserted replaced
4436:294e084f1263 4437:21f2e01fdd6a
    28     (the value is automatically recovered if necessary)
    28     (the value is automatically recovered if necessary)
    29 
    29 
    30 :Data handling:
    30 :Data handling:
    31 
    31 
    32   * `as_rset()`, converts the entity into an equivalent result set simulating the
    32   * `as_rset()`, converts the entity into an equivalent result set simulating the
    33      request `Any X WHERE X eid _eid_`
    33     ._cwuest `Any X WHERE X eid _eid_`
    34 
    34 
    35   * `complete(skip_bytes=True)`, executes a request that recovers all at once
    35   * `complete(skip_bytes=True)`, executes a._cwuest that recovers all at once
    36     all the missing attributes of an entity
    36     all the missing attributes of an entity
    37 
    37 
    38   * `get_value(name)`, returns the value associated to the attribute name given
    38   * `get_value(name)`, returns the value associated to the attribute name given
    39     in parameter
    39     in parameter
    40 
    40 
    52     given in the parameters on the current entity
    52     given in the parameters on the current entity
    53 
    53 
    54   * `delete()` allows to delete the entity
    54   * `delete()` allows to delete the entity
    55 
    55 
    56 
    56 
    57 Tne :class:`AnyEntity` class
    57 The :class:`AnyEntity` class
    58 ----------------------------
    58 ----------------------------
    59 
    59 
    60 To provide a specific behavior for each entity, we have to define a class
    60 To provide a specific behavior for each entity, we have to define a class
    61 inheriting from `cubicweb.entities.AnyEntity`. In general, we define this class
    61 inheriting from `cubicweb.entities.AnyEntity`. In general, we define this class
    62 in `mycube.entities` module (or in a submodule if we want to split code among
    62 in `mycube.entities` module (or in a submodule if we want to split code among
    88   * `dc_date(date_format=None)`, returns a unicode string corresponding to
    88   * `dc_date(date_format=None)`, returns a unicode string corresponding to
    89     the meta-data `Date` (update date by default)
    89     the meta-data `Date` (update date by default)
    90 
    90 
    91   * `dc_type(form='')`, returns a string to display the entity type by
    91   * `dc_type(form='')`, returns a string to display the entity type by
    92     specifying the preferred form (`plural` for a plural form)
    92     specifying the preferred form (`plural` for a plural form)
       
    93 
       
    94 
       
    95 Inheritance
       
    96 -----------
       
    97 
       
    98 When describing a data model, entities can inherit from other entities as is
       
    99 common in object-oriented programming.
       
   100 
       
   101 You have the possibility to adapt some entity attributes, as follow:
       
   102 
       
   103 .. sourcecode:: python
       
   104 
       
   105     from cubes.OTHER_CUBE import entities
       
   106     class EntityExample(entities.EntityExample):
       
   107         def dc_long_title(self):
       
   108             return '%s (%s)' % (self.name, self.description)
       
   109 
       
   110 Notice this is different than yams schema inheritance.
       
   111