schemas/base.py
changeset 6942 18bdddd3740f
parent 6882 b5e34836f84e
child 6944 0cf10429ad39
equal deleted inserted replaced
6941:9ed02daa7dbb 6942:18bdddd3740f
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
   258                         'read':   ('managers',),
   258                         'read':   ('managers',),
   259                         'update': ('managers',),
   259                         'update': ('managers',),
   260                         })
   260                         })
   261 
   261 
   262 
   262 
       
   263 ENTITY_MANAGERS_PERMISSIONS = {
       
   264     'read':   ('managers',),
       
   265     'add':    ('managers',),
       
   266     'update': ('managers',),
       
   267     'delete': ('managers',),
       
   268     }
       
   269 RELATION_MANAGERS_PERMISSIONS = {
       
   270     'read':   ('managers',),
       
   271     'add':    ('managers',),
       
   272     'delete': ('managers',),
       
   273     }
       
   274 
   263 class CWSourceHostConfig(EntityType):
   275 class CWSourceHostConfig(EntityType):
   264     __permissions__ = {
   276     __permissions__ = ENTITY_MANAGERS_PERMISSIONS
   265         'read':   ('managers',),
       
   266         'add':    ('managers',),
       
   267         'update': ('managers',),
       
   268         'delete': ('managers',),
       
   269         }
       
   270     __unique_together__ = [('match_host', 'cw_host_config_of')]
   277     __unique_together__ = [('match_host', 'cw_host_config_of')]
   271     match_host = String(required=True, maxsize=128,
   278     match_host = String(required=True, maxsize=128,
   272                         description=_('regexp matching host(s) to which this config applies'))
   279                         description=_('regexp matching host(s) to which this config applies'))
   273     config = String(required=True,
   280     config = String(required=True,
   274                     description=_('Source\'s configuration for a particular host. '
   281                     description=_('Source\'s configuration for a particular host. '
   280                         'update': ('managers',),
   287                         'update': ('managers',),
   281                         })
   288                         })
   282 
   289 
   283 
   290 
   284 class cw_host_config_of(RelationDefinition):
   291 class cw_host_config_of(RelationDefinition):
       
   292     __permissions__ = RELATION_MANAGERS_PERMISSIONS
   285     subject = 'CWSourceHostConfig'
   293     subject = 'CWSourceHostConfig'
   286     object = 'CWSource'
   294     object = 'CWSource'
   287     cardinality = '1*'
   295     cardinality = '1*'
   288     composite = 'object'
   296     composite = 'object'
   289     inlined = True
   297     inlined = True
   295         'delete': (),
   303         'delete': (),
   296         }
   304         }
   297     subject = '*'
   305     subject = '*'
   298     object = 'CWSource'
   306     object = 'CWSource'
   299     cardinality = '1*'
   307     cardinality = '1*'
       
   308     composite = 'object'
   300 
   309 
   301 class cw_support(RelationDefinition):
   310 class cw_support(RelationDefinition):
   302     subject = 'CWSource'
   311     subject = 'CWSource'
   303     object = ('CWEType', 'CWRType')
   312     object = ('CWEType', 'CWRType')
   304     constraints = [RQLConstraint('NOT O final TRUE')]
   313     constraints = [RQLConstraint('NOT O final TRUE')]