server/test/data-schema2sql/schema/schema.py
changeset 10199 218c28bff695
child 10443 2d3834df64ab
equal deleted inserted replaced
10198:534efa7bfaeb 10199:218c28bff695
       
     1 # copyright 2004-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of yams.
       
     5 #
       
     6 # yams is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # yams is distributed in the hope that it will be useful, but WITHOUT ANY
       
    12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
       
    13 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with yams. If not, see <http://www.gnu.org/licenses/>.
       
    18 from yams.buildobjs import (EntityType, RelationDefinition, RelationType,
       
    19                             SubjectRelation, String, Int, Float, Date, Boolean)
       
    20 
       
    21 class Affaire(EntityType):
       
    22     sujet = String(maxsize=128)
       
    23     ref = String(maxsize=12)
       
    24 
       
    25     concerne = SubjectRelation('Societe')
       
    26     obj_wildcard = SubjectRelation('*')
       
    27     sym_rel = SubjectRelation('Person', symmetric=True)
       
    28     inline_rel = SubjectRelation('Person', inlined=True, cardinality='?*')
       
    29 
       
    30 class subj_wildcard(RelationDefinition):
       
    31     subject = '*'
       
    32     object = 'Affaire'
       
    33 
       
    34 
       
    35 class Person(EntityType):
       
    36     __unique_together__ = [('nom', 'prenom')]
       
    37     nom    = String(maxsize=64, fulltextindexed=True, required=True)
       
    38     prenom = String(maxsize=64, fulltextindexed=True)
       
    39     sexe   = String(maxsize=1, default='M')
       
    40     promo  = String(vocabulary=('bon','pasbon'))
       
    41     titre  = String(maxsize=128, fulltextindexed=True)
       
    42     adel   = String(maxsize=128)
       
    43     ass    = String(maxsize=128)
       
    44     web    = String(maxsize=128)
       
    45     tel    = Int(__permissions__={'read': (),
       
    46                                   'add': ('managers',),
       
    47                                   'update': ('managers',)})
       
    48     fax    = Int()
       
    49     datenaiss = Date()
       
    50     test   = Boolean()
       
    51     salary = Float()
       
    52     travaille = SubjectRelation('Societe',
       
    53                                 __permissions__={'read': (),
       
    54                                                  'add': (),
       
    55                                                  'delete': ('managers',),
       
    56                                                  })
       
    57 
       
    58     evaluee = SubjectRelation('Note')
       
    59 
       
    60 class Salaried(Person):
       
    61     __specializes_schema__ = True
       
    62 
       
    63 class Societe(EntityType):
       
    64     nom  = String(maxsize=64, fulltextindexed=True)
       
    65     web = String(maxsize=128)
       
    66     tel  = Int()
       
    67     fax  = Int()
       
    68     rncs = String(maxsize=32)
       
    69     ad1  = String(maxsize=128)
       
    70     ad2  = String(maxsize=128)
       
    71     ad3  = String(maxsize=128)
       
    72     cp   = String(maxsize=12)
       
    73     ville = String(maxsize=32)
       
    74 
       
    75     evaluee = SubjectRelation('Note')
       
    76 
       
    77 
       
    78 class Note(EntityType):
       
    79     date = String(maxsize=10)
       
    80     type = String(maxsize=1)
       
    81     para = String(maxsize=512)
       
    82 
       
    83 
       
    84 class pkginfo(EntityType):
       
    85     modname = String(maxsize=30, required=True)
       
    86     version = String(maxsize=10, required=True, default='0.1')
       
    87     copyright = String(required=True)
       
    88     license = String(vocabulary=('GPL', 'ZPL'))
       
    89     short_desc = String(maxsize=80, required=True)
       
    90     long_desc = String(required=True, fulltextindexed=True)
       
    91     author = String(maxsize=100, required=True)
       
    92     author_email = String(maxsize=100, required=True)
       
    93     mailinglist = String(maxsize=100)
       
    94     debian_handler = String(vocabulary=('machin', 'bidule'))
       
    95 
       
    96 
       
    97 class evaluee(RelationType):
       
    98     __permissions__ = {
       
    99         'read': ('managers',),
       
   100         'add': ('managers',),
       
   101         'delete': ('managers',),
       
   102         }
       
   103 
       
   104 class concerne(RelationDefinition):
       
   105     subject = 'Person'
       
   106     object = 'Affaire'
       
   107     __permissions__ = {
       
   108         'read': ('managers',),
       
   109         'add': ('managers',),
       
   110         'delete': ('managers',),
       
   111         }
       
   112