server/session.py
branchstable
changeset 7329 f2d52aa8bcdb
parent 7237 9f619715665b
child 7330 584907154ce3
--- a/server/session.py	Fri May 06 18:20:58 2011 +0200
+++ b/server/session.py	Fri May 06 18:21:31 2011 +0200
@@ -33,12 +33,14 @@
 from yams import BASE_TYPES
 
 from cubicweb import Binary, UnknownEid, QueryError, schema
+from cubicweb.selectors import objectify_selector
 from cubicweb.req import RequestSessionBase
 from cubicweb.dbapi import ConnectionProperties
 from cubicweb.utils import make_uid, RepeatList
 from cubicweb.rqlrewrite import RQLRewriter
 from cubicweb.server.edition import EditedEntity
 
+
 ETYPE_PYOBJ_MAP[Binary] = 'Bytes'
 
 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy()
@@ -58,6 +60,20 @@
         description.append(term.get_type(solution, args))
     return description
 
+@objectify_selector
+def is_user_session(cls, req, **kwargs):
+    """repository side only selector returning 1 if the session is a regular
+    user session and not an internal session
+    """
+    return req.is_internal_session
+
+@objectify_selector
+def is_internal_session(cls, req, **kwargs):
+    """repository side only selector returning 1 if the session is not a regular
+    user session but an internal session
+    """
+    return req.is_internal_session
+
 
 class hooks_control(object):
     """context manager to control activated hooks categories.