entities/authobjs.py
branchstable
changeset 7120 e8b6fc55df2d
parent 7110 73b3e0e095d3
child 7370 96923d75610b
equal deleted inserted replaced
7119:8b29c4c2ffc6 7120:e8b6fc55df2d
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2011 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
    85         try:
    85         try:
    86             prop = self._cw.execute(
    86             prop = self._cw.execute(
    87                 'CWProperty X WHERE X pkey %(k)s, X for_user U, U eid %(u)s',
    87                 'CWProperty X WHERE X pkey %(k)s, X for_user U, U eid %(u)s',
    88                 {'k': pkey, 'u': self.eid}).get_entity(0, 0)
    88                 {'k': pkey, 'u': self.eid}).get_entity(0, 0)
    89         except:
    89         except:
    90             self._cw.create_entity('CWProperty', pkey=unicode(pkey),
    90             kwargs = dict(pkey=unicode(pkey), value=value)
    91                                    value=value, for_user=self)
    91             if self.is_in_group('managers'):
       
    92                 kwargs['for_user'] = self
       
    93             self._cw.create_entity('CWProperty', **kwargs)
    92         else:
    94         else:
    93             prop.set_attributes(value=value)
    95             prop.set_attributes(value=value)
    94 
    96 
    95     def matching_groups(self, groups):
    97     def matching_groups(self, groups):
    96         """return the number of the given group(s) in which the user is
    98         """return the number of the given group(s) in which the user is