Purpose unknown

@param {String} path - The app name.
@param {unknown} session unknown
@param {unknown} controller unknown
@param {unknown} sessions unknown

@returns {unknown} unknown
967882
function restoreSession(path, session, controller, sessions) {
    let ourObjectTemplate = getObjectTemplate(controller);

    ourObjectTemplate.withoutChangeTracking(function callBack() {
        let sessionData = getSessionCache(path, ourObjectTemplate.controller.__sessionId, true, sessions);
        // Will return in exising controller object because createEmptyObject does so
        let unserialized = session.semotus.controllers[path];

        controller = ourObjectTemplate.fromJSON(
            decompressSessionData(unserialized.controller),
            controller.__template__
        );

        if (unserialized.serializationTimeStamp !== sessionData.serializationTimeStamp) {
            ourObjectTemplate.logger.warn({
                component: 'amorphic',
                module: 'restoreSession',
                activity: 'restore',
                savedAs: sessionData.serializationTimeStamp,
                foundToBe: unserialized.serializationTimeStamp
            }, 'Session data not as saved');
        }

        if (session.semotus.objectMap && session.semotus.objectMap[path]) {
            ourObjectTemplate.objectMap = session.semotus.objectMap[path];
        }

        ourObjectTemplate.logger.info({component: 'amorphic', module: 'restoreSession', activity: 'restoring'});
        ourObjectTemplate.syncSession();  // Clean tracking of changes
    });

    return controller;
}
321129
function (path) {
		filesThatExist.push(path);

		var mockGetConfig = {
			handler: function (req, res, params) {
				return params;
			},
		};

		spyOn(mockGetConfig, 'handler').and.callThrough();
		
		registerRequireMock(testObject._formatPathForRequire(path), function () {
			return mockGetConfig;
		});

		return mockGetConfig;
	}
