devtools/testlib.py
changeset 7332 c3ae97c0066b
parent 7314 d3104c697adb
parent 7331 7fcc4f22f3e4
child 7338 591d6ed3e1f4
equal deleted inserted replaced
7326:6c603d0fb2c7 7332:c3ae97c0066b
   358     def create_user(self, req, login=None, groups=('users',), password=None,
   358     def create_user(self, req, login=None, groups=('users',), password=None,
   359                     commit=True, **kwargs):
   359                     commit=True, **kwargs):
   360         """create and return a new user entity"""
   360         """create and return a new user entity"""
   361         if isinstance(req, basestring):
   361         if isinstance(req, basestring):
   362             warn('[3.12] create_user arguments are now (req, login[, groups, password, commit, **kwargs])',
   362             warn('[3.12] create_user arguments are now (req, login[, groups, password, commit, **kwargs])',
   363                  DeprecationWarning, stacklevel=1)
   363                  DeprecationWarning, stacklevel=2)
   364             if not isinstance(groups, (tuple, list)):
   364             if not isinstance(groups, (tuple, list)):
   365                 password = groups
   365                 password = groups
   366                 groups = login
   366                 groups = login
   367             elif isinstance(login, tuple):
   367             elif isinstance(login, tuple):
   368                 groups = login
   368                 groups = login
   389         """insert a permission on an entity. Will have to commit the main
   389         """insert a permission on an entity. Will have to commit the main
   390         connection to be considered
   390         connection to be considered
   391         """
   391         """
   392         if not isinstance(session, Session):
   392         if not isinstance(session, Session):
   393             warn('[3.12] grant_permission arguments are now (session, entity, group, pname[, plabel])',
   393             warn('[3.12] grant_permission arguments are now (session, entity, group, pname[, plabel])',
   394                  DeprecationWarning, stacklevel=1)
   394                  DeprecationWarning, stacklevel=2)
   395             plabel = pname
   395             plabel = pname
   396             pname = group
   396             pname = group
   397             group = entity
   397             group = entity
   398             entity = session
   398             entity = session
   399             assert not isinstance(self, type)
   399             assert not isinstance(self, type)
   400             session = self.session
   400             session = self.session
   401         pname = unicode(pname)
   401         pname = unicode(pname)
   402         plabel = plabel and unicode(plabel) or unicode(group)
   402         plabel = plabel and unicode(plabel) or unicode(group)
   403         e = entity.eid
   403         e = getattr(entity, 'eid', entity)
   404         with security_enabled(session, False, False):
   404         with security_enabled(session, False, False):
   405             peid = session.execute(
   405             peid = session.execute(
   406             'INSERT CWPermission X: X name %(pname)s, X label %(plabel)s,'
   406             'INSERT CWPermission X: X name %(pname)s, X label %(plabel)s,'
   407             'X require_group G, E require_permission X '
   407             'X require_group G, E require_permission X '
   408             'WHERE G name %(group)s, E eid %(e)s',
   408             'WHERE G name %(group)s, E eid %(e)s',