Instantiates each app from it's appConfig and stores that in a local private collection
@method _createAppInstance
@private
@param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}} objects
554294
function(appConfig, appContent) {
		// instantiate F2.UI
		appConfig.ui = new F2.UI(appConfig);

		// instantiate F2.App
		if (F2.Apps[appConfig.appId] !== undefined) {
			if (typeof F2.Apps[appConfig.appId] === 'function') {

				// IE
				setTimeout(function() {
					_apps[appConfig.instanceId].app = new F2.Apps[appConfig.appId](appConfig, appContent, appConfig.root);
					if (_apps[appConfig.instanceId].app['init'] !== undefined) {
						_apps[appConfig.instanceId].app.init();
					}
				}, 0);

			}
			else {
				F2.log('app initialization class is defined but not a function. (' + appConfig.appId + ')');
			}
		}
	}
37853
def _build_app_models(request, admin_apps, models_tuples, ensure_all_models=False):
    

    app_models = []
    for app_and_model, config in models_tuples:
        if app_and_model:
            app_label, model_name = app_and_model.split('.')

            for app in admin_apps:
                if app['app_label'] == app_label:
                    for model in app['models']:
                        if model['object_name'] == model_name:
                            try:
                                model['name'] = \
                                    config['name']
                            except KeyError:
                                pass

                            # Get each of the polymorphic types to allow addition.
                            model_class = apps.get_model(app_and_model)
                            model_admin = admin.site._registry[model_class]

                            if hasattr(model_admin, 'get_child_type_choices'):
                                model['polymorphic_classes'] = \
                                    model_admin.get_child_type_choices(
                                        request, 'add'
                                    )

                            # TODO: Fluent/polymorphic has a way of sorting child order which should be used instead
                            if 'default_poly_child' in config.keys():
                                ct = ContentType.objects.get_by_natural_key(
                                    *config['default_poly_child'].lower().split('.')
                                )
                                model.default_poly_child = ct.id

                            app_models.append(model)

                    break

    return app_models
761623
function(appConfig, message, origin) {

		var obj, func;

		function parseFunction(parent, functionName) {
			var path = String(functionName).split('.');
			for (var i = 0; i < path.length; i++) {
				if (parent[path[i]] === undefined) {
					parent = undefined;
					break;
				}
				parent = parent[path[i]];
			}
			return parent;
		}

		function parseMessage(regEx, message, instanceId) {
			var o = F2.parse(message.replace(regEx, ''));

			// if obj.callbacks
			//   for each callback
			//     for each params
			//       if callback matches param
			//        replace param with _createRpcCallback(app.instanceId, callback)
			if (o.params && o.params.length && o.callbacks && o.callbacks.length) {
				jQuery.each(o.callbacks, function(i, c) {
					jQuery.each(o.params, function(i, p) {
						if (c == p) {
							o.params[i] = _createRpcCallback(instanceId, c);
						}
					});
				});
			}

			return o;
		}

		// handle UI Call
		if (_rUiCall.test(message)) {
			obj = parseMessage(_rUiCall, message, appConfig.instanceId);
			func = parseFunction(appConfig.ui, obj.functionName);
			// if we found the function, call it
			if (func !== undefined) {
				func.apply(appConfig.ui, obj.params);
			} else {
				F2.log('Unable to locate UI RPC function: ' + obj.functionName);
			}

		// handle RPC
		} else if (_rRpc.test(message)) {
			obj = parseMessage(_rRpc, message, appConfig.instanceId);
			func = parseFunction(window, obj.functionName);
			if (func !== undefined) {
				func.apply(func, obj.params);
			} else {
				F2.log('Unable to locate RPC function: ' + obj.functionName);
			}

		// handle RPC Callback
		} else if (_rRpcCallback.test(message)) {
			obj = parseMessage(_rRpcCallback, message, appConfig.instanceId);
			if (_callbacks[obj.functionName] !== undefined) {
				_callbacks[obj.functionName].apply(_callbacks[obj.functionName], obj.params);
				delete _callbacks[obj.functionName];
			}

		// handle Events
		} else if (_rEvents.test(message)) {
			obj = parseMessage(_rEvents, message, appConfig.instanceId);
			F2.Events._socketEmit.apply(F2.Events, obj);
		}
	}