1009110
function Application(domain, path) {
   
   // Late instantiation. This is to make sure
   // the app singleton is created and referenced by others
   // before the object is properly instantiated.

   this.IPC_TOKEN = IPC_TOKEN;

   this.loadSelf = function() {
     
    app = this;

    this.inflect = protos.inflect;

    var self = this;
    
    // Set environment
    Object.defineProperty(this, 'environment', {
      value: protos.environment,
      writable: false,
      enumerable: true,
      configurable: false
    });
     
    // Cluster object
    this.cluster = cluster;

    // Application's Hostname
    this.hostname = domain;

    // Domain that will be used to generate cookies, instead
    // of the original application's domain name.
    this.cookieDomain = null;

    // Path where the application is located
    this.path = path;

    // Application's Classname
    this.className = this.constructor.name;

    // Boolean value indicating whether or not the application has initialized
    this.initialized = false;

    // Directory to store the models, views, controllers & helpers
    // Defaults to skeleton root. Must start/end with a slash.
    this.mvcpath = path + '/app/';

    // Application's API. Groups methods related to the application.
    // The API object gets its methods from the files in the api/ directory.
    this.api = {};

    // Application paths. These define where the several application files be stored
    // within the application directory structure.
    this.paths = {
      api: 'api/',
      data: 'data/',
      layout: '__layout/',
      restricted: '__restricted/',
      static: '__static/',
      public: 'public/',
      upload: 'upload/',
      environment: 'env/',
      extensions: 'ext/',
      templates: 'templates/'
    }

    /*
      Contains the view data for the application

      static: Static view paths
      buffers: Template sources
      callbacks: Rendered template functions
      partials: Rendered template partials
    */  

    this.views = {
      static: [],
      buffers: {},
      callbacks: {},
      partials: {}
    }

    // If set to true, the application will print log messages on stdout.
    this.logging = true;

    // If set to true, the application will print debug messages on stdout.
    this.debugLog = protos.config.bootstrap.debugLog ? true : false;

    // If set to true, the application will cache the rendered views, to optimize performance.
    this.viewCaching = false;

    // Login URL to use when redirecting unauthenticated users.
    this.loginUrl = '/login';

    // Debug color to use on the console
    this.debugColor = protos.config.bootstrap.debugColor || '0;37';

    // Application templates
    this.templates = {};

    // Application hooks. Callbacks to run on specific events
    this.hooks = {};

    // Driver instances
    this.drivers = {};

    // Storage instances
    this.storages = {};

    // Helper instances
    this.helpers = {};

    // Controller instances
    this.controllers = {};

    // Controller handlers
    this.handlers = {};

    // Model method aliases
    this.model = {}; // Contains model method aliases

    // Model instances
    this.models = {}; // Contains model instances

    // Engine instances
    this.engines = {};
    
    this.noop = protos.noop;

    this.defaultEngine = null;

    this.loadedEngines = [];

    this.config = {};

    this.locals = {};

    this.routes = {};

    this.httpMethods = protos.httpMethods;

    this.httpStatusCodes = http.STATUS_CODES;

    // Stores booleans with middleware support/availability information.
    // This property is manipulated by middleware.

    this.supports = {};

    // To be used by middleware to store objects
    this.resources = {};

    // Store filters
    this.__filters = {};

    // Store data
    this.__data = {};

    /*
      Execution state for tasks. Keys represent the
      task ID's and their respective values are booleans.

      The boolean values will determine if the task's
      callback will be executed (when the task's state
      is checked on a specific iteration)
    */

    this.__jobExecutionState = {};

    // Task Interval IDs. Can be passed to clearInterval to
    // disable the tasks permanently.

    this.__jobIntervalIDs = {};

    // Object containing each of the invalidation callbacks for each cache key
    this.__jobInvalidationCallbacks = {};

    /////////////////////////////

    // Attach configuration
    this.config = parseConfig.call(this);

    // Verify that regexes are valid

    if (!this.config.regex) this.config.regex = {};

    for (var r in this.config.regex) {

      if (r in protos.regex) {
        this.debug("Warning: regex has been overridden: %s", r);
      }

      var re = this.config.regex[r].toString();

      if (!protos.regex.validRegex.test(re)) {
        throw new Error(util.format("\
Bad regular expression in app.config.regex, where %s => %s\n\n\
%s\n", r, re, protos.i18n.badRegularExpression));
      }

    }

    /////////////////////////////

    this.regex = _.extend(this.config.regex, protos.regex);

    // Structure application's baseUrl
    
    var portSuffix = protos.config.bootstrap.server.portSuffix;
    var listenPort = protos.config.server.listenPort;
    var securePort = protos.config.bootstrap.server.useSSL ? protos.config.bootstrap.ssl.port : null;
    
    if (portSuffix || portSuffix === undefined) {
      // If portSuffix is undefined it means the boot.js file does not have it defined, therefore
      // it should be assumed as defined, since this is the default behavior.
      var portStr = (listenPort !== 80) ? util.format(':%s', listenPort) : '';
      var securePortStr = (securePort !== 443) ? util.format(':%s', securePort) : '';
    } else {
      portStr = securePortStr = '';
    }
    
    this.baseUrl = util.format('http://%s%s', this.hostname, portStr);
    this.baseUrlSecure = util.format('https://%s%s', this.hostname, securePortStr);

    var useSSL = protos.config.useSSL;
    var ssl = protos.config.bootstrap.ssl;

    var serverCallback = function(req, res) {
      req.startTime = Date.now();
      self.routeRequest(req, res);
    }

    this.server = http.createServer(serverCallback);

    if (useSSL && ssl) {
      var sslServerOpts = {
        key: fs.readFileSync(this.fullPath(ssl.key), 'utf8'),
        cert: fs.readFileSync(this.fullPath(ssl.cert), 'utf8')
      }
      this.secureServer = require('https').createServer(sslServerOpts, serverCallback);
    }

    // Load protos components
    var componentsCb = (protos.config.bootstrap.events && protos.config.bootstrap.events.components);
    if (componentsCb instanceof Function) {
      componentsCb.call(protos, protos);
    }

    // Emit protos bootstrap event
    protos.emit('bootstrap', this);

    // Set worker message listener (messages from workers to master)
    // Runs messages formatted as [method, arg1, arg2, ... argn],
    // assuming 'method' is an actual method existing in app
    // This is internal, not intended for use in apps (unless you really know what you're doing)

    this.on('worker_message', function(msg) {
      if (msg instanceof Array) {
        var token = msg[0];
        if (token === IPC_TOKEN) {
          var method = msg[1];
          if (app[method] instanceof Function) {
            try {
              app[method].apply(app, msg.slice(2));
            } catch(err) {
              (app.errorLog || app.log)(err);
            }
          }
        }
      }
    });
    
    // Set master message listener (messages from master to workers)
    // Runs messages formatted as [method, arg1, arg2, ... argn],
    // assuming 'method' is an actual method existing in app
    // This is internal, not intended for use in apps (unless you really know what you're doing)

    this.on('master_message', function(msg) {
      if (msg instanceof Array) {
        var token = msg[0];
        if (token === IPC_TOKEN) {
          var method = msg[1];
          if (app[method] instanceof Function) {
            try {
              app[method].apply(app, msg.slice(2));
            } catch(err) {
              (app.errorLog || app.log)(err);
            }
          }
        }
      }
    });
    
    // Load data
    loadData.call(this);

    // Load hooks
    loadHooks.call(this);
    
    // Emit env data hook
    this.emit('env_data_loaded', protos.__envData);
    
    // Emit app's pre_init event (needs to be called after loading hooks)
    // to be able to use hooks/pre_init.js on the app
    this.emit('pre_init', this);

    // Run initialization code
    this.initialize();

  }

}
938539
function(actionName, action, resourcePath) {
		// prefix function to set rest values
		var identify = function(req, res, next) {
			res.set('XX-Powered-By', 'Restpress');
			req.resource = self;
			req.actionName = actionName;
			req.action = action;
			next();
		};

		self[actionName] = function() {
			if (identify) {
				// insert identify as second argument
				// This is to be done only once
				[].unshift.call(arguments, identify);
				identify = null;
			}

			// insert actionPath as first argument
			[].unshift.call(arguments, resourcePath + action.route);

			// Hack for restify where 'delete' method is 'del'
			var appMethod = action.method;
			if (appMethod == 'delete' &&
					typeof self.app[appMethod] !== 'function' &&
					typeof self.app['del'] === 'function') {
					appMethod = 'del';
			}

			// Call express app VERB function
			self.app[appMethod].apply(self.app, arguments);
			
			// return this for chaining
			return self;
		};
	}
