doc/book/en/devrepo/datamodel/definition.rst
changeset 8125 7070250bf50d
parent 7797 a71618a75b53
child 9255 46f41c3e1443
equal deleted inserted replaced
8122:b5b0b341467a 8125:7070250bf50d
   183   only if you know that you will have to run numerous searches on the
   183   only if you know that you will have to run numerous searches on the
   184   value of this attribute.
   184   value of this attribute.
   185 
   185 
   186 * `default`: default value of the attribute. In case of date types, the values
   186 * `default`: default value of the attribute. In case of date types, the values
   187   which could be used correspond to the RQL keywords `TODAY` and `NOW`.
   187   which could be used correspond to the RQL keywords `TODAY` and `NOW`.
       
   188 
       
   189 * `metadata`: Is also accepted as an argument of the attribute contructor. It is
       
   190   not really an attribute property. see `Metadata`_ for details.
   188 
   191 
   189 Properties for `String` attributes:
   192 Properties for `String` attributes:
   190 
   193 
   191 * `fulltextindexed`: boolean indicating if the attribute is part of
   194 * `fulltextindexed`: boolean indicating if the attribute is part of
   192   the full text index (false by default) (*applicable on the type
   195   the full text index (false by default) (*applicable on the type
   565  denote a somewhat "protected" or "private" attribute.
   568  denote a somewhat "protected" or "private" attribute.
   566 
   569 
   567  In any case, identifiers starting with "CW" or "cw" are reserved for
   570  In any case, identifiers starting with "CW" or "cw" are reserved for
   568  internal use by the framework.
   571  internal use by the framework.
   569 
   572 
       
   573  .. _Metadata:
       
   574 
       
   575  Some attribute using the name of another attribute as prefix are considered
       
   576  metadata.  For example, if an EntityType have both a ``data`` and
       
   577  ``data_format`` attribute, ``data_format`` is view as the ``format`` metadata
       
   578  of ``data``. Later the :meth:`cw_attr_metadata` method will allow you to fetch
       
   579  metadata related to an attribute. There are only three valid metadata names:
       
   580  ``format``, ``encoding`` and ``name``.
       
   581 
   570 
   582 
   571 The name of the Python attribute corresponds to the name of the attribute
   583 The name of the Python attribute corresponds to the name of the attribute
   572 or the relation in *CubicWeb* application.
   584 or the relation in *CubicWeb* application.
   573 
   585 
   574 An attribute is defined in the schema as follows::
   586 An attribute is defined in the schema as follows::
   575 
   587 
   576     attr_name = attr_type(properties)
   588     attr_name = AttrType(*properties, metadata={})
   577 
   589 
   578 where `attr_type` is one of the type listed above and `properties` is
   590 where
   579 a list of the attribute needs to satisfy (see `Properties`_
   591 
   580 for more details).
   592 * `AttrType`: is one of the type listed in EntityType_,
       
   593 
       
   594 * `properties`: is a list of the attribute needs to satisfy (see `Properties`_
       
   595   for more details),
       
   596 
       
   597 * `metadata`: is a dictionary of meta attributes related to ``attr_name``.
       
   598   Dictionary keys are the name of the meta attribute. Dictionary values
       
   599   attributes objects (like the content of ``AttrType``). For each entry of the
       
   600   metadata dictionary a ``<attr_name>_<key> = <value>`` attribute is
       
   601   automaticaly added to the EntityType.  see `Metadata`_ section for details
       
   602   about valid key.
       
   603 
       
   604 
       
   605  ---
       
   606 
       
   607 While building your schema
   581 
   608 
   582 * it is possible to use the attribute `meta` to flag an entity type as a `meta`
   609 * it is possible to use the attribute `meta` to flag an entity type as a `meta`
   583   (e.g. used to describe/categorize other entities)
   610   (e.g. used to describe/categorize other entities)
   584 
   611 
   585 .. XXX the paragraph below needs clarification and / or moving out in
   612 .. XXX the paragraph below needs clarification and / or moving out in