536374
protected void addAppConfigToCategory(I_CmsWorkplaceAppConfiguration appConfig) {

        CmsAppCategoryNode node = m_nodes.get(appConfig.getAppCategory());
        if (node == null) {
            LOG.info(
                "Missing parent ["
                    + appConfig.getAppCategory()
                    + "] for "
                    + appConfig.getId()
                    + " / "
                    + appConfig.getClass().getName());
        } else {
            node.addAppConfiguration(appConfig);
        }
    }
1044404
function appRequest(params, cb) {
  params = params || {};
  var mbaasConf = params[constants.MBAAS_CONF_KEY];
  params[constants.MBAAS_CONF_KEY] = undefined;
  //Adding Mbaas Config Params
  var fullParams = _.extend(_.clone(params), mbaasConf);

  var invalidParamError = validateAppParams(fullParams);

  if (invalidParamError) {
    return cb(invalidParamError);
  }

  fullParams = _buildAppRequestParams(fullParams);

  return doFHMbaaSRequest(fullParams, cb);
}
392643
function create(appName, callback) {
    commons.post(format('/%s/apps/', deis.version), {
      id: appName
    }, callback);
  }
526172
function ConfigUtil() {

    var self = this; //, mainConfig

    /**
     * Init
     * @contructor
     * */
    var init = function() {

        if ( !ConfigUtil.instance ) {
            try {
                self.paths = getContext('paths')
            } catch (err) {
                self.paths = {}
            }

            var path = new _(__dirname).toUnixStyle();
            self.__dirname =  _( path.substring(0, (path.length - 4)) );

            ConfigUtil.instance = self;
            return self
        } else {
            self = ConfigUtil.instance;
            return ConfigUtil.instance
        }
    }


    /**
     * Set config file if !exists
     *
     * @param {string} app - App name
     * @param {string} file - File to save
     * @param {object} content - JSON content to save
     * */
    this.set = function(app, file, content, callback){
        switch (app) {
            case 'gina':
            case 'gina.utils':
                setFile(app, file, content, function(err){
                    callback(err);
                });
                break;
        }
    }

    /**
     * Get config file if exists
     *
     * @param {string} project - Project name
     * @param {strins} key - File name to save + .ext
     *
     * @callback callback
     * @param {string|boolean} err
     * @param {object} config - Bundle Configuration
     * */
    this.get = function(project, file, callback){

        var config = null, err = false;

        switch (project) {
            case 'gina':
            case 'gina.utils':
                try {
                    //You are under gina.utils/lib/...
                    if ( typeof(self.value) != "undefined" ) {

                        try {
                            config = self.value;//????
                        } catch (err) {
                            err = 'Utils.Config.get(...) : self.value['+file+'] : key not found.\n' + err;
                        }

                    } else {
                        //Getting paths.
                        if ( typeof(self.paths.root) != 'undefined' ) {
                            //console.error("requiring :=> ",  self.paths.root + '/.gna/locals.json');
                            try {
                                config = require(self.paths.root  + '/.gna/' + file);
                                self.value = config;
                                self.paths = config['paths'];

                            } catch (err) {
                                //Means that the file was not found..
                                console.error(err.stack || err.message);
                                err = new Error(self.__dirname  + '/.gna/locals.json: project configuration file not found.');
                                process.exit(1)
                            }
                        }
                    }
                    callback(err, config)

                } catch (err) {
                    var err = new Error('.gna/locals.json: project configuration file not found. \n' + (err.stack||err.message));
                    //logger.error('gina', 'UTILS:CONFIG:ERR:3', err, __stack);
                    callback(err);
                }
                break;

            default :
                callback('Config.get('+project+'): case not found');
        }
    }

    /**
     * Get sync config file if exists
     *
     * @param {string} app - App name
     * @return {object} config - App Configuration
     *
     * @private
     * */
    this.getSync = function(project, file, i){
        var maxRetry    = 7
            , delay     = 300
            , i         = i || 0;

        if (typeof(file) == 'undefined') {
            var file = 'locals.json'
        }

        if ( typeof(self.value) != "undefined" ) {
            return self.value;
        } else {
            var filename = self.paths.root +'/.gna/'+ file;
            if (i > 0) {
                console.debug('retrying [ '+i+' ] to load: ' + filename)
            }

            try {
                if ( fs.existsSync(filename) ) {
                    return require(filename)
                } else {
                    // you might just be experimenting some latencies
                    if (i < maxRetry) {
                        console.debug('retrying to load config after timeout');
                        setTimeout(function(){
                            console.debug('It is time re reload config');
                            self.getSync(project, file, i+1)
                        }, delay);
                        //return
                    } else {
                        var err = new Error(filename+ ' not found');
                        console.emerg(err.stack||err.message);
                        process.exit(1);
                    }
                }
            } catch (err) {
                if (i < maxRetry) {
                    console.debug('(catched) retrying to load config after timeout');
                    setTimeout(function(){
                        console.debug('It is time re reload config');
                        self.getSync(project, file, i+1)
                    }, delay);
                } else {
                    console.error(err.stack);
                    throw new Error(err.message);
                }
            }
        }
    }

    /**
     * Create a config file
     *
     * @param {string} app - Targeted application
     * @param {string} file - File save
     * @param {string} content - Content fo the file to save
     *
     *
     * TOTO - Avoid systematics file override.
     * @private
     * */

    var setFile = function(app, file, content, callback) {

        var paths = {
            root : content.paths.root,
            utils : content.paths.utils
        };
        var gnaFolder = content.paths.root + '/.gna';

        self.project = content.project;

        self.paths = paths;

        //Create path.
        var createFolder = function(){
            if ( fs.existsSync(gnaFolder) ) {
                if ( !fs.existsSync(gnaFolder +'/'+ file) ) {
                    createContent(gnaFolder +'/'+ file, gnaFolder, content, function(err){
                        setTimeout(function(){
                            callback(err)
                        }, 500)
                    })
                } else { // already existing ... won't overwrite
                    callback(false)
                }

            } else {
                fs.mkdir(gnaFolder, 0777, function(err){
                    if (err) {
                        console.error(err.stack);
                        callback(err)
                    } else {
                        //Creating content.
                        createContent(gnaFolder+ '/' +file, gnaFolder, content, function(err){
                            setTimeout(function(){
                                callback(err)
                            }, 500)
                        })
                    }
                })
            }

        };

        fs.exists(gnaFolder, function(exists){
            if (!exists) {
                createFolder()
            } else {
                // test if decalred path matches real path and overwrite if not the same
                // in case you move your project
                var filename        = _(gnaFolder +'/'+ file, true);
                var checksumFileOld = _(gnaFolder +'/'+ math.checkSumSync( JSON.stringify( require(filename) ), 'sha1'), true) + '.txt';
                var checksumFile    = _(gnaFolder +'/'+ math.checkSumSync( JSON.stringify(content), 'sha1'), true) + '.txt';

                var verified        = (checksumFileOld == checksumFile) ? true : false;


                if ( !fs.existsSync(checksumFile) && fs.existsSync(filename) || !fs.existsSync(filename) || !verified) {
                    if ( fs.existsSync(filename) ) fs.unlinkSync(filename);
                    if ( fs.existsSync(checksumFile) ) fs.unlinkSync(checksumFile);

                    createContent(filename, gnaFolder, content, function(err){
                        fs.openSync(checksumFile, 'w');
                        setTimeout(function(){
                            callback(err)
                        }, 500)
                    })
                } else if ( fs.existsSync(filename) ) {

                    var locals = require(gnaFolder +'/'+ file);

                    if (paths.utils != locals.paths.utils) {

                        new _(gnaFolder).rm( function(err){
                            if (err) {
                                console.warn('found error while trying to remove `.gna`\n' + err.stack)
                            }

                            //setTimeout(function(){
                                //console.debug('Done removing `gnaFolder` : '+ gnaFolder);
                            createFolder();
                            //}, 200);
                        })
                    } else {
                        callback(false)// nothing to do
                    }
                } else {
                    callback(false)// nothing to do
                }
            }
        })
    }


    /**
     * Remove symbolic link
     *
     * @param {string} path
     * @callback callback
     *
     * @private
     * */
    var removeSymlink = function(path, callback){

        fs.exists(path, function(exists){
            if (exists) {
                fs.lstat(path, function(err, stats){
                    if (err) console.error(err.stack);

                    if ( stats.isSymbolicLink() ) fs.unlink(path, function(err){
                        if (err) {
                            console.error(err.stack);
                            callback(err)
                        } else {
                            //Trigger.
                            onSymlinkRemoved(self.paths, function(err){
                                if (err) console.error(err.stack);

                                callback(false)
                            })
                        }
                    })
                })
            } else {
                //log & ignore. This is not a real issue.
                //logger.warn('gina', 'UTILS:CONFIG:WARN:1', 'Path not found: ' + path, __stack);
                console.warn( 'Path not found: ' + path, __stack);
                onSymlinkRemoved(self.paths, function(err){
                    //if (err) logger.error('gina', 'UTILS:CONFIG:ERR:9', err, __stack);
                    if (err) console.error(err.stack||err.message);

                    callback(false)
                })
            }
        })
    }

    /**
     * Symbolic link remove event
     *
     * @param {string} [err]
     * @callback callback
     *
     * @private
     * */
    var onSymlinkRemoved = function(paths, callback){
        //Remove original.
        var p = new _(paths.root + '/.gna');
        var path = p.toString();

        //Remove folers.
        fs.exists(path, function(exists){
            //delete when exists.
            if (exists) {
                //console.log("yeah about to delete main folder: ", p.toString());
                //Delete ans die here..
                p.rm(function(err, path){
                    //console.log("receives ", err, path);
                    if (err) {
                        //logger.error('gina', 'UTILS:CONFIG:ERR:8', err, __stack);
                        console.error(err.stack||err.message);
                        callback(err)
                    } else {
                        //logger.info('gina', 'UTILS:CONFIG:INFO:1', path +': deleted with success !');
                        console.info( path +': deleted with success !');
                        callback(false)
                    }
                })
            }
        })
    }

    /**
     * Create content
     *
     * @param {string} filename - Fullpath
     * @content {string} content
     *
     * @private
     * */
    var createContent = function(filename, gnaFolder, content, callback){
        if ( fs.existsSync(filename) ) {
            fs.unlinkSync(filename)
        }
        fs.appendFile(
            filename,
            JSON.stringify(content, null, '\t'),
            null,
            function(err){
                if (err) {
                    //logger.error('gina', 'UTILS:CONFIG:ERR:2', err, __stack);
                    console.error('`Error on while calling createContent()`: ' + err.stack||err.message);
                    callback(err)
                } else {
                    setTimeout(function(){
                        callback(err)
                    }, 1000)
                }
            }//EO function
        )//EO fs.appendFile
    }

    /**
     * Get var value by namespace
     *
     * @param {string} namespace
     * @param {object} [config ] - Config object
     * @return {*} value - Can be String or Array
     *
     * @private
     * */
    var getVar = function(namespace, config) {
        if ( typeof(config) == "undefined" )
            var config = self.getSync(app);

        if (config != null) {
            var split = namespace.split('.'), k=0;
            while (k<split.length) {
                config = config[split[k++]]
            }
            return config
        } else {
            return null
        }
    }

    /**
     * Get path by app & namespance
     *
     * @param {string} app
     * @param {string} namespace
     *
     * @callback callback
     * @param {string} err
     * @param {string} path
     *
     * @private
     * */
    var getPath = function(app, namespace, callback){

        self.get(app, function(err, config){
            if (err) {
                //logger.error('gina', 'UTILS:CONFIG:ERR:4', err, __stack);
                console.error(err.stack||err.message);
                callback(err + 'Utils.Config.get(...)');
            }

            try {
                callback( false, getVar('paths.' + namespace, config) );

            } catch (err) {
                var err = new Error('Config.getPath(app, cat, callback): cat not found');
                callback(err)
            }
        })
    }


    /**
     * Get project name
     *
     * @return {string} projectName
     *
     * */
    this.getProjectName = function(){
        if ( this.paths != undefined && this.paths.root != undefined ) {
            var arr = this.paths.root.split("/");
            return arr[arr.length-1]
        } else {
            return null
        }
    }

    return init()
}
279146
def create(appname, **kwargs):
        """"""

        if appname in LinkFactory._class_dict:
            return LinkFactory._class_dict[appname].create(**kwargs)
        else:
            raise KeyError(
                "Could not create object associated to app %s" % appname)