291295
function getController (method, path, role) {
    // if path does not exist return
    if (!this.paths[path]) {
        return
    }
    // if method does not exist return
    if (!this.paths[path][method]) {
        return
    }
    // set role to default if not defined
    if (role === undefined) {
        role = 'all'
    }
    // find controller matching role
    return _.find(this.paths[path][method], controller => {
        return controller.role === role ? true : false
    })
}
1248976
function(path) {
        let req = null;
        let i;
        let j;
        let matchingReq = null;
        let expectedReq = null;
        let testResponse = null;
        for (i = 0; i < this.requests.length; i++) {
            req = this.requests[i];
            for (j = 0; j < this.expectedRequests.length; j++) {
                expectedReq = this.expectedRequests[j];
                if (path && path !== expectedReq.path) {
                    continue;
                }
                if (expectedReq.method === req.method &&
                        req.path.indexOf(expectedReq.path) !== -1) {
                    if (!expectedReq.data || (JSON.stringify(expectedReq.data) ===
                            JSON.stringify(req.data))) {
                        matchingReq = expectedReq;
                        this.expectedRequests.splice(j, 1);
                        break;
                    }
                }
            }

            if (matchingReq) {
                // remove from request queue
                this.requests.splice(i, 1);
                i--;

                for (j = 0; j < matchingReq.checks.length; j++) {
                    matchingReq.checks[j](req);
                }
                testResponse = matchingReq.response;
                console.log(`${Date.now()}    responding to ${matchingReq.path}`);

                let body = testResponse.body;
                if (Object.prototype.toString.call(body) == "[object Function]") {
                    body = body(req.path, req.data, req);
                }

                if (!testResponse.rawBody) {
                    body = JSON.stringify(body);
                }
                req.callback(
                    testResponse.err, testResponse.response, body,
                );
                matchingReq = null;
            }
        }
        if (testResponse) {  // flushed something
            return true;
        }
        return false;
    }
