server/session.py
changeset 8190 2a3c1b787688
parent 8096 e1b21db042d6
child 8265 9747ab9230ad
equal deleted inserted replaced
8189:2ee0ef069fa7 8190:2a3c1b787688
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    27 from uuid import uuid4
    27 from uuid import uuid4
    28 from warnings import warn
    28 from warnings import warn
    29 
    29 
    30 from logilab.common.deprecation import deprecated
    30 from logilab.common.deprecation import deprecated
    31 from logilab.common.textutils import unormalize
    31 from logilab.common.textutils import unormalize
       
    32 from logilab.common.registry import objectify_predicate
    32 from rql import CoercionError
    33 from rql import CoercionError
    33 from rql.nodes import ETYPE_PYOBJ_MAP, etype_from_pyobj
    34 from rql.nodes import ETYPE_PYOBJ_MAP, etype_from_pyobj
    34 from yams import BASE_TYPES
    35 from yams import BASE_TYPES
    35 
    36 
    36 from cubicweb import Binary, UnknownEid, QueryError, schema
    37 from cubicweb import Binary, UnknownEid, QueryError, schema
    37 from cubicweb.selectors import objectify_selector
       
    38 from cubicweb.req import RequestSessionBase
    38 from cubicweb.req import RequestSessionBase
    39 from cubicweb.dbapi import ConnectionProperties
    39 from cubicweb.dbapi import ConnectionProperties
    40 from cubicweb.utils import make_uid, RepeatList
    40 from cubicweb.utils import make_uid, RepeatList
    41 from cubicweb.rqlrewrite import RQLRewriter
    41 from cubicweb.rqlrewrite import RQLRewriter
    42 from cubicweb.server import ShuttingDown
    42 from cubicweb.server import ShuttingDown
    72                 if ttype is not None:
    72                 if ttype is not None:
    73                     return ttype
    73                     return ttype
    74             except CoercionError:
    74             except CoercionError:
    75                 return None
    75                 return None
    76 
    76 
    77 @objectify_selector
    77 @objectify_predicate
    78 def is_user_session(cls, req, **kwargs):
    78 def is_user_session(cls, req, **kwargs):
    79     """repository side only selector returning 1 if the session is a regular
    79     """repository side only predicate returning 1 if the session is a regular
    80     user session and not an internal session
    80     user session and not an internal session
    81     """
    81     """
    82     return not req.is_internal_session
    82     return not req.is_internal_session
    83 
    83 
    84 @objectify_selector
    84 @objectify_predicate
    85 def is_internal_session(cls, req, **kwargs):
    85 def is_internal_session(cls, req, **kwargs):
    86     """repository side only selector returning 1 if the session is not a regular
    86     """repository side only predicate returning 1 if the session is not a regular
    87     user session but an internal session
    87     user session but an internal session
    88     """
    88     """
    89     return req.is_internal_session
    89     return req.is_internal_session
    90 
    90 
    91 @objectify_selector
    91 @objectify_predicate
    92 def repairing(cls, req, **kwargs):
    92 def repairing(cls, req, **kwargs):
    93     """repository side only selector returning 1 if the session is not a regular
    93     """repository side only predicate returning 1 if the session is not a regular
    94     user session but an internal session
    94     user session but an internal session
    95     """
    95     """
    96     return req.vreg.config.repairing
    96     return req.vreg.config.repairing
    97 
    97 
    98 
    98