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