def get_old_document(resource, req, lookup, document, version):
 if ((version != 'all') and (version != 'diffs') and (version is not None)):
  try:
   version = int(version)
   assert (version > 0)
  except (ValueError, BadRequestKeyError, AssertionError):
   abort(400, description=debug_error_message('Document version number should be an int greater than 0'))
  resource_def = config.DOMAIN[resource]
  if (versioned_id_field(resource_def) not in lookup):
   lookup[versioned_id_field(resource_def)] = lookup[resource_def['id_field']]
   del lookup[resource_def['id_field']]
  lookup[config.VERSION] = version
  delta = app.data.find_one((resource + config.VERSIONS), req, **lookup)
  if (not delta):
   abort(404)
  old_document = synthesize_versioned_document(document, delta, resource_def)
 else:
  old_document = document.copy()
 return old_document

def get_old_document ( resource , req , lookup , document , version ) : if ( ( version != 'all' ) and ( version != 'diffs' ) and ( version is not None ) ) : try : version = int ( version ) assert ( version > 0 ) except ( ValueError , BadRequestKeyError , AssertionError ) : abort ( 400 , description = debug_error_message ( 'Document version number should be an int greater than 0' ) ) resource_def = config . DOMAIN [ resource ] if ( versioned_id_field ( resource_def ) not in lookup ) : lookup [ versioned_id_field ( resource_def ) ] = lookup [ resource_def [ 'id_field' ] ] del lookup [ resource_def [ 'id_field' ] ] lookup [ config . VERSION ] = version delta = app . data . find_one ( ( resource + config . VERSIONS ) , req , ** lookup ) if ( not delta ) : abort ( 404 ) old_document = synthesize_versioned_document ( document , delta , resource_def ) else : old_document = document . copy ( ) return old_document
returns an old document if appropriate .