def show_model_changes(new, old=None, fields=None, always=False):
 old = (old or new._db._get(type(new), new.id))
 changes = []
 for field in old:
  if ((field == 'mtime') or (fields and (field not in fields))):
   continue
  line = _field_diff(field, old, new)
  if line:
   changes.append(u'  {0}: {1}'.format(field, line))
 for field in (set(new) - set(old)):
  if (fields and (field not in fields)):
   continue
  changes.append(u'  {0}: {1}'.format(field, colorize('red', new.formatted()[field])))
 if (changes or always):
  print_obj(old, old._db)
 if changes:
  print_(u'\n'.join(changes))
 return bool(changes)

def show_model_changes ( new , old = None , fields = None , always = False ) : old = ( old or new . _db . _get ( type ( new ) , new . id ) ) changes = [ ] for field in old : if ( ( field == 'mtime' ) or ( fields and ( field not in fields ) ) ) : continue line = _field_diff ( field , old , new ) if line : changes . append ( u'  {0}: {1}' . format ( field , line ) ) for field in ( set ( new ) - set ( old ) ) : if ( fields and ( field not in fields ) ) : continue changes . append ( u'  {0}: {1}' . format ( field , colorize ( 'red' , new . formatted ( ) [ field ] ) ) ) if ( changes or always ) : print_obj ( old , old . _db ) if changes : print_ ( u'\n' . join ( changes ) ) return bool ( changes )
given a model object .