cubicweb/pyramid/syncsession.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Nov 2016 11:46:03 +0100
branch3.24
changeset 11814 ab8f652a9c99
parent 11702 be23c3813bbf
permissions -rw-r--r--
[pyramid] Add action verb used in some messages displayed by the command For instance we'll see 'instance started' instead of 'instance None', which is nicer.

# 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