def print_form(n, f, OUT):
 if f.name:
  print >>OUT, ('\nForm name=%s (#%d)' % (f.name, (n + 1)))
 else:
  print >>OUT, ('\nForm #%d' % ((n + 1),))
 if f.controls:
  print >>OUT, '## ## __Name__________________ __Type___ __ID________ __Value__________________'
 submit_indices = {}
 n = 1
 for c in f.controls:
  if c.is_of_kind('clickable'):
   submit_indices[c] = n
   n += 1
 clickies = [c for c in f.controls if c.is_of_kind('clickable')]
 nonclickies = [c for c in f.controls if (c not in clickies)]
 for (n, field) in enumerate(f.controls):
  if hasattr(field, 'items'):
   items = [i.name for i in field.items]
   value_displayed = ('%s of %s' % (field.value, items))
  else:
   value_displayed = ('%s' % (field.value,))
  if field.is_of_kind('clickable'):
   submit_index = ('%-2s' % (submit_indices[field],))
  else:
   submit_index = '  '
  strings = (('%-2s' % ((n + 1),)), submit_index, ('%-24s %-9s' % (trunc(str(field.name), 24), trunc(field.type, 9))), ('%-12s' % (trunc((field.id or '(None)'), 12),)), trunc(value_displayed, 40))
  for s in strings:
   print >>OUT, s,
  print >>OUT, ''
 print ''

def print_form ( n , f , OUT ) : if f . name : print >> OUT , ( '\nForm name=%s (#%d)' % ( f . name , ( n + 1 ) ) ) else : print >> OUT , ( '\nForm #%d' % ( ( n + 1 ) , ) ) if f . controls : print >> OUT , '## ## __Name__________________ __Type___ __ID________ __Value__________________' submit_indices = { } n = 1 for c in f . controls : if c . is_of_kind ( 'clickable' ) : submit_indices [ c ] = n n += 1 clickies = [ c for c in f . controls if c . is_of_kind ( 'clickable' ) ] nonclickies = [ c for c in f . controls if ( c not in clickies ) ] for ( n , field ) in enumerate ( f . controls ) : if hasattr ( field , 'items' ) : items = [ i . name for i in field . items ] value_displayed = ( '%s of %s' % ( field . value , items ) ) else : value_displayed = ( '%s' % ( field . value , ) ) if field . is_of_kind ( 'clickable' ) : submit_index = ( '%-2s' % ( submit_indices [ field ] , ) ) else : submit_index = '  ' strings = ( ( '%-2s' % ( ( n + 1 ) , ) ) , submit_index , ( '%-24s %-9s' % ( trunc ( str ( field . name ) , 24 ) , trunc ( field . type , 9 ) ) ) , ( '%-12s' % ( trunc ( ( field . id or '(None)' ) , 12 ) , ) ) , trunc ( value_displayed , 40 ) ) for s in strings : print >> OUT , s , print >> OUT , '' print ''
dump the contents of a form as html .