X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=daklib%2Fdbconn.py;h=22fa262cae20cd68f7a68a78b717d8752b6b5d8a;hb=48ef6001b312b545cf998cab9e07f87eb1d02591;hp=43c0b6985e7ebf723423cce58f6a1c59d353bfe3;hpb=fcb5dd60b62794747cf976feadf9208b98de7bd8;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 43c0b698..22fa262c 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -1233,6 +1233,29 @@ def get_priority(priority, session=None): __all__.append('get_priority') +def get_priorities(session=None): + """ + Returns dictionary of priority names -> id mappings + + @type session: Session + @param session: Optional SQL session object (a temporary one will be + generated if not supplied) + + @rtype: dictionary + @return: dictionary of priority names -> id mappings + """ + if session is None: + session = DBConn().session() + + ret = {} + q = session.query(Priority) + for x in q.all(): + ret[x.priority] = x.priority_id + + return ret + +__all__.append('get_priorities') + ################################################################################ class Queue(object): @@ -1469,6 +1492,29 @@ def get_section(section, session=None): __all__.append('get_section') +def get_sections(session=None): + """ + Returns dictionary of section names -> id mappings + + @type session: Session + @param session: Optional SQL session object (a temporary one will be + generated if not supplied) + + @rtype: dictionary + @return: dictionary of section names -> id mappings + """ + if session is None: + session = DBConn().session() + + ret = {} + q = session.query(Section) + for x in q.all(): + ret[x.section] = x.section_id + + return ret + +__all__.append('get_sections') + ################################################################################ class DBSource(object):