Changeset 3201

Show
Ignore:
Timestamp:
05/15/07 14:40:17 (2 years ago)
Author:
mscott
Message:

Example constraints, pass 1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/mscott/Constraints/trunk/constraints/schema/constraints_001.py

    r3200 r3201  
    33from schevo.schema import * 
    44schevo.schema.prep(locals()) 
     5 
     6from schevo.functional import all 
    57 
    68 
     
    1416 
    1517    _key(name) 
     18 
     19 
     20class Widget(E.Entity): 
     21 
     22    name = f.unicode() 
     23    sprocket_list = f.entity_list('Sprocket') 
     24 
     25    _key(name) 
     26 
     27    _constraints = [ 
     28        "all((sprocket.widget is self) for sprocket in self.sprocket_list)", 
     29        "len(self.sprocket_list) == self.sys.count('Sprocket', 'widget')", 
     30        ] 
     31 
     32 
     33class Sprocket(E.Entity): 
     34 
     35    name = f.unicode() 
     36    widget = f.entity('Widget') 
     37 
     38    _constraints = [ 
     39        "self in self.widget.sprocket_list", 
     40        ]