doc/book/en/devrepo/datamodel/definition.rst
changeset 10301 729f36a1bcfa
parent 10222 75d6096216d7
parent 10281 cc9eb88377f4
equal deleted inserted replaced
10276:ffb269e60348 10301:729f36a1bcfa
   242 * `BoundaryConstraint`: allows to specify a minimum and/or maximum value
   242 * `BoundaryConstraint`: allows to specify a minimum and/or maximum value
   243   on numeric types and date
   243   on numeric types and date
   244 
   244 
   245 .. sourcecode:: python
   245 .. sourcecode:: python
   246 
   246 
   247    from yams.constraints import BoundaryConstraint, TODAY
   247    from yams.constraints import BoundaryConstraint, TODAY, NOW, Attribute
   248    BoundaryConstraint('<=', TODAY())
   248 
       
   249    class DatedEntity(EntityType):
       
   250       start = Date(constraints=[BoundaryConstraint('>=', TODAY())])
       
   251       end = Date(constraints=[BoundaryConstraint('>=', Attribute('start'))])
       
   252 
       
   253    class Before(EntityType);
       
   254       last_time = DateTime(constraints=[BoundaryConstraint('<=', NOW())])
   249 
   255 
   250 * `IntervalBoundConstraint`: allows to specify an interval with
   256 * `IntervalBoundConstraint`: allows to specify an interval with
   251   included values
   257   included values
   252 
   258 
   253 .. sourcecode:: python
   259 .. sourcecode:: python
   257 
   263 
   258 * `UniqueConstraint`: identical to "unique=True"
   264 * `UniqueConstraint`: identical to "unique=True"
   259 
   265 
   260 * `StaticVocabularyConstraint`: identical to "vocabulary=(...)"
   266 * `StaticVocabularyConstraint`: identical to "vocabulary=(...)"
   261 
   267 
   262 .. XXX Attribute, NOW
   268 Constraints can be dependent on a fixed value (90, Date(2015,3,23)) or a variable.
       
   269 In this second case, yams can handle :
       
   270 
       
   271 * `Attribute`: compare to the value of another attribute.
       
   272 * `TODAY`: compare to the current Date.
       
   273 * `NOW`: compare to the current Datetime.
   263 
   274 
   264 RQL Based Constraints
   275 RQL Based Constraints
   265 ......................
   276 ......................
   266 
   277 
   267 RQL based constraints may take three arguments. The first one is the ``WHERE``
   278 RQL based constraints may take three arguments. The first one is the ``WHERE``