comparison roundup/backends/rdbms_common.py @ 1195:e0032f4ab334

added missing stringFind to sql backends
author Richard Jones <richard@users.sourceforge.net>
date Tue, 24 Sep 2002 01:59:28 +0000
parents 23b8d1e87fe3
children 735adcbfc665
comparison
equal deleted inserted replaced
1194:d76b3f8d7bc4 1195:e0032f4ab334
1 # $Id: rdbms_common.py,v 1.14 2002-09-23 08:24:51 richard Exp $ 1 # $Id: rdbms_common.py,v 1.15 2002-09-24 01:59:28 richard Exp $
2 2
3 # standard python modules 3 # standard python modules
4 import sys, os, time, re, errno, weakref, copy 4 import sys, os, time, re, errno, weakref, copy
5 5
6 # roundup modules 6 # roundup modules
1610 a = self.db.arg 1610 a = self.db.arg
1611 tables.append('select nodeid from %s_%s where linkid in (%s)'%( 1611 tables.append('select nodeid from %s_%s where linkid in (%s)'%(
1612 self.classname, prop, ','.join([a for x in values.keys()]))) 1612 self.classname, prop, ','.join([a for x in values.keys()])))
1613 sql = '\nintersect\n'.join(tables) 1613 sql = '\nintersect\n'.join(tables)
1614 self.db.sql(sql, allvalues) 1614 self.db.sql(sql, allvalues)
1615 try: 1615 l = [x[0] for x in self.db.sql_fetchall()]
1616 l = [x[0] for x in self.db.cursor.fetchall()] 1616 if __debug__:
1617 except gadfly.database.error, message: 1617 print >>hyperdb.DEBUG, 'find ... ', l
1618 if message == 'no more results': 1618 return l
1619 l = [] 1619
1620 raise 1620 def stringFind(self, **requirements):
1621 '''Locate a particular node by matching a set of its String
1622 properties in a caseless search.
1623
1624 If the property is not a String property, a TypeError is raised.
1625
1626 The return is a list of the id of all nodes that match.
1627 '''
1628 where = []
1629 args = []
1630 for propname in requirements.keys():
1631 prop = self.properties[propname]
1632 if isinstance(not prop, String):
1633 raise TypeError, "'%s' not a String property"%propname
1634 where.append(propname)
1635 args.append(requirements[propname].lower())
1636
1637 # generate the where clause
1638 s = ' and '.join(['_%s=%s'%(col, self.db.arg) for col in where])
1639 sql = 'select id from _%s where %s'%(self.classname, s)
1640 self.db.sql(sql, tuple(args))
1641 l = [x[0] for x in self.db.sql_fetchall()]
1621 if __debug__: 1642 if __debug__:
1622 print >>hyperdb.DEBUG, 'find ... ', l 1643 print >>hyperdb.DEBUG, 'find ... ', l
1623 return l 1644 return l
1624 1645
1625 def list(self): 1646 def list(self):

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