cubicweb/pyramid/syncsession.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Mon, 20 Mar 2017 17:38:43 +0100
branch3.24
changeset 12077 e282711ac6b2
parent 11702 be23c3813bbf
permissions -rw-r--r--
Added tag 3.24.7, debian/3.24.7-1, centos/3.24.7-1 for changeset 58f1e8545a77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11702
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
#
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
# This file is part of CubicWeb.
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
#
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
# any later version.
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    10
#
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
# details.
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
#
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
"""Override cubicweb's syncsession hooks to handle them in the pyramid's way"""
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
from logilab.common.decorators import monkeypatch
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
from cubicweb.hooks import syncsession
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
def includeme(config):
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
    @monkeypatch(syncsession)
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
    def get_user_sessions(cnx, user_eid):
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
        if cnx.user.eid == user_eid:
be23c3813bbf [pyramid] Override cubicweb.hooks.syncsession.get_user_sessions() for Pyramid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
            yield cnx