Beispiel #1
0
    def search(self, key=None):
        '''Since Scripts are ninjas, they have no Name=FOO in the configuration
        file.  We will generate names upon creation, and use them, but we have to
        support much more complicated searching to deal with the reality of Bacula
        configurations.'''
        logging.debug('dbdict search')
        DbDict.search(self, key)
        if self[ID]:
            return self
        logging.debug('continuing search')
        conditions = []
        values = []
        for key in self.keys():
            if not self[key] == None:
                conditions.append('`%s` = %%s' % key)
                values.append(self[key])
        sql = 'select * from %s where %s' % (self.table,
                                             ' and '.join(conditions))
        values = tuple(values)

        new_me = self.bc.do_sql(sql, values, asdict=True)
        if not new_me:
            self._create()
        else:
            self.update(new_me[0])
        return self
 def __init__(self, row={}, string=None):
     DbDict.__init__(self, row, string)
     self.entries = []
     return
 def __init__(self, row={}, string=None):
     DbDict.__init__(self, row, string)
     self.entries = []
     return
 def __init__(self, row={}, string=None):
     '''Overrides DbDice.__init__ to ensure each instance has a clean entries member.'''
     DbDict.__init__(self, row, string)
     self.entries = []
     return
 def __init__(self, row={}, string=None):
     '''Overrides DbDice.__init__ to ensure each instance has a clean entries member.'''
     DbDict.__init__(self, row, string)
     self.entries = []
     return