server/sources/native.py
changeset 10365 21461f80f348
parent 10364 8b35a898b334
child 10366 38c7598b5c61
equal deleted inserted replaced
10364:8b35a898b334 10365:21461f80f348
  1017                 sql += ' WHERE %s' % ' OR '.join(subqsqls)
  1017                 sql += ' WHERE %s' % ' OR '.join(subqsqls)
  1018             restr.update(trarestr)
  1018             restr.update(trarestr)
  1019             restr.update(tearestr)
  1019             restr.update(tearestr)
  1020         # we want results ordered by transaction's time descendant
  1020         # we want results ordered by transaction's time descendant
  1021         sql += ' ORDER BY tx_time DESC'
  1021         sql += ' ORDER BY tx_time DESC'
  1022         with cnx.ensure_cnx_set:
  1022         cu = self.doexec(cnx, sql, restr)
  1023             cu = self.doexec(cnx, sql, restr)
  1023         # turn results into transaction objects
  1024             # turn results into transaction objects
  1024         return [tx.Transaction(cnx, *args) for args in cu.fetchall()]
  1025             return [tx.Transaction(cnx, *args) for args in cu.fetchall()]
       
  1026 
  1025 
  1027     def tx_info(self, cnx, txuuid):
  1026     def tx_info(self, cnx, txuuid):
  1028         """See :class:`cubicweb.repoapi.Connection.transaction_info`"""
  1027         """See :class:`cubicweb.repoapi.Connection.transaction_info`"""
  1029         return tx.Transaction(cnx, txuuid, *self._tx_info(cnx, unicode(txuuid)))
  1028         return tx.Transaction(cnx, txuuid, *self._tx_info(cnx, unicode(txuuid)))
  1030 
  1029 
  1117         """return transaction's time and user of the transaction with the given uuid.
  1116         """return transaction's time and user of the transaction with the given uuid.
  1118 
  1117 
  1119         raise `NoSuchTransaction` if there is no such transaction of if the
  1118         raise `NoSuchTransaction` if there is no such transaction of if the
  1120         connection's user isn't allowed to see it.
  1119         connection's user isn't allowed to see it.
  1121         """
  1120         """
  1122         with cnx.ensure_cnx_set:
  1121         restr = {'tx_uuid': txuuid}
  1123             restr = {'tx_uuid': txuuid}
  1122         sql = self.sqlgen.select('transactions', restr,
  1124             sql = self.sqlgen.select('transactions', restr,
  1123                                  ('tx_time', 'tx_user'))
  1125                                      ('tx_time', 'tx_user'))
  1124         cu = self.doexec(cnx, sql, restr)
  1126             cu = self.doexec(cnx, sql, restr)
  1125         try:
  1127             try:
  1126             time, ueid = cu.fetchone()
  1128                 time, ueid = cu.fetchone()
  1127         except TypeError:
  1129             except TypeError:
  1128             raise tx.NoSuchTransaction(txuuid)
  1130                 raise tx.NoSuchTransaction(txuuid)
  1129         if not (cnx.user.is_in_group('managers')
  1131             if not (cnx.user.is_in_group('managers')
  1130                 or cnx.user.eid == ueid):
  1132                     or cnx.user.eid == ueid):
  1131             raise tx.NoSuchTransaction(txuuid)
  1133                 raise tx.NoSuchTransaction(txuuid)
  1132         return time, ueid
  1134             return time, ueid
       
  1135 
  1133 
  1136     def _reedit_entity(self, entity, changes, err):
  1134     def _reedit_entity(self, entity, changes, err):
  1137         cnx = entity._cw
  1135         cnx = entity._cw
  1138         eid = entity.eid
  1136         eid = entity.eid
  1139         entity.cw_edited = edited = EditedEntity(entity)
  1137         entity.cw_edited = edited = EditedEntity(entity)