cubicweb/pyramid/syncsession.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Fri, 18 Nov 2016 14:26:03 +0100
branch3.24
changeset 11833 1212f0fa2d42
parent 11702 be23c3813bbf
permissions -rw-r--r--
[debian] Have a single python-cubicweb binary for the library But keep distinct meta-packages for dependencies of the HTTP server (Twisted/Pyramid) and database backend. Related to #16133259.

# 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