1088858
public void createSession(String sessionId) {
        boolean newSession = sessionId == null;
        sessionId = newSession ? newSessionId() : sessionId;
        SessionController controller = sessions.get(sessionId);
        
        if (controller == null) {
            controller = SessionController.create(sessionId, newSession);
            sessions.put(sessionId, controller);
        }
    }
826801
public function initController($controller, $path)
    {
        if($path)
        {
            $controller = $this->name . '\\Controller\\' . $path . '\\' . $controller;
        }
        else
        {
            $controller = $this->name . '\\Controller\\' . $controller;
        }

        return new $controller();
    }
357935
function(path) {
                var pathParts = this.getPathParts(path),
                    tabs,
                    page;
                if (pathParts.length === 0) {
                    return;
                }
                page = pathParts[0];
                if (!page) {
                    return;
                }
                if (page === 'examples' && pathParts.length > 1) {
                    tabs = [];
                    tabs.push('app/examples/' + pathParts[1] + '.html');
                    tabs.push('app/examples/' + pathParts[1] + '.js');
                    return tabs;
                }
            }
1191100
def new_session
      app = Rails.application
      session = ActionDispatch::Integration::Session.new(app)
      yield session if block_given?

      # This makes app.url_for and app.foo_path available in the console
      session.extend(app.routes.url_helpers)
      session.extend(app.routes.mounted_helpers)

      session
    end
