hooks/security.py
changeset 8190 2a3c1b787688
parent 6426 541659c39f6a
child 8239 c6cdd060212e
equal deleted inserted replaced
8189:2ee0ef069fa7 8190:2a3c1b787688
     1 # copyright 2003-2010 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
    19 the user connected to a session
    19 the user connected to a session
    20 """
    20 """
    21 
    21 
    22 __docformat__ = "restructuredtext en"
    22 __docformat__ = "restructuredtext en"
    23 
    23 
       
    24 from logilab.common.registry import objectify_predicate
       
    25 
    24 from cubicweb import Unauthorized
    26 from cubicweb import Unauthorized
    25 from cubicweb.selectors import objectify_selector, lltrace
       
    26 from cubicweb.server import BEFORE_ADD_RELATIONS, ON_COMMIT_ADD_RELATIONS, hook
    27 from cubicweb.server import BEFORE_ADD_RELATIONS, ON_COMMIT_ADD_RELATIONS, hook
    27 
    28 
    28 
    29 
    29 def check_entity_attributes(session, entity, editedattrs=None, creation=False):
    30 def check_entity_attributes(session, entity, editedattrs=None, creation=False):
    30     eid = entity.eid
    31     eid = entity.eid
    62             rdef = rschema.rdef(session.describe(eidfrom)[0],
    63             rdef = rschema.rdef(session.describe(eidfrom)[0],
    63                                 session.describe(eidto)[0])
    64                                 session.describe(eidto)[0])
    64             rdef.check_perm(session, action, fromeid=eidfrom, toeid=eidto)
    65             rdef.check_perm(session, action, fromeid=eidfrom, toeid=eidto)
    65 
    66 
    66 
    67 
    67 @objectify_selector
    68 @objectify_predicate
    68 @lltrace
       
    69 def write_security_enabled(cls, req, **kwargs):
    69 def write_security_enabled(cls, req, **kwargs):
    70     if req is None or not req.write_security:
    70     if req is None or not req.write_security:
    71         return 0
    71         return 0
    72     return 1
    72     return 1
    73 
    73