cubicweb/test/data_schemareader/schema.py
author Philippe Pepiot <ph@itsalwaysdns.eu>
Tue, 31 Mar 2020 19:15:03 +0200
changeset 12957 0c973204033a
parent 11911 37726f66ff82
permissions -rw-r--r--
[server] prevent returning closed cursor to the database pool In since c8c6ad8 init_repository use repo.internal_cnx() instead of repo.system_source.get_connection() so it use the pool and we should not close cursors from the pool before returning it back. Otherwise we may have "connection already closed" error. This bug only trigger when connection-pool-size = 1. Since we are moving to use a dynamic pooler we need to get this fixed. This does not occur with sqlite since the connection wrapper instantiate new cursor everytime, but this occur with other databases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11775
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
     1
from yams.buildobjs import EntityType, SubjectRelation
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
     2
from cubicweb.schemas.base import in_group, RELATION_MANAGERS_PERMISSIONS
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
     3
8167
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
# copy __permissions__ to avoid modifying a shared dictionary
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
in_group.__permissions__ = in_group.__permissions__.copy()
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
in_group.__permissions__['read'] = ('managers',)
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
11775
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
     8
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
     9
class CWSourceSchemaConfig(EntityType):
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    10
    cw_for_source = SubjectRelation(
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    11
        'CWSource', inlined=True, cardinality='1*', composite='object',
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    12
        __permissions__=RELATION_MANAGERS_PERMISSIONS)
39cf9e55ada8 [source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    13
11911
37726f66ff82 [tox] Drop "exclude" option from flake8 config and adjust flake8-ok-files.txt accordingly
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11775
diff changeset
    14
8167
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
cw_for_source = CWSourceSchemaConfig.get_relation('cw_for_source')
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
cw_for_source.__permissions__ = {'read': ('managers', 'users'),
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
                                 'add': ('managers',),
41ec579e27c4 [test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
                                 'delete': ('managers',)}