@@ -938,28 +938,6 @@ def history(self, direction='descending', dre=re.compile('^\d+$'),
938938 if not self .is_view_ok ():
939939 return self ._ ('[hidden]' )
940940
941- # pre-load the history with the current state
942- current = {}
943- for prop_n in self ._props .keys ():
944- prop = self [prop_n ]
945- if not isinstance (prop , HTMLProperty ):
946- continue
947- current [prop_n ] = prop .plain (escape = 1 )
948- # make link if hrefable
949- if (prop_n in self ._props and
950- isinstance (self ._props [prop_n ], hyperdb .Link )):
951- classname = self ._props [prop_n ].classname
952- try :
953- template = self ._client .selectTemplate (classname , 'item' )
954- if template .startswith ('_generic.' ):
955- raise NoTemplate ('not really...' )
956- except NoTemplate :
957- pass
958- else :
959- id = self ._klass .get (self ._nodeid , prop_n , None )
960- current [prop_n ] = '<a rel="nofollow" href="%s%s">%s</a>' % (
961- classname , id , current [prop_n ])
962-
963941 # get the journal, sort and reverse
964942 history = self ._klass .history (self ._nodeid , skipquiet = (not showall ))
965943 history .sort (key = lambda a : a [:3 ])
@@ -971,6 +949,7 @@ def history(self, direction='descending', dre=re.compile('^\d+$'),
971949
972950 timezone = self ._db .getUserTimezone ()
973951 l = []
952+ current = {}
974953 comments = {}
975954 for id , evt_date , user , action , args in history :
976955 date_s = str (evt_date .local (timezone )).replace ("." ," " )
@@ -999,6 +978,28 @@ def history(self, direction='descending', dre=re.compile('^\d+$'),
999978 % (self ._ (k ), str (args [k ])))
1000979 continue
1001980
981+ # load the current state for the property (if we
982+ # haven't already)
983+ if k not in current :
984+ val = self [k ]
985+ if not isinstance (val , HTMLProperty ):
986+ current [k ] = None
987+ else :
988+ current [k ] = val .plain (escape = 1 )
989+ # make link if hrefable
990+ if (isinstance (prop , hyperdb .Link )):
991+ classname = prop .classname
992+ try :
993+ template = self ._client .selectTemplate (classname , 'item' )
994+ if template .startswith ('_generic.' ):
995+ raise NoTemplate ('not really...' )
996+ except NoTemplate :
997+ pass
998+ else :
999+ linkid = self ._klass .get (self ._nodeid , k , None )
1000+ current [k ] = '<a rel="nofollow" href="%s%s">%s</a>' % (
1001+ classname , linkid , current [k ])
1002+
10021003 if args [k ] and (isinstance (prop , hyperdb .Multilink ) or
10031004 isinstance (prop , hyperdb .Link )):
10041005 # figure what the link class is
@@ -1084,7 +1085,7 @@ def history(self, direction='descending', dre=re.compile('^\d+$'),
10841085 else :
10851086 old = label ;
10861087 cell .append ('%s: %s' % (self ._ (k ), old ))
1087- if k in current :
1088+ if k in current and current [ k ] is not None :
10881089 cell [- 1 ] += ' -> %s' % current [k ]
10891090 current [k ] = old
10901091
@@ -1095,49 +1096,49 @@ def history(self, direction='descending', dre=re.compile('^\d+$'),
10951096 d = date .Date (args [k ],
10961097 translator = self ._client ).local (timezone )
10971098 cell .append ('%s: %s' % (self ._ (k ), str (d )))
1098- if k in current :
1099+ if k in current and current [ k ] is not None :
10991100 cell [- 1 ] += ' -> %s' % current [k ]
11001101 current [k ] = str (d )
11011102
11021103 elif isinstance (prop , hyperdb .Interval ) and args [k ]:
11031104 val = str (date .Interval (args [k ],
11041105 translator = self ._client ))
11051106 cell .append ('%s: %s' % (self ._ (k ), val ))
1106- if k in current :
1107+ if k in current and current [ k ] is not None :
11071108 cell [- 1 ] += ' -> %s' % current [k ]
11081109 current [k ] = val
11091110
11101111 elif isinstance (prop , hyperdb .String ) and args [k ]:
11111112 val = cgi .escape (args [k ])
11121113 cell .append ('%s: %s' % (self ._ (k ), val ))
1113- if k in current :
1114+ if k in current and current [ k ] is not None :
11141115 cell [- 1 ] += ' -> %s' % current [k ]
11151116 current [k ] = val
11161117
11171118 elif isinstance (prop , hyperdb .Boolean ) and args [k ] is not None :
11181119 val = args [k ] and '' "Yes" or '' "No"
11191120 cell .append ('%s: %s' % (self ._ (k ), val ))
1120- if k in current :
1121+ if k in current and current [ k ] is not None :
11211122 cell [- 1 ] += ' -> %s' % current [k ]
11221123 current [k ] = val
11231124
11241125 elif isinstance (prop , hyperdb .Password ) and args [k ] is not None :
11251126 val = args [k ].dummystr ()
11261127 cell .append ('%s: %s' % (self ._ (k ), val ))
1127- if k in current :
1128+ if k in current and current [ k ] is not None :
11281129 cell [- 1 ] += ' -> %s' % current [k ]
11291130 current [k ] = val
11301131
11311132 elif not args [k ]:
1132- if k in current :
1133+ if k in current and current [ k ] is not None :
11331134 cell .append ('%s: %s' % (self ._ (k ), current [k ]))
11341135 current [k ] = '(no value)'
11351136 else :
11361137 cell .append (self ._ ('%s: (no value)' )% self ._ (k ))
11371138
11381139 else :
11391140 cell .append ('%s: %s' % (self ._ (k ), str (args [k ])))
1140- if k in current :
1141+ if k in current and current [ k ] is not None :
11411142 cell [- 1 ] += ' -> %s' % current [k ]
11421143 current [k ] = str (args [k ])
11431144
0 commit comments