comparison roundup/backends/rdbms_common.py @ 1484:b3f2484babce

fixes to import/export
author Richard Jones <richard@users.sourceforge.net>
date Fri, 28 Feb 2003 03:33:46 +0000
parents 405e91b5be46
children 2fc7d4a8c9e7
comparison
equal deleted inserted replaced
1483:ca3e0e2320be 1484:b3f2484babce
1 # $Id: rdbms_common.py,v 1.37 2003-02-27 11:07:36 richard Exp $ 1 # $Id: rdbms_common.py,v 1.38 2003-02-28 03:33:46 richard Exp $
2 ''' Relational database (SQL) backend common code. 2 ''' Relational database (SQL) backend common code.
3 3
4 Basics: 4 Basics:
5 5
6 - map roundup classes to relational tables 6 - map roundup classes to relational tables
712 sql = 'select count(*) from _%s'%classname 712 sql = 'select count(*) from _%s'%classname
713 if __debug__: 713 if __debug__:
714 print >>hyperdb.DEBUG, 'countnodes', (self, sql) 714 print >>hyperdb.DEBUG, 'countnodes', (self, sql)
715 self.cursor.execute(sql) 715 self.cursor.execute(sql)
716 return self.cursor.fetchone()[0] 716 return self.cursor.fetchone()[0]
717
718 def getnodeids(self, classname, retired=0):
719 ''' Retrieve all the ids of the nodes for a particular Class.
720
721 Set retired=None to get all nodes. Otherwise it'll get all the
722 retired or non-retired nodes, depending on the flag.
723 '''
724 # flip the sense of the flag if we don't want all of them
725 if retired is not None:
726 retired = not retired
727 sql = 'select id from _%s where __retired__ <> %s'%(classname, self.arg)
728 if __debug__:
729 print >>hyperdb.DEBUG, 'getnodeids', (self, sql, retired)
730 self.cursor.execute(sql, (retired,))
731 return [x[0] for x in self.cursor.fetchall()]
732 717
733 def addjournal(self, classname, nodeid, action, params, creator=None, 718 def addjournal(self, classname, nodeid, action, params, creator=None,
734 creation=None): 719 creation=None):
735 ''' Journal the Action 720 ''' Journal the Action
736 'action' may be: 721 'action' may be:
1688 return l 1673 return l
1689 1674
1690 def list(self): 1675 def list(self):
1691 ''' Return a list of the ids of the active nodes in this class. 1676 ''' Return a list of the ids of the active nodes in this class.
1692 ''' 1677 '''
1693 return self.db.getnodeids(self.classname, retired=0) 1678 return self.getnodeids(retired=0)
1679
1680 def getnodeids(self, retired=None):
1681 ''' Retrieve all the ids of the nodes for a particular Class.
1682
1683 Set retired=None to get all nodes. Otherwise it'll get all the
1684 retired or non-retired nodes, depending on the flag.
1685 '''
1686 # flip the sense of the flag if we don't want all of them
1687 if retired is not None:
1688 retired = not retired
1689 sql = 'select id from _%s where __retired__ <> %s'%(self.classname,
1690 self.db.arg)
1691 if __debug__:
1692 print >>hyperdb.DEBUG, 'getnodeids', (self, sql, retired)
1693 self.db.cursor.execute(sql, (retired,))
1694 return [x[0] for x in self.db.cursor.fetchall()]
1694 1695
1695 def filter(self, search_matches, filterspec, sort=(None,None), 1696 def filter(self, search_matches, filterspec, sort=(None,None),
1696 group=(None,None)): 1697 group=(None,None)):
1697 ''' Return a list of the ids of the active nodes in this class that 1698 ''' Return a list of the ids of the active nodes in this class that
1698 match the 'filter' spec, sorted by the group spec and then the 1699 match the 'filter' spec, sorted by the group spec and then the

Roundup Issue Tracker: http://roundup-tracker.org/