cubicweb/server/test/data-schema2sql/schema/schema.py
author Philippe Pepiot <ph@itsalwaysdns.eu>
Tue, 31 Mar 2020 18:22:05 +0200
changeset 12966 6cd938c29ca3
parent 11413 c172fa18565e
permissions -rw-r--r--
[server] Make connection pooler configurable and set better default values Drop the configuration connections-pool-size and add new configurations options: * connections-pool-min-size. Set to 0 by default so we open connections only when needed. This avoid opening min-size*processes connections at startup, which is, it think, a good default. * connections-pool-max-size. Set to 0 (unlimited) by default, so we move the bottleneck to postgresql. * connections-idle-timeout. Set to 10 minutes. I don't have arguments about this except that this is the default in pgbouncer.

# copyright 2004-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of yams.
#
# yams is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# yams is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with yams. If not, see <http://www.gnu.org/licenses/>.
from yams.buildobjs import (EntityType, RelationDefinition, RelationType,
                            SubjectRelation, String, Int, Float, Date, Boolean)
from yams.constraints import Attribute, BoundaryConstraint

class Affaire(EntityType):
    sujet = String(maxsize=128)
    ref = String(maxsize=12)

    concerne = SubjectRelation('Societe')
    obj_wildcard = SubjectRelation('*')
    sym_rel = SubjectRelation('Person', symmetric=True)
    inline_rel = SubjectRelation('Person', inlined=True, cardinality='?*')

class subj_wildcard(RelationDefinition):
    subject = '*'
    object = 'Affaire'


class Person(EntityType):
    __unique_together__ = [('nom', 'prenom')]
    nom    = String(maxsize=64, fulltextindexed=True, required=True)
    prenom = String(maxsize=64, fulltextindexed=True)
    sexe   = String(maxsize=1, default='M')
    promo  = String(vocabulary=('bon','pasbon','pas;bon;;du;;;tout;;;;'))
    titre  = String(maxsize=128, fulltextindexed=True)
    adel   = String(maxsize=128)
    ass    = String(maxsize=128)
    web    = String(maxsize=128)
    tel    = Int(__permissions__={'read': (),
                                  'add': ('managers',),
                                  'update': ('managers',)})
    fax    = Int()
    datenaiss = Date()
    test   = Boolean()
    salary = Float()
    travaille = SubjectRelation('Societe',
                                __permissions__={'read': (),
                                                 'add': (),
                                                 'delete': ('managers',),
                                                 })

    evaluee = SubjectRelation('Note')

class Salaried(Person):
    __specializes_schema__ = True

class Societe(EntityType):
    nom  = String(maxsize=64, fulltextindexed=True)
    web = String(maxsize=128)
    tel  = Int(unique=True)
    fax  = Int(constraints=[BoundaryConstraint('<=', Attribute('tel'))])
    rncs = String(maxsize=32)
    ad1  = String(maxsize=128)
    ad2  = String(maxsize=128)
    ad3  = String(maxsize=128)
    cp   = String(maxsize=12)
    ville = String(maxsize=32)

    evaluee = SubjectRelation('Note')


class Note(EntityType):
    date = String(maxsize=10)
    type = String(maxsize=1)
    para = String(maxsize=512)


class pkginfo(EntityType):
    modname = String(maxsize=30, required=True)
    version = String(maxsize=10, required=True, default='0.1')
    copyright = String(required=True)
    license = String(vocabulary=('GPL', 'ZPL'))
    short_desc = String(maxsize=80, required=True)
    long_desc = String(required=True, fulltextindexed=True)
    author = String(maxsize=100, required=True)
    author_email = String(maxsize=100, required=True)
    mailinglist = String(maxsize=100)
    debian_handler = String(vocabulary=('machin', 'bidule'))


class evaluee(RelationType):
    __permissions__ = {
        'read': ('managers',),
        'add': ('managers',),
        'delete': ('managers',),
        }

class concerne(RelationDefinition):
    subject = 'Person'
    object = 'Affaire'
    __permissions__ = {
        'read': ('managers',),
        'add': ('managers',),
        'delete': ('managers',),
        }