doc/book/en/development/devcore/dbapi.rst
branchstable
changeset 5190 73bdc50d6af1
parent 5189 84d4587a92bc
child 5257 a31fbcfa8c3b
equal deleted inserted replaced
5189:84d4587a92bc 5190:73bdc50d6af1
    59 .. sourcecode:: python
    59 .. sourcecode:: python
    60 
    60 
    61    self._cw.execute('Any T WHERE T in_conf C, C eid %(x)s', {'x': entity.eid})
    61    self._cw.execute('Any T WHERE T in_conf C, C eid %(x)s', {'x': entity.eid})
    62 
    62 
    63 The syntax tree is built once for the "generic" RQL and can be re-used
    63 The syntax tree is built once for the "generic" RQL and can be re-used
    64 with a number of different eids.
    64 with a number of different eids. There rql IN operator is an exception
       
    65 to this rule.
    65 
    66 
    66 Alternativelly, some of the common data related to an entity can be obtained from
    67 .. sourcecode:: python
    67 the top-level `entity.related()` method (which is used under the hood by the orm
    68 
    68 when you use attribute access notation on an entity to get a relation. The above
    69    self._cw.execute('Any T WHERE T in_conf C, C name IN (%s)' % ','.join(['foo', 'bar']))
    69 would then be translated to:
    70 
       
    71 Alternativelly, some of the common data related to an entity can be
       
    72 obtained from the `entity.related()` method (which is used under the
       
    73 hood by the orm when you use attribute access notation on an entity to
       
    74 get a relation. The initial request would then be translated to:
    70 
    75 
    71 .. sourcecode:: python
    76 .. sourcecode:: python
    72 
    77 
    73    entity.related('in_conf', 'object')
    78    entity.related('in_conf', 'object')
    74 
    79 
    75 The `related()` method, as more generally others orm methods, makes extensive use
    80 Additionnaly this benefits from the fetch_attrs policy eventually
    76 of the cache mechanisms so you don't have to worry about them. Additionnaly this
    81 defined on the class element, which says which attributes must be also
    77 use will get you commonly used attributes that you will be able to use in your
    82 loaded when the entity is loaded through the orm.
    78 view generation without having to ask the data backend.
       
    79