Mercurial > p > roundup > code
comparison roundup/hyperdb.py @ 228:1d1848c99abe
Fixed some isFooTypes that I missed.
Refactored some code in the CGI code.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 15 Aug 2001 23:43:18 +0000 |
| parents | ad2c98faec97 |
| children | e17a43d2c0d0 |
comparison
equal
deleted
inserted
replaced
| 227:359ba665d346 | 228:1d1848c99abe |
|---|---|
| 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.15 2001-08-12 06:32:36 richard Exp $ | 18 # $Id: hyperdb.py,v 1.16 2001-08-15 23:43:18 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 |
| 188 elif isinstance(prop, String): | 188 elif isinstance(prop, String): |
| 189 if type(value) != type(''): | 189 if type(value) != type(''): |
| 190 raise TypeError, 'new property "%s" not a string'%key | 190 raise TypeError, 'new property "%s" not a string'%key |
| 191 | 191 |
| 192 elif isinstance(prop, Date): | 192 elif isinstance(prop, Date): |
| 193 if not hasattr(value, 'isDate'): | 193 if not isinstance(value, date.Date): |
| 194 raise TypeError, 'new property "%s" not a Date'% key | 194 raise TypeError, 'new property "%s" not a Date'% key |
| 195 | 195 |
| 196 elif isinstance(prop, Interval): | 196 elif isinstance(prop, Interval): |
| 197 if not hasattr(value, 'isInterval'): | 197 if not isinstance(value, date.Interval): |
| 198 raise TypeError, 'new property "%s" not an Interval'% key | 198 raise TypeError, 'new property "%s" not an Interval'% key |
| 199 | 199 |
| 200 for key, prop in self.properties.items(): | 200 for key, prop in self.properties.items(): |
| 201 if propvalues.has_key(key): | 201 if propvalues.has_key(key): |
| 202 continue | 202 continue |
| 343 elif isinstance(prop, String): | 343 elif isinstance(prop, String): |
| 344 if value is not None and type(value) != type(''): | 344 if value is not None and type(value) != type(''): |
| 345 raise TypeError, 'new property "%s" not a string'%key | 345 raise TypeError, 'new property "%s" not a string'%key |
| 346 | 346 |
| 347 elif isinstance(prop, Date): | 347 elif isinstance(prop, Date): |
| 348 if not hasattr(value, 'isDate'): | 348 if not isinstance(value, date.Date): |
| 349 raise TypeError, 'new property "%s" not a Date'% key | 349 raise TypeError, 'new property "%s" not a Date'% key |
| 350 | 350 |
| 351 elif isinstance(prop, Interval): | 351 elif isinstance(prop, Interval): |
| 352 if not hasattr(value, 'isInterval'): | 352 if not isinstance(value, date.Interval): |
| 353 raise TypeError, 'new property "%s" not an Interval'% key | 353 raise TypeError, 'new property "%s" not an Interval'% key |
| 354 | 354 |
| 355 node[key] = value | 355 node[key] = value |
| 356 | 356 |
| 357 self.db.setnode(self.classname, nodeid, node) | 357 self.db.setnode(self.classname, nodeid, node) |
| 673 # clean up the strings | 673 # clean up the strings |
| 674 if av and av[0] in string.uppercase: | 674 if av and av[0] in string.uppercase: |
| 675 av = an[prop] = av.lower() | 675 av = an[prop] = av.lower() |
| 676 if bv and bv[0] in string.uppercase: | 676 if bv and bv[0] in string.uppercase: |
| 677 bv = bn[prop] = bv.lower() | 677 bv = bn[prop] = bv.lower() |
| 678 if isinstance(propclass.isStringType or propclass, Date): | 678 if (isinstance(propclass, String) or |
| 679 isinstance(propclass, Date)): | |
| 679 if dir == '+': | 680 if dir == '+': |
| 680 r = cmp(av, bv) | 681 r = cmp(av, bv) |
| 681 if r != 0: return r | 682 if r != 0: return r |
| 682 elif dir == '-': | 683 elif dir == '-': |
| 683 r = cmp(bv, av) | 684 r = cmp(bv, av) |
| 804 cl.create(name=option[i], order=i) | 805 cl.create(name=option[i], order=i) |
| 805 return hyperdb.Link(name) | 806 return hyperdb.Link(name) |
| 806 | 807 |
| 807 # | 808 # |
| 808 # $Log: not supported by cvs2svn $ | 809 # $Log: not supported by cvs2svn $ |
| 810 # Revision 1.15 2001/08/12 06:32:36 richard | |
| 811 # using isinstance(blah, Foo) now instead of isFooType | |
| 812 # | |
| 809 # Revision 1.14 2001/08/07 00:24:42 richard | 813 # Revision 1.14 2001/08/07 00:24:42 richard |
| 810 # stupid typo | 814 # stupid typo |
| 811 # | 815 # |
| 812 # Revision 1.13 2001/08/07 00:15:51 richard | 816 # Revision 1.13 2001/08/07 00:15:51 richard |
| 813 # Added the copyright/license notice to (nearly) all files at request of | 817 # Added the copyright/license notice to (nearly) all files at request of |
