예제 #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))