server/test/data-schema2sql/schema/Company.py
author Rémi Cardona <remi.cardona@logilab.fr>
Fri, 18 Sep 2015 11:54:12 +0200
changeset 10706 b261d90149d0
parent 10199 218c28bff695
permissions -rw-r--r--
[server] Port BFSS to py3k The BFSS API changes in python 3: * 'defaultdir' MUST be a unicode object * 'fsencoding' MUST NOT be set In python 2, fsencoding handles both the encoding of file paths on the file system (utf-8 by default, but the system may actually be using something else) and the encoding of file paths that will be stored in the database. So in python 3, we wipe the slate clean: * rely on sys.getfilesystemencoding() to convert unicode objects to bytes * always encode paths to utf-8 for storage in the database Caveat emptor / here be dragons: * sys.getfilesystemencoding() depends on the current locale, which therefore MUST be set properly * when migrating an existing instance from py2 to py3, one MAY need to reencode file paths stored in the database
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
# copyright 2004-2010 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, RelationType, RelationDefinition, \
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    19
     SubjectRelation, String
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    20
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    21
class Company(EntityType):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    22
    name = String()
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    23
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    24
class Subcompany(Company):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    25
    __specializes_schema__ = True
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    26
    subcompany_of = SubjectRelation('Company')
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    27
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    28
class Division(Company):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    29
    __specializes_schema__ = True
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    30
    division_of = SubjectRelation('Company')
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    31
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    32
class Subdivision(Division):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    33
    __specializes_schema__ = True
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    34
    subdivision_of = SubjectRelation('Company')
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 Employee(EntityType):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    37
    works_for = SubjectRelation('Company')
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    38
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    39
class require_permission(RelationType):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    40
    """link a permission to the entity. This permission should be used in the
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    41
    security definition of the entity's type to be useful.
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    42
    """
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    43
    fulltext_container = 'subject'
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    44
    __permissions__ = {
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    45
        'read':   ('managers', 'users', 'guests'),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    46
        'add':    ('managers',),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    47
        'delete': ('managers',),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    48
        }
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    49
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    50
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    51
class missing_require_permission(RelationDefinition):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    52
    name = 'require_permission'
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    53
    subject = 'Company'
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    54
    object = 'EPermission'
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    55
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    56
class EPermission(EntityType):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    57
    """entity type that may be used to construct some advanced security configuration
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
    __permissions__ = {
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    60
        'read':   ('managers', 'users', 'guests',),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    61
        'add':    ('managers',),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    62
        'delete': ('managers',),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    63
        'update': ('managers', 'owners',),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    64
        }
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    65
    name = String(required=True, indexed=True, internationalizable=True,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    66
                  fulltextindexed=True, maxsize=100,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    67
                  description=_('name or identifier of the permission'))