926748
function(node) {
		var appConfig;

		if (node) {
			var appId = node.getAttribute('data-f2-appid');
			var manifestUrl = node.getAttribute('data-f2-manifesturl');

			if (appId && manifestUrl) {
				appConfig = {
					appId: appId,
					enableBatchRequests: node.hasAttribute('data-f2-enablebatchrequests'),
					isSecure: node.hasAttribute('data-f2-issecure'),
					manifestUrl: manifestUrl,
					root: node
				};

				// See if the user passed in a block of serialized json
				var contextJson = node.getAttribute('data-f2-context');

				if (contextJson) {
					try {
						appConfig.context = F2.parse(contextJson);
					}
					catch (e) {
						console.warn('F2: "data-f2-context" of node is not valid JSON', '"' + e + '"');
					}
				}
			}
		}

		return appConfig;
	}
179953
def app_factory(global_conf, **local_conf):
    
    configuration_file = global_conf.get("__file__", None)
    webapp = init_webapp(ini_path=configuration_file, local_conf=local_conf)
    return webapp
118234
function collections(config) {
  config = config || {};

  return function plugin(app, base) {
    if (!utils.isValid(app, 'generate-collections')) return;
    app.define('home', path.resolve.bind(path, os.homedir()));

    /**
     * Options
     */

    app.option(config);

    // add default view collections
    if (!app.files) app.create('files', { viewType: 'renderable'});
    if (!app.includes) app.create('includes', { viewType: 'partial' });
    if (!app.layouts) app.create('layouts', { viewType: 'layout' });
    if (!app.templates) app.create('templates', { viewType: 'renderable' });

    /**
     * Middleware for collections created by this generator
     */

    app.preLayout(/./, function(view, next) {
      if (utils.falsey(view.layout) && !view.isType('partial')) {
        // use the empty layout created above, to ensure that all
        // pre-and post-layout middleware are still triggered
        view.layout = app.resolveLayout(view);
        if (utils.falsey(view.layout)) {
          view.layout = 'empty';
        }
        next();
        return;
      }

      if (view.isType('partial')) {
        view.options.layout = null;
        view.data.layout = null;
        view.layout = null;
        if (typeof view.partialLayout === 'string') {
          view.layout = view.partialLayout;
        }
      }
      next();
    });

    // remove or rename template prefixes before writing files to the file system
    var regex = app.options.templatePathRegex || /./;
    app.templates.preWrite(regex, utils.renameFile(app));
    app.templates.onLoad(regex, function(view, next) {
      var userDefined = app.home('templates', view.basename);
      if (fs.existsSync(userDefined)) {
        view.contents = fs.readFileSync(userDefined);
      }
      utils.stripPrefixes(view);
      utils.parser.parse(view, next);
    });

    // "noop" layout
    app.layout('empty', {content: '{% body %}'});

    // create collections defined on the options
    if (utils.isObject(app.options.create)) {
      for (var key in app.options.create) {
        if (!app[key]) {
          app.create(key, app.options.create[key]);
        } else {
          app[key].option(app.options.create[key]);
        }
      }
    }

    // pass the plugin to sub-generators
    return plugin;
  };
}
215459
function (name) {
    // initialize module instance with default module configuration
    _.merge(this, defaultModuleConfig)
    // set app name
    this.name = name
    // set absolute path of base directory for module
    this.base = getBase()
    // store reference to global app
    this.immutableApp = immutableApp
}
106739
function create(options) {
  console.log('Creating app: ', options.name);

  if (!options.status)
    options.status = (code, msg) => {
      console.log(msg);
    };
  if (!options.type) options.type = 'rekit-react';

  const prjDir = path.join(options.location || process.cwd(), options.name);
  return new Promise(async (resolve, reject) => {
    try {
      if (fs.existsSync(prjDir)) {
        reject('FOLDER_EXISTS');
        return;
      }
      fs.mkdirSync(prjDir);
      let gitRepo;
      if (options.source) {
        if (/^https?:/.test(options.source)) {
          // It's a git repo
          gitRepo = options.source;
        } else {
          // It's a local folder
          const srcDir = path.isAbsolute(options.source)
            ? options.source
            : path.join(process.cwd(), options.source);
          options.status('CREATE_APP_COPY_FILES', `Copy files from ${srcDir}...`);
          await fs.copy(srcDir, prjDir, {
            filter: src => !/\/(\.git|node_modules\/|node_modules$)/.test(src) || path.basename(src) === '.gitignore',
          });
        }
      } else if (options.type) {
        // Get gitRepo
        options.status(
          'QUERY_APP_TYPES_GIT_REPO',
          `Looking for the git repo for app type ${options.type}...`,
        );
        const appTypes = await getAppTypes();
        const appType = _.find(appTypes, { id: options.type });
        if (!appType) reject('APP_TYPE_NOT_SUPPORTED');
        gitRepo = appType.repo;
      } else {
        await fs.remove(prjDir);
        reject('NO_SOURCE_OR_APP_TYPE');
      }

      if (gitRepo) {
        options.status('CLONE_PROJECT', `Downloading project from ${gitRepo}...`);
        await cloneRepo(gitRepo, prjDir);
      }

      postCreate(prjDir, options);
      options.status('CREATION_SUCCESS', '😃App creation success.');
      resolve();
    } catch (err) {
      console.log('Failed to create project.');
      fs.removeSync(prjDir);
      reject(err);
    }
  });
}
763122
def create_app(config=None, config_obj=None):
    
    app = Flask(__name__)
    # configure application from external configs
    configure_app(app, config=config, config_obj=config_obj)
    # register different parts of the application
    register_blueprints(app)
    # setup extensions
    bind_extensions(app)
    return app
