1- import sys , cgi , urllib
1+ import sys , cgi , urllib , os
22
33from roundup import hyperdb , date
44from roundup .i18n import _
@@ -203,6 +203,12 @@ def classhelp(self, properties, label='?', width='400', height='400'):
203203 'properties=%s\' , \' %s\' , \' %s\' )"><b>(%s)</b></a>' % (self .classname ,
204204 properties , width , height , label )
205205
206+ def submit (self , label = "Submit New Entry" ):
207+ ''' Generate a submit button (and action hidden element)
208+ '''
209+ return ' <input type="hidden" name=":action" value="new">\n ' \
210+ ' <input type="submit" name="submit" value="%s">' % label
211+
206212 def history (self ):
207213 return 'New node - no history'
208214
@@ -265,6 +271,12 @@ def __getattr__(self, attr):
265271
266272 # no good
267273 raise AttributeError , attr
274+
275+ def submit (self , label = "Submit Changes" ):
276+ ''' Generate a submit button (and action hidden element)
277+ '''
278+ return ' <input type="hidden" name=":action" value="edit">\n ' \
279+ ' <input type="submit" name="submit" value="%s">' % label
268280
269281 # XXX this probably should just return the history items, not the HTML
270282 def history (self , direction = 'descending' ):
@@ -305,8 +317,8 @@ def history(self, direction='descending'):
305317 # try to get the relevant property and treat it
306318 # specially
307319 try :
308- prop = props [k ]
309- except :
320+ prop = self . props [k ]
321+ except KeyError :
310322 prop = None
311323 if prop is not None :
312324 if args [k ] and (isinstance (prop , hyperdb .Multilink ) or
@@ -320,9 +332,9 @@ def history(self, direction='descending'):
320332 comments [classname ] = _ ('''The linked class
321333 %(classname)s no longer exists''' )% locals ()
322334 labelprop = linkcl .labelprop (1 )
323- # hrefable = os.path.exists(
324- # os.path.join(self.instance .TEMPLATES,
325- # classname+'.item'))
335+ hrefable = os .path .exists (
336+ os .path .join (self .db . config .TEMPLATES ,
337+ classname + '.item' ))
326338
327339 if isinstance (prop , hyperdb .Multilink ) and \
328340 len (args [k ]) > 0 :
@@ -349,9 +361,9 @@ def history(self, direction='descending'):
349361 exists</strike>''' )
350362 subml .append ('<strike>%s</strike>' % label )
351363 else :
352- # if hrefable:
353- subml .append ('<a href="%s%s">%s</a>' % (
354- classname , linkid , label ))
364+ if hrefable :
365+ subml .append ('<a href="%s%s">%s</a>' % (
366+ classname , linkid , label ))
355367 ml .append (sublabel + ', ' .join (subml ))
356368 cell .append ('%s:\n %s' % (k , ', ' .join (ml )))
357369 elif isinstance (prop , hyperdb .Link ) and args [k ]:
0 commit comments