- def clear_caches(self):
- self.__init_caches()
-
- ## Get functions
- def __get_id(self, retfield, selectobj, cachekey, cachename=None):
- # This is a bit of a hack but it's an internal function only
- if cachename is not None:
- res = self.caches[cachename].GetValue(cachekey)
- if res:
- return res
-
- c = selectobj.execute()
-
- if c.rowcount != 1:
- return None
-
- res = c.fetchone()
-
- if retfield not in res.keys():
- return None
-
- res = res[retfield]
-
- if cachename is not None:
- self.caches[cachename].SetValue(cachekey, res)
-
- return res
-
- def get_suite_id(self, suite):
- """
- Returns database id for given C{suite}.
- Results are kept in a cache during runtime to minimize database queries.
-
- @type suite: string
- @param suite: The name of the suite
-
- @rtype: int
- @return: the database id for the given suite
-
- """
- return int(self.__get_id('id',
- self.tbl_suite.select(self.tbl_suite.columns.suite_name == suite),
- suite,
- 'suite'))
-
- def get_section_id(self, section):
- """
- Returns database id for given C{section}.
- Results are kept in a cache during runtime to minimize database queries.
-
- @type section: string
- @param section: The name of the section
-
- @rtype: int
- @return: the database id for the given section
-
- """
- return self.__get_id('id',
- self.tbl_section.select(self.tbl_section.columns.section == section),
- section,
- 'section')
-
- def get_priority_id(self, priority):
- """
- Returns database id for given C{priority}.
- Results are kept in a cache during runtime to minimize database queries.
-
- @type priority: string
- @param priority: The name of the priority
-
- @rtype: int
- @return: the database id for the given priority
-
- """
- return self.__get_id('id',
- self.tbl_priority.select(self.tbl_priority.columns.priority == priority),
- priority,
- 'priority')
-
- def get_override_type_id(self, override_type):
- """
- Returns database id for given override C{type}.
- Results are kept in a cache during runtime to minimize database queries.
-
- @type override_type: string
- @param override_type: The name of the override type
-
- @rtype: int
- @return: the database id for the given override type
-
- """
- return self.__get_id('id',
- self.tbl_override_type.select(self.tbl_override_type.columns.type == override_type),
- override_type,
- 'override_type')
-
- def get_architecture_id(self, architecture):
- """
- Returns database id for given C{architecture}.
- Results are kept in a cache during runtime to minimize database queries.
-
- @type architecture: string
- @param architecture: The name of the override type
-
- @rtype: int
- @return: the database id for the given architecture
-
- """
- return self.__get_id('id',
- self.tbl_architecture.select(self.tbl_architecture.columns.arch_string == architecture),
- architecture,
- 'architecture')
-
- def get_archive_id(self, archive):
- """
- returns database id for given c{archive}.
- results are kept in a cache during runtime to minimize database queries.
-
- @type archive: string
- @param archive: the name of the override type
-
- @rtype: int
- @return: the database id for the given archive
-
- """
- archive = archive.lower()
- return self.__get_id('id',
- self.tbl_archive.select(self.tbl_archive.columns.name == archive),
- archive,
- 'archive')
-
- def get_component_id(self, component):
- """
- Returns database id for given C{component}.
- Results are kept in a cache during runtime to minimize database queries.
-
- @type component: string
- @param component: The name of the override type
-
- @rtype: int
- @return: the database id for the given component
-
- """
- component = component.lower()
- return self.__get_id('id',
- self.tbl_component.select(self.tbl_component.columns.name == component),
- component.lower(),
- 'component')