comparison roundup/hyperdb.py @ 1019:a9a73d4e78b9 maint-0.4

fixes to property editing through the web
author Richard Jones <richard@users.sourceforge.net>
date Tue, 03 Sep 2002 03:28:26 +0000
parents b3db3c26d7ad
children
comparison
equal deleted inserted replaced
1017:cfc694864143 1019:a9a73d4e78b9
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.69.2.2 2002-09-03 02:55:26 richard Exp $ 18 # $Id: hyperdb.py,v 1.69.2.3 2002-09-03 03:28:26 richard Exp $
19 19
20 __doc__ = """ 20 __doc__ = """
21 Hyperdatabase implementation, especially field types. 21 Hyperdatabase implementation, especially field types.
22 """ 22 """
23 23
395 prop = self.properties[key] 395 prop = self.properties[key]
396 except KeyError: 396 except KeyError:
397 raise KeyError, '"%s" has no property "%s"'%(self.classname, 397 raise KeyError, '"%s" has no property "%s"'%(self.classname,
398 key) 398 key)
399 399
400 if isinstance(prop, Link): 400 if value is not None and isinstance(prop, Link):
401 if type(value) != type(''): 401 if type(value) != type(''):
402 raise ValueError, 'link value must be String' 402 raise ValueError, 'link value must be String'
403 link_class = self.properties[key].classname 403 link_class = self.properties[key].classname
404 # if it isn't a number, it's a key 404 # if it isn't a number, it's a key
405 if not num_re.match(value): 405 if not num_re.match(value):
587 587
588 # do stuff based on the prop type 588 # do stuff based on the prop type
589 if isinstance(prop, Link): 589 if isinstance(prop, Link):
590 link_class = self.properties[key].classname 590 link_class = self.properties[key].classname
591 # if it isn't a number, it's a key 591 # if it isn't a number, it's a key
592 if type(value) != type(''): 592 if value is not None and not isinstance(value, type('')):
593 raise ValueError, 'link value must be String' 593 raise ValueError, 'property "%s" link value be a string'%(
594 if not num_re.match(value): 594 key)
595 if isinstance(value, type('')) and not num_re.match(value):
595 try: 596 try:
596 value = self.db.classes[link_class].lookup(value) 597 value = self.db.classes[link_class].lookup(value)
597 except (TypeError, KeyError): 598 except (TypeError, KeyError):
598 raise IndexError, 'new property "%s": %s not a %s'%( 599 raise IndexError, 'new property "%s": %s not a %s'%(
599 key, value, self.properties[key].classname) 600 key, value, self.properties[key].classname)
600 601
601 if not self.db.hasnode(link_class, value): 602 if (value is not None and
603 not self.db.getclass(link_class).hasnode(value)):
602 raise IndexError, '%s has no node %s'%(link_class, value) 604 raise IndexError, '%s has no node %s'%(link_class, value)
603 605
604 if self.properties[key].do_journal: 606 if self.properties[key].do_journal:
605 # register the unlink with the old linked node 607 # register the unlink with the old linked node
606 if node[key] is not None: 608 if node[key] is not None:
1186 cl.create(name=options[i], order=i) 1188 cl.create(name=options[i], order=i)
1187 return hyperdb.Link(name) 1189 return hyperdb.Link(name)
1188 1190
1189 # 1191 #
1190 # $Log: not supported by cvs2svn $ 1192 # $Log: not supported by cvs2svn $
1193 # Revision 1.69.2.2 2002/09/03 02:55:26 richard
1194 # bug in multilink meant changes might not be detected correctly
1195 #
1191 # Revision 1.69.2.1 2002/07/10 06:30:47 richard 1196 # Revision 1.69.2.1 2002/07/10 06:30:47 richard
1192 # . #571170 ] gdbm deadlock 1197 # . #571170 ] gdbm deadlock
1193 # 1198 #
1194 # Revision 1.69 2002/06/17 23:15:29 richard 1199 # Revision 1.69 2002/06/17 23:15:29 richard
1195 # Can debug to stdout now 1200 # Can debug to stdout now

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