1097440
function Application(ctx, config) {
	// validate params
	if (!ctx && !config) {
		// both empty
		ctx = document;
		config = {};
	}
	else if (Utils.isNode(config)) {
		// reverse order of arguments
		var tmpConfig = config;
		config = ctx;
		ctx = tmpConfig;
	}
	else if (!Utils.isNode(ctx) && !config) {
		// only config is given
		config = ctx;
		ctx = document;
	}
	else if (Utils.isNode(ctx) && !config) {
		// only ctx is given
		config = {};
	}

	var defaults = {
		namespace: Module
	};

	config = Utils.extend(defaults, config);

	/**
	 * The context node.
	 *
	 * @property _ctx
	 * @type Node
	 */
	this._ctx = Utils.getElement(ctx);

	/**
	 * The configuration.
	 *
	 * @property config
	 * @type Object
	 */
	this._config = config;

	/**
	 * The sandbox to get the resources from.
	 * The singleton is shared between all modules.
	 *
	 * @property _sandbox
	 * @type Sandbox
	 */
	this._sandbox = new Sandbox(this);

	/**
	 * Contains references to all modules on the page.
	 *
	 * @property _modules
	 * @type Object
	 */
	this._modules = {};

	/**
	 * The next unique module id to use.
	 *
	 * @property id
	 * @type Number
	 */
	this._id = 1;
}
764298
function createApplication() {
  var app = connect();
  utils.merge(app, proto);
  app.request = { __proto__: req };
  app.response = { __proto__: res };
  app.init();
  return app;
}
348818
public static void saveApplicationBindings( Application app ) {

		File descDir = new File( app.getDirectory(), Constants.PROJECT_DIR_DESC );
		File appBindingsFile = new File( descDir, APP_BINDINGS_FILE );

		// Convert the bindings map
		Map<String,String> format = new HashMap<> ();
		for( Map.Entry<String,Set<String>> entry : app.getApplicationBindings().entrySet()) {
			String s = Utils.format( entry.getValue(), ", " );
			format.put( entry.getKey(), s );
		}

		// Save it
		Properties props = new Properties();
		props.putAll( format );

		try {
			Utils.createDirectory( descDir );
			Utils.writePropertiesFile( props, appBindingsFile );

		} catch( IOException e ) {
			Logger logger = Logger.getLogger( ConfigurationUtils.class.getName());
			logger.severe( "Failed to save application bindings for " + app + ". " + e.getMessage());
			Utils.logException( logger, e );
		}
	}