How to use the wilson/conf.settings function in wilson

To help you get started, we’ve selected a few wilson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisdickinson / wilson / lib / commands.js View on Github external
exports.runcommand = function() {
    var sys = require('sys'),
        conf = require('wilson/conf'),
        core = require('wilson/core/app'),
        application = require('wilson/application'),
        app_and_command = process.argv[2].split(':'),
        app = app_and_command[0],
        command = app_and_command[1],
        appInstance;

    try {
        application.loadApps(conf.settings.APP_OVERRIDES);
        appInstance = application.getApplicationInstance(app);
    } catch(err) {
        conf.setSettings({
            INSTALLED_APPS:{
                core:application.use('wilson/core')
            },
            TEMPLATE_LOADERS:[
                'wilson/template/loaders.application',
                'wilson/template/loaders.filesystem',
            ],
        });
        application.loadApps(conf.settings.APP_OVERRIDES);
        appInstance = application.getApplicationInstance('core');
    }

    if(appInstance) {
github chrisdickinson / wilson / lib / contrib / sessions / backends / base.js View on Github external
var settings = require('wilson/conf').settings,
    Buffer = require('buffer').Buffer,
    crypto = require('crypto');

var MAX_SESSION_KEY = 18446744073709551616;

var SessionStore = function(key, appInstance) {
    this._session_key = key;
    this.appInstance = appInstance;
    this.accessed = false;
    this.modified = false;
};

SessionStore.prototype.encode = function(data) {
    var pickled = JSON.stringify(data),
        md5 = crypto.createHash('md5').update(pickled + settings.SECRET_KEY).digest('hex'),
        result = new Buffer(pickled + md5, 'utf8').toString('base64');
github chrisdickinson / wilson / lib / servers.js View on Github external
exports.getServerFunction = function() {
    var http = require('wilson/http'),
        conf = require('wilson/conf'),
        application = require('wilson/application'),
        settings = conf.settings,
        middleware_strings = settings.MIDDLEWARE,
        middleware = [];

    var createWrappedMethod = function(instance, method) {
            return function() {
                method.apply(instance, Array.prototype.slice.call(arguments));
            };
    };

    var createWrappedMiddleware = function(instance, middleware, mw_name) {
        output_middleware = {};

        Object.keys(middleware).forEach(function(name) {
            output_middleware[name] = createWrappedMethod(instance, middleware[name]); 
        });
github chrisdickinson / wilson / lib / application.js View on Github external
exports.loadApps = function(app_options) {
    app_options = app_options || {};

    var settings = require('wilson/conf').settings,
        apps = settings.INSTALLED_APPS;

    Object.keys(apps).forEach(function(app_name) {
        appInstances[app_name] = apps[app_name].load(app_name, app_options[app_name]);
    });

    Object.keys(appInstances).forEach(function(app_name) {
        appInstances[app_name].setupForwardDependencies();
    });

    Object.keys(appInstances).forEach(function(app_name) {
        appInstances[app_name].resolveModels();
    });
};
github chrisdickinson / wilson / lib / contrib / sessions / models.js View on Github external
var models = require('wilson/models'),
    settings = require('wilson/conf').settings,
    Buffer = require('buffer').Buffer,
    crypto = require('crypto');

exports.Session = models.model({
    'session_key':models.CharField({'max_length':40, primary_key:true}),
    'session_data':models.TextField(),
    'expire_date':models.DateTimeField(),
    'get_encoded':function(data) {
        var pickled = JSON.stringify(data),
            md5 = crypto.createHash('md5').update(pickled + settings.SECRET_KEY).digest('hex'),
            result = new Buffer(pickled + md5, 'utf8').toString('base64');
        return result;
    },
    'get_decoded':function() {
        var encodedData = (new Buffer(this.session_data, 'base64')).toString('utf8'),
            pickled = encodedData.slice(0, -32),
github chrisdickinson / wilson / lib / commands.js View on Github external
appInstance;

    try {
        application.loadApps(conf.settings.APP_OVERRIDES);
        appInstance = application.getApplicationInstance(app);
    } catch(err) {
        conf.setSettings({
            INSTALLED_APPS:{
                core:application.use('wilson/core')
            },
            TEMPLATE_LOADERS:[
                'wilson/template/loaders.application',
                'wilson/template/loaders.filesystem',
            ],
        });
        application.loadApps(conf.settings.APP_OVERRIDES);
        appInstance = application.getApplicationInstance('core');
    }

    if(appInstance) {
        var appCommand = appInstance.app.commands[command];
        if(appCommand) {
            appCommand.apply(appInstance, process.argv.slice(3));
        } else {
            sys.puts('Could not find the command '+app_and_command);
            if(app === appInstance.name) {
                sys.puts('Available commands within '+app);
                for(var command_name in appInstance.app.commands) {
                    sys.puts('\t'+[app, command_name].join(':'));
                }
            } else {
                sys.puts('All apps and commands:');