<commit_before>openerp.base = function(instance) {

    instance.base = {};
    instance.base.Apps = instance.web.Widget.extend({
        template: 'EmptyComponent',
        init: function(parent, options) {
            this._super(parent);
            // create a new instance
            this.remote_instance = new openerp.init();

        },

        destroy: function() {
            if (this.client) {
                this.client.destroy();
            }
            delete this.remote_instance;
        },
        
        _get_options: function() {
            //var DEFAULT_SERVER = 'http://apps.openerp.com/loempia';           // PROD
            var DEFAULT_SERVER = 'http://apps.openerp.com:9069/loempia7';     // TEST
            //var DEFAULT_SERVER = 'http://localhost:8080/trunk_loempia7';        // DEV
            var ICP = new instance.web.Model('ir.config_parameter');
            return ICP.call('get_param', ['loempia.server', DEFAULT_SERVER]).pipe(function(u) {
                var link = $(_.str.sprintf('<a href="%s"></a>', u))[0];
                var host = _.str.sprintf('%s//%s', link.protocol, link.host);
                var dbname = link.pathname.substr(1);

                var login = (sessionStorage ? sessionStorage.getItem('loempia.login') : null) || 'anonymous';
                var passwd = (sessionStorage ? sessionStorage.getItem('loempia.passwd') : null) || 'anonymous';

                return {
                   url: host,
                   dbname: dbname,
                   login: login,
                   password: <PASSWORD>,
                   action_id: 'loempia.action_embed'
                };
            });
        },

        start: function() {
            return this._get_options().then(this.proxy('_connect'));
        },
        _connect: function(options) {
            this.options = options;

            var client = this.client = new this.remote_instance.web.EmbeddedClient(null, this.options.url,
                                                                     this.options.dbname, this.options.login, this.options.password, 
                                                                     this.options.action_id, this.action_flags);
            client.on('connection_failed', this, this.action_fallback);
            this.client = client;
            
            client.replace(this.$el).
                done(function() {
                    client.$el.removeClass('openerp');
                }).
                fail(function() {
                    console.log('fail', this);
                    alert('fail');
                });
        },
        
        action_fallback: function() {
            // TODO show flash message
            this.do_warn(this.options.url + ' unreachable');
            this.do_action('base.action_modules');                <commit_msg>[FIX] apps: store params<commit_after>openerp.base = function(instance) {

    instance.base = {};
    instance.base.Apps = instance.web.Widget.extend({
        template: 'EmptyComponent',
        init: function(parent, options) {
            this._super(parent);
            this.params = options;
            this.clean();
            // create a new instance
            this.remote_instance = new openerp.init();
        },

        clean: function() {
            if (this.client) {
                this.client.destroy();
            }
        },

        destroy: function() {
            this.clean();
            //delete this.remote_instance;
            this._super();
        },

        _get_options: function() {
            var self = this;
            //var DEFAULT_SERVER = 'http://apps.openerp.com/loempia';           // PROD
            var DEFAULT_SERVER = 'http://apps.openerp.com:9069/loempia7';     // TEST
            //var DEFAULT_SERVER = 'http://localhost:8080/trunk_loempia7';        // DEV
            var ICP = new instance.web.Model('ir.config_parameter');
            return ICP.call('get_param', ['loempia.server', DEFAULT_SERVER]).pipe(function(u) {
                var link = $(_.str.sprintf('<a href="%s"></a>', u))[0];
                var host = _.str.sprintf('%s//%s', link.protocol, link.host);
                var dbname = link.pathname.substr(1);

                var login = (sessionStorage ? sessionStorage.getItem('loempia.login') : null) || 'anonymous';
                var passwd = (sessionStorage ? sessionStorage.getItem('loempia.passwd') : null) || 'anonymous';

                return {
                   url: host,
                   dbname: dbname,
                   login: login,
                   password: <PASSWORD>,
                   action_id: 'loempia.action_embed'
                };
            });
        },

        start: function() {
            return this._get_options().then(this.proxy('_connect'));
        },
        _connect: function(options) {
            this.options = options;

            var client = this.client = new this.remote_instance.web.EmbeddedClient(null, this.options.url,
                                                                     this.options.dbname, this.options.login, this.options.password,
                                                                     this.options.action_id);
            client.on('connection_failed', this, this.action_fallback);
            //this.client = client;

            client.replace(this.$el).
                done(function() {
                    client.$el.removeClass('openerp');
                }).
                fail(function() {
                    console.log('fail', this);
                    alert('fail');
                });
        },

        action_fallback: function() {
            // TODO show flash message
            this.do_warn(this.options.url + ' unreachable');
            this.do_action('base.action_modules');
{'fraction_non_alphanumeric': 0.1275064267352185, 'fraction_numerical': 0.004113110539845758, 'mean_word_length': 1.3986847513357994, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7379420', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1459, 'n_words': 258}