cubicweb/pyramid/syncsession.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Fri, 04 Nov 2016 11:56:00 +0100
changeset 11797 6c036ac4c1c2
parent 11702 be23c3813bbf
permissions -rw-r--r--
[test] Distinguish "request" tests from accept parser ones in unittest_request.py

# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb 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.
#
# CubicWeb 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 CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
"""Override cubicweb's syncsession hooks to handle them in the pyramid's way"""

from logilab.common.decorators import monkeypatch
from cubicweb.hooks import syncsession


def includeme(config):

    @monkeypatch(syncsession)
    def get_user_sessions(cnx, user_eid):
        if cnx.user.eid == user_eid:
            yield cnx