662473
function saveSession(path, session, controller, req, sessions) {
    let request = controller.__request;
    controller.__request = null;

    let time = process.hrtime();

    let ourObjectTemplate = getObjectTemplate(controller);

    let serialSession;

    if (typeof(ourObjectTemplate.serializeAndGarbageCollect) === 'function') {
        serialSession = ourObjectTemplate.serializeAndGarbageCollect();
    }
    else {
        serialSession = controller.toJSONString();
    }

    // Track the time of the last serialization to make sure it is valid
    let sessionData = getSessionCache(path, ourObjectTemplate.controller.__sessionId, true, sessions);
    sessionData.serializationTimeStamp = (new Date ()).getTime();

    session.semotus.controllers[path] = {controller: compressSessionData(serialSession),
        serializationTimeStamp: sessionData.serializationTimeStamp};

    session.semotus.lastAccess = new Date(); // Tickle it to force out cookie

    if (ourObjectTemplate.objectMap) {
        if (!session.semotus.objectMap) {
            session.semotus.objectMap = {};
        }

        session.semotus.objectMap[path] = ourObjectTemplate.objectMap;
    }

    req.amorphicTracking.addServerTask(
        {
            name: 'Save Session',
            size: session.semotus.controllers[path].controller.length
        },
        time);

    controller.__request = request;
}
338771
function Routing(app) {
	var config, defaultController;

	/**
	 * Find the action function based on controller name and action name.
	 * If no controller but a model is found, the default controller is taken.
	 * @param  {String} controllerName controller name
	 * @param  {String} actionName     action name
	 * @return {Function}              action function
	 */
	function getAction(controllerName, actionName) {
		controllerName = controllerName.camelize();
		var controller = app.controllers[controllerName];
		if (controller === undefined && app.models[controllerName])
			controller = defaultController;

		if (controller)
			return controller[actionName || 'index'];
		else
			return null;
	}

	/**
	 * adds a single route
	 * @param {String} verb           HTTP verb
	 * @param {String} routePath      routing path
	 * @param {String} controllerName controller name
	 * @param {String} actionName     action name
	 */
	function addSingleRoute(verb, routePath, controllerName, actionName) {
		// add controller and action fields to the request
		var reqExtender = function(req, res, next) {
			req.controller = controllerName;
			req.action = actionName || 'index';
			next();
		};

		var params = [routePath, reqExtender];
		params = params.concat(getPolicies(controllerName, actionName));
		params.push(getAction(controllerName, actionName));

		app[verb].apply(app, params);
	}

	/**
	 * gets the policies in effect for a given controller and action
	 * @param  {String} controller
	 * @param  {String} action
	 * @return {Array}            policies
	 */
	function getPolicies(controller, action) {
		var policies = config.policies;
		var currentPolicies = [];
		if (policies[controller] && policies[controller][action]) {
			currentPolicies = policies[controller][action];
		} else if (Object.isString(policies[controller])) {
			currentPolicies = policies[controller];
		} else if (policies[controller] && policies[controller]['*']) {
			currentPolicies = policies[controller]['*'];
		} else if (policies['*']) {
			currentPolicies = policies['*'];
		}

		if (currentPolicies === true) {
			currentPolicies = [];
		}

		if (!Object.isArray(currentPolicies)) {
			currentPolicies = [currentPolicies];
		}

		currentPolicies = currentPolicies.map(function(policy) {
			var policyPath = path.join(config.rootDir, config.paths.policies, policy);
			return require(policyPath);
		});
		return currentPolicies;
	}

	/**
	 * parse the resource route definitions
	 */
	var resourceRouting;
	function parseResourceRoutes() {
		var routes = config.resourceRouting;
		resourceRouting = [];
		for (var route in routes) {
			var parsedRoute = parseRoute(route, routes[route]);
			// if it's a string it defines the action
			if (Object.isString(parsedRoute.target)) {
				parsedRoute.target = {action: parsedRoute.target};
			}
			resourceRouting.push(parsedRoute);
		}
	}

	/**
	 * add a resource route
	 * @param {String} routePath      route path
	 * @param {String} controllerName controller name
	 */
	function addResourceRoute(routePath, controllerName) {
		resourceRouting.forEach(function(route) {
			var actionPath = route.path.replace(':controller', controllerName);
			route.verbs.forEach(function (verb) {
				addSingleRoute(verb, actionPath, controllerName, route.target.action);
			});
		});
	}

	/**
	 * add a static route
	 * @param {String} routePath route path
	 * @param {String} target    target path (relative to the scarab root)
	 */
	function addStaticRoute(routePath, targets) {
		if (!Object.isArray(targets)) {
			targets = [targets];
		}
		targets.forEach(function(target) {
			if (target)
				app.use(routePath, app.middleware.static(path.resolve(config.rootDir, target)));
		});
	}

	function addRedirectRoute(verb, routePath, target) {
		app[verb](routePath, function(req, res) {
			res.redirect(target);
		});
	}

	/**
	 * apply the path policies (for static routes)
	 */
	function applyPathPolicies() {
		var allPolicies = [];
		for (var routePath in config.policies) {
			if (routePath.charAt(0) === '/') {
				var currentPolicies = config.policies[routePath];
				if (currentPolicies === true) {
					currentPolicies = [];
				}
				if (!Object.isArray(currentPolicies)) {
					currentPolicies = [currentPolicies];
				}
				allPolicies.push({route: routePath, policies: currentPolicies});
			}
		}
		allPolicies.forEach(function(pathPolicy) {
			pathPolicy.policies.forEach(function(policy) {
				var policyPath = path.join(config.rootDir, config.paths.policies, policy);
				app.all(pathPolicy.route, require(policyPath));
			});
		});
	}

	/**
	 * parse a route
	 * @param  {String} route  a route definition
	 * @param  {Object} target target definition
	 * @return {Object}        route parsed into verbs, path and target
	 */
	function parseRoute(route, target) {
		var verbs, routePath, routeParts;

		routeParts = route.split(' ');
		if (routeParts.length === 1) {
			verbs = ['all'];
			routePath = routeParts[0];
		} else {
			verbs = routeParts[0].split(',');
			verbs.map(function (verb) {
				return verb.trim().toLowerCase();
			});
			routePath = routeParts[1];
		}
		return {verbs: verbs, path: routePath, target: target};
	}

	/**
	 * initializes all routes
	 */
	function init() {
		config = app.config;

		defaultController = config.defaultControllerFactory(app.models);

		// load controllers
		var controllerDir = path.join(config.rootDir, config.paths.controllers);
		var controllerFiles = fs.readdirSync(controllerDir);
		controllerFiles.forEach(function(controllerFile) {
			var controllerName = controllerFile.substring(0, controllerFile.indexOf('Controller'));
			var controllerDef = require(path.join(controllerDir, controllerFile));
			var controller;
			if (controllerDef.noDefaultActions) {
				controller = controllerDef;
			} else {
				controller = Object.create(defaultController);
				controller = Object.merge(controller, controllerDef);
			}
			app.controllers[controllerName] = controller;
		});

		applyPathPolicies();

		var routes = config.routes,
			parsed = [];

		parseResourceRoutes();

		for (var route in routes) {
			parsed.push(parseRoute(route, routes[route]));
		}

		parsed.forEach(function(route) {
			if(!route.target)
				return;

			if (Object.isString(route.target)) {
				if (route.verbs[0] !== 'static' && route.target.charAt(0) === '/') {
					route.target = {redirect: route.target};
				} else {
					var parts = route.target.split('.');
					if (parts.length === 2) {
						route.target = {controller: parts[0], action: parts[1]};
					}
				}
			}
			if (!Object.isObject(route.target)) {
				route.target = {controller: route.target};
			}

			route.verbs.forEach(function (verb) {
				if (verb === 'resource') {
					addResourceRoute(route.path, route.target.controller);
				} else if (verb === 'static') {
					addStaticRoute(route.path, route.target.controller);
				} else if (route.target.redirect) {
					addRedirectRoute(verb, route.path, route.target.redirect);
				} else {
					addSingleRoute(verb, route.path, route.target.controller, route.target.action);
				}
			});
		});

		if(config.autoRoute) {
			resourceRouting.forEach(function(route) {
				var actionPath = path.join('/', config.autoRoutePath, route.path);
				route.verbs.forEach(function (verb) {
					app[verb](actionPath, function(req, res, next) {
						var controllerName = req.params.controller.singularize();
						var actionName = route.target.action;
						req.controller = controllerName;
						req.action = actionName;

						var action = getAction(controllerName, actionName);
						if (action) {
							var policies = getPolicies(controllerName, actionName);
							if (policies.length > 0) {
								var policyIdx = 0;
								var nextPolicy = function() {
									policyIdx++;
									if (policyIdx < policies.length) {
										policies[policyIdx](req, res, nextPolicy);
									} else {
										action(req, res, next);
									}
								};
								policies[0](req, res, nextPolicy);
							} else {
								action(req, res, next);
							}
						} else {
							next();
						}
					});
				});
			});
		}
	}

	return {
		init: init
	};
}
984132
public Response head(Session session, String path, String baseURI)
   {
      try
      {
         Node node = (Node)session.getItem(path);

         WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session);
         URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true));

         if (ResourceUtil.isFile(node))
         {
            Resource resource = new FileResource(uri, node, nsContext);

            String lastModified = resource.getProperty(PropertyConstants.GETLASTMODIFIED).getValue();
            String contentType = resource.getProperty(PropertyConstants.GETCONTENTTYPE).getValue();
            String contentLength = resource.getProperty(PropertyConstants.GETCONTENTLENGTH).getValue();

            return Response.ok().header(ExtHttpHeaders.LAST_MODIFIED, lastModified).header(ExtHttpHeaders.CONTENT_TYPE,
               contentType).header(ExtHttpHeaders.CONTENT_LENGTH, contentLength).build();
         }

         return Response.ok().build();
      }
      catch (PathNotFoundException exc)
      {
         return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build();
      }
      catch (Exception exc)
      {
         LOG.error(exc.getMessage(), exc);
         return Response.serverError().entity(exc.getMessage()).build();
      }
   }
