1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: hyperdb.py,v 1.49 2002-01-16 07:02:57 richard Exp $
18+ # $Id: hyperdb.py,v 1.50 2002-01-19 13:16:04 rochecompaan Exp $
1919
2020__doc__ = """
2121Hyperdatabase implementation, especially field types.
@@ -54,17 +54,19 @@ def __repr__(self):
5454class Link :
5555 """An object designating a Link property that links to a
5656 node in a specified class."""
57- def __init__ (self , classname ):
57+ def __init__ (self , classname , do_journal = 'no' ):
5858 self .classname = classname
59+ self .do_journal = do_journal == 'yes'
5960 def __repr__ (self ):
6061 return '<%s to "%s">' % (self .__class__ , self .classname )
6162
6263class Multilink :
6364 """An object designating a Multilink property that links
6465 to nodes in a specified class.
6566 """
66- def __init__ (self , classname ):
67+ def __init__ (self , classname , do_journal = 'no' ):
6768 self .classname = classname
69+ self .do_journal = do_journal == 'yes'
6870 def __repr__ (self ):
6971 return '<%s to "%s">' % (self .__class__ , self .classname )
7072
@@ -309,8 +311,9 @@ def create(self, **propvalues):
309311 propvalues [key ] = value
310312
311313 # register the link with the newly linked node
312- self .db .addjournal (link_class , value , 'link' ,
313- (self .classname , newid , key ))
314+ if self .properties [key ].do_journal :
315+ self .db .addjournal (link_class , value , 'link' ,
316+ (self .classname , newid , key ))
314317
315318 elif isinstance (prop , Multilink ):
316319 if type (value ) != type ([]):
@@ -336,8 +339,9 @@ def create(self, **propvalues):
336339 if not self .db .hasnode (link_class , id ):
337340 raise IndexError , '%s has no node %s' % (link_class , id )
338341 # register the link with the newly linked node
339- self .db .addjournal (link_class , id , 'link' ,
340- (self .classname , newid , key ))
342+ if self .properties [key ].do_journal :
343+ self .db .addjournal (link_class , id , 'link' ,
344+ (self .classname , newid , key ))
341345
342346 elif isinstance (prop , String ):
343347 if type (value ) != type ('' ):
@@ -505,15 +509,16 @@ class or a KeyError is raised.
505509 if not self .db .hasnode (link_class , value ):
506510 raise IndexError , '%s has no node %s' % (link_class , value )
507511
508- # register the unlink with the old linked node
509- if node [key ] is not None :
510- self .db .addjournal (link_class , node [key ], 'unlink' ,
511- (self .classname , nodeid , key ))
512+ if self .properties [key ].do_journal :
513+ # register the unlink with the old linked node
514+ if node [key ] is not None :
515+ self .db .addjournal (link_class , node [key ], 'unlink' ,
516+ (self .classname , nodeid , key ))
512517
513- # register the link with the newly linked node
514- if value is not None :
515- self .db .addjournal (link_class , value , 'link' ,
516- (self .classname , nodeid , key ))
518+ # register the link with the newly linked node
519+ if value is not None :
520+ self .db .addjournal (link_class , value , 'link' ,
521+ (self .classname , nodeid , key ))
517522
518523 elif isinstance (prop , Multilink ):
519524 if type (value ) != type ([]):
@@ -543,19 +548,22 @@ class or a KeyError is raised.
543548 if id in value :
544549 continue
545550 # register the unlink with the old linked node
546- self .db .addjournal (link_class , id , 'unlink' ,
547- (self .classname , nodeid , key ))
551+ if self .properties [key ].do_journal :
552+ self .db .addjournal (link_class , id , 'unlink' ,
553+ (self .classname , nodeid , key ))
548554 l .remove (id )
549555
550556 # handle additions
551557 for id in value :
552558 if not self .db .hasnode (link_class , id ):
553- raise IndexError , '%s has no node %s' % (link_class , id )
559+ raise IndexError , '%s has no node %s' % (
560+ link_class , id )
554561 if id in l :
555562 continue
556563 # register the link with the newly linked node
557- self .db .addjournal (link_class , id , 'link' ,
558- (self .classname , nodeid , key ))
564+ if self .properties [key ].do_journal :
565+ self .db .addjournal (link_class , id , 'link' ,
566+ (self .classname , nodeid , key ))
559567 l .append (id )
560568
561569 elif isinstance (prop , String ):
@@ -1047,6 +1055,10 @@ def Choice(name, *options):
10471055
10481056#
10491057# $Log: not supported by cvs2svn $
1058+ # Revision 1.49 2002/01/16 07:02:57 richard
1059+ # . lots of date/interval related changes:
1060+ # - more relaxed date format for input
1061+ #
10501062# Revision 1.48 2002/01/14 06:32:34 richard
10511063# . #502951 ] adding new properties to old database
10521064#
0 commit comments