Mercurial > p > roundup > code
comparison roundup/hyperdb.py @ 330:62f899fb0c03
Made Class.stringFind() do caseless matching.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sat, 27 Oct 2001 00:17:41 +0000 |
| parents | 5a2c43891c20 |
| children | 93dc08528ad9 |
comparison
equal
deleted
inserted
replaced
| 329:96212178c175 | 330:62f899fb0c03 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: hyperdb.py,v 1.28 2001-10-21 04:44:50 richard Exp $ | 18 # $Id: hyperdb.py,v 1.29 2001-10-27 00:17:41 richard Exp $ |
| 19 | 19 |
| 20 # standard python modules | 20 # standard python modules |
| 21 import cPickle, re, string | 21 import cPickle, re, string |
| 22 | 22 |
| 23 # roundup modules | 23 # roundup modules |
| 524 l.append(id) | 524 l.append(id) |
| 525 cldb.close() | 525 cldb.close() |
| 526 return l | 526 return l |
| 527 | 527 |
| 528 def stringFind(self, **requirements): | 528 def stringFind(self, **requirements): |
| 529 """Locate a particular node by matching a set of its String properties. | 529 """Locate a particular node by matching a set of its String |
| 530 properties in a caseless search. | |
| 530 | 531 |
| 531 If the property is not a String property, a TypeError is raised. | 532 If the property is not a String property, a TypeError is raised. |
| 532 | 533 |
| 533 The return is a list of the id of all nodes that match. | 534 The return is a list of the id of all nodes that match. |
| 534 """ | 535 """ |
| 535 for propname in requirements.keys(): | 536 for propname in requirements.keys(): |
| 536 prop = self.properties[propname] | 537 prop = self.properties[propname] |
| 537 if isinstance(not prop, String): | 538 if isinstance(not prop, String): |
| 538 raise TypeError, "'%s' not a String property"%propname | 539 raise TypeError, "'%s' not a String property"%propname |
| 540 requirements[propname] = requirements[propname].lower() | |
| 539 l = [] | 541 l = [] |
| 540 cldb = self.db.getclassdb(self.classname) | 542 cldb = self.db.getclassdb(self.classname) |
| 541 for nodeid in self.db.getnodeids(self.classname, cldb): | 543 for nodeid in self.db.getnodeids(self.classname, cldb): |
| 542 node = self.db.getnode(self.classname, nodeid, cldb) | 544 node = self.db.getnode(self.classname, nodeid, cldb) |
| 543 if node.has_key(self.db.RETIRED_FLAG): | 545 if node.has_key(self.db.RETIRED_FLAG): |
| 544 continue | 546 continue |
| 545 for key, value in requirements.items(): | 547 for key, value in requirements.items(): |
| 546 if node[key] != value: | 548 if node[key].lower() != value: |
| 547 break | 549 break |
| 548 else: | 550 else: |
| 549 l.append(nodeid) | 551 l.append(nodeid) |
| 550 cldb.close() | 552 cldb.close() |
| 551 return l | 553 return l |
| 845 cl.create(name=option[i], order=i) | 847 cl.create(name=option[i], order=i) |
| 846 return hyperdb.Link(name) | 848 return hyperdb.Link(name) |
| 847 | 849 |
| 848 # | 850 # |
| 849 # $Log: not supported by cvs2svn $ | 851 # $Log: not supported by cvs2svn $ |
| 852 # Revision 1.28 2001/10/21 04:44:50 richard | |
| 853 # bug #473124: UI inconsistency with Link fields. | |
| 854 # This also prompted me to fix a fairly long-standing usability issue - | |
| 855 # that of being able to turn off certain filters. | |
| 856 # | |
| 850 # Revision 1.27 2001/10/20 23:44:27 richard | 857 # Revision 1.27 2001/10/20 23:44:27 richard |
| 851 # Hyperdatabase sorts strings-that-look-like-numbers as numbers now. | 858 # Hyperdatabase sorts strings-that-look-like-numbers as numbers now. |
| 852 # | 859 # |
| 853 # Revision 1.26 2001/10/16 03:48:01 richard | 860 # Revision 1.26 2001/10/16 03:48:01 richard |
| 854 # admin tool now complains if a "find" is attempted with a non-link property. | 861 # admin tool now complains if a "find" is attempted with a non-link property. |