67738
function (path, timeout) {
    return this.execute(function (path) {
      Router.go(path);
    }, [ path ])
    .wait(timeout || DEFAULT_TIMEOUT, 'until current path is ' + path, function (path) {
      
      var controller = Router.current();
      var pathOK = (window.location.pathname + window.location.search + window.location.hash === path);

      if (controller && pathOK && controller.ready()) {
        return true;
      } else {
        Router.go(path);
      }
    }, [ path ]);
  }
678285
function findPage(pages, path) {
  const p = path.shift();
  const page = pages.find(page => page.path === p);

  if (!page) {
    return {redirect: getDefaultPath(pages)};
  }
  if (page.children) {
    const result = findPage(page.children, path);
    if (result.page) {
      return result;
    }
    return {redirect: [p].concat(result.redirect)};
  }
  if (path.length) {
    return {redirect: []};
  }
  return {page};
}
1076067
function loadpage(path, vars, user, newvalue) {
  // __dirname = path.resolve(); // If in the REPL
  if(typeof vars != "object") vars = {};
  var serverFileContent = readServerFile();
  var env = {
      googleClientId: googleClientId,
      vars: vars,
      user: toLeoQuery(user || {}),
      defaultOptions: toLeoQuery(defaultOptions),
      path: path,
      fileOperations: [] };
  
  if(typeof newvalue == "undefined") {
    return [evaluateToHtml(path, env, serverFileContent), vars];
  } else { // We update the page and re-render it.
    var newVal = sns.nativeToVal(newvalue);
    console.log("Started to update...");
    var result = sns.objEnv.string.update(env)(serverFileContent)(newVal);
    console.log("Update finished (first solution)");
    if(result.ctor == "Ok") {
      var allSolutions = result._0;
      // Instead of iterating through all the solutions, just detect if there is an ambiguity.
      var solution = getOneSolution(path, serverFileContent, allSolutions);
      if(solution === false) {
        return [{ctor: "Err", _0: "Empty list of solutions"}];
      } else {
        console.log("Checking for ambiguities");
        var allSolutionsTail = sns.lazyList.tail(allSolutions);
        var solution2 = getOneSolution(path, serverFileContent, allSolutionsTail);
        if(solution2 === false) { // No ambiguity, we can immediately process the change.
          console.log("No ambiguity");
          return solution;
        } else {
          console.log("Ambiguity found");
          var solutionKey = uniqueKey();
          var cachedSolution = {
              timestamp: (+ new Date()),
              computed: [solution, solution2],
              remaining: allSolutionsTail,
              path: path,
              serverFileContent: serverFileContent
          }
          cachedSolutions[solutionKey] = cachedSolution;
          return solution.concat(solutionKey);
        }
      }
    } else return [result];
  }
}
650289
function(route, container) {

    var appName, routeName,
        isService = (container !== this.config.container),
        isError = (route === ERROR_ROUTE_NAME);

    // Normalize Route
    route || (route = '');

    // Get the app name from this route
    appName = routeName = (route.split('/')[0] || 'index');

    // If this isn't the error route, Find Any Custom Route Mappings
    if(!isService && !isError){
      this._currentRoute = route.split('/')[0];
      _.any(this.config.handlers, (handler) => {
        if (handler.regex.test(route)){
          appName = handler.app;
          this._currentRoute = handler.route;
          return true;
        }
      });
    }

    // Wrap these async resource fetches in a promise and return it.
    // This promise resolves when both css and js resources are loaded
    // It rejects if either of the css or js resources fails to load.
    return new Promise((resolve, reject) => {

      var throwError = (err) => {
        // If we are already in an error state, this means we were unable to load
        // a custom error page. Uninstall anything we have and insert our default 404 page.
        if(this.status === ERROR){
          if(isService) return resolve(err);
          this._uninstallResource();
          container.innerHTML = DEFAULT_404_PAGE;
          return resolve(err);
        }

        // Set our status to error and attempt to load a custom error page.
        console.error('Could not ' + ((isService) ? 'load the ' + appName + ' service:' : 'find the ' + (appName || 'index') + ' app.'), 'at', ('/' + route));
        this.status = ERROR;
        this._currentRoute = route;
        resolve(this._fetchResource(ERROR_ROUTE_NAME, container));
      };

      // If the values we got from installing our resources are unexpected, 404
      // Otherwise, set status, activate the css, and install the page component
      var install = (response) => {
        var cssElement = response[0], jsElement = response[1];
        if(!(cssElement instanceof Element) || !(jsElement instanceof Element) ) return throwError();
        (!isService && !isError) && (this.status = SUCCESS);
        cssElement && cssElement.removeAttribute('disabled');
        this._installResource(jsElement.getAttribute('data-name'), appName, container).then(resolve, resolve);
      };

      // If loading a page, set status to loading
      (!isService && !isError) && (this.status = LOADING);

      // If Page Is Already Loaded Then The Route Does Not Exist. 404 and Exit.
      if (this.current && this.current.__pageId === (this.uid + '-' + appName)){ return throwError(); }

      // Fetch our css and js in paralell, install or throw when both complete
      Promise.all([this._fetchCSS(routeName, appName), this._fetchJavascript(routeName, appName)])
      .then(install, throwError);

    });
  }