示例#1
0
    def configDelete(self, idx, namefunc=defaultNamefunc):
        """
        Delete a configuration from the database.  Assumes inside a 
        transaction, but does not commit the change.

        Parameters
        ----------
        idx : int
            A database ID for the configuration to be deleted.

        namefunc : int -> str
            A function to provide human-readable names for the database ID.
            (A useful function is not really defined here.)

        Returns
        -------
        Nothing

        If the deletion fails, errors are appended to the transaction 
        errorlist.
        """
        try:
            if self.cur.execute("select id from %s where config = %%s" % self.table, (idx,)) != 0:
                self.errorlist.append(
                    _mysql_exceptions.Error(0,
                                            "Can't delete configuration %s, still in use." % namefunc(idx)))
                return
            self.cur.execute("delete from %s_cfg where id = %%s" % self.table, (idx,))
        except _mysql_exceptions.Error as e:
            self.errorlist.append(e)
示例#2
0
 def configDelete(self, idx, namefunc=defaultNamefunc):
     try:
         if self.cur.execute("select id from %s where config = %%s" % self.table, (idx,)) != 0:
             self.errorlist.append(
                 _mysql_exceptions.Error(0,
                                         "Can't delete configuration %s, still in use." % namefunc(idx)))
             return
         self.cur.execute("delete from %s_cfg where id = %%s" % self.table, (idx,))
     except _mysql_exceptions.Error as e:
         self.errorlist.append(e)
示例#3
0
    def transaction_error(self, msg):
        """
        Indicate an error during a database transaction.

        Parameters
        ----------
        msg : str
            An error string.

        Returns
        -------
        None
        """
        self.errorlist.append(_mysql_exceptions.Error(0, msg))
示例#4
0
文件: pmgrobj.py 项目: pcdshub/pmgr
 def transaction_error(self, msg):
     self.errorlist.append(_mysql_exceptions.Error(0, msg))