@transaction.commit_on_success
def load_data_for_offline_install(in_file):
 assert os.path.exists(in_file), 'in_file must exist.'
 with open(in_file, 'r') as fp:
  models = deserialize(fp.read())
 try:
  central_server = models.next().object
 except Exception as e:
  logging.debug(('Exception loading central server object: %s' % e))
  return
 logging.debug(('Saving object %s' % central_server))
 assert isinstance(central_server, Device)
 central_server.save(imported=True, is_trusted=True)
 invitation = None
 for model in models:
  try:
   logging.debug(('Saving object %s' % model.object))
   model.object.save(imported=True)
   if isinstance(model.object, ZoneInvitation):
    invitation = model.object
    if (invitation.used_by is None):
     invitation.claim(used_by=Device.get_own_device())
  except ValidationError as e:
   logging.error(('Failed to import model %s' % model))
 return invitation

@ transaction . commit_on_success def load_data_for_offline_install ( in_file ) : assert os . path . exists ( in_file ) , 'in_file must exist.' with open ( in_file , 'r' ) as fp : models = deserialize ( fp . read ( ) ) try : central_server = models . next ( ) . object except Exception as e : logging . debug ( ( 'Exception loading central server object: %s' % e ) ) return logging . debug ( ( 'Saving object %s' % central_server ) ) assert isinstance ( central_server , Device ) central_server . save ( imported = True , is_trusted = True ) invitation = None for model in models : try : logging . debug ( ( 'Saving object %s' % model . object ) ) model . object . save ( imported = True ) if isinstance ( model . object , ZoneInvitation ) : invitation = model . object if ( invitation . used_by is None ) : invitation . claim ( used_by = Device . get_own_device ( ) ) except ValidationError as e : logging . error ( ( 'Failed to import model %s' % model ) ) return invitation
receives a serialized file for import .