Changeset 2308

Show
Ignore:
Timestamp:
11/03/08 17:25:33 (2 months ago)
Author:
aperez
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r2307 r2308  
     12008-11-03  Antonio Perez  <aperez@skarcha.com> 
     2 
     3        * admin/ModuleCgi.py, admin/static/js/common.js, admin/Entry.py: 
     4        Adds support for Custom Environment Variables. Bug #188: 
     5        http://code.google.com/p/cherokee/issues/detail?id=188 
     6 
    172008-11-03  Alvaro Lopez Ortega  <alvaro@octality.com> 
    28 
  • cherokee/trunk/admin/Entry.py

    r2067 r2308  
    1717            self._kwargs['class']='required' 
    1818            del kwargs['req'] 
     19 
     20        if 'noautosubmit' in kwargs and kwargs['noautosubmit'] == True: 
     21            self._kwargs['class']='noautosubmit' 
     22            del kwargs['noautosubmit'] 
    1923 
    2024    def _init_value (self, cfg): 
  • cherokee/trunk/admin/ModuleCgi.py

    r1987 r2308  
    2121        'check_file', 
    2222        'pass_req_headers', 
    23         'xsendfile' 
     23        'xsendfile', 
     24        'env' 
    2425    ] 
    2526 
     
    4950        txt += self.Indent(table) 
    5051 
     52        txt1 = '<h2>Custom environment variables</h2>' 
     53        envs = self._cfg.keys('%s!env'%(self._prefix)) 
     54        if envs: 
     55            table = Table(3, title_left=1, style='width="90%"') 
     56 
     57            for env in envs: 
     58                pre = '%s!env!%s'%(self._prefix,env) 
     59                val = self.InstanceEntry(pre, 'text', size=25) 
     60                js = "post_del_key('/ajax/update', '%s');"%(pre) 
     61                link_del = self.InstanceImage ("bin.png", "Delete", border="0", onClick=js) 
     62                table += (env, val, link_del) 
     63 
     64            txt1 += self.Indent(table) 
     65 
     66        txt1 += '<h3>Add new custom environment variable</h3>'; 
     67        name  = self.InstanceEntry('new_custom_env_name',  'text', size=25, noautosubmit=True) 
     68        value = self.InstanceEntry('new_custom_env_value', 'text', size=25, noautosubmit=True) 
     69 
     70        table = Table(3, 1, style='width="90%"') 
     71        table += ('Name', 'Value', '') 
     72        table += (name, value, SUBMIT_ADD) 
     73        txt1 += self.Indent(table) 
     74        txt += txt1 
     75 
    5176        return txt 
    5277 
    5378    def _op_apply_changes (self, uri, post): 
     79        new_name = post.pop('new_custom_env_name') 
     80        new_value = post.pop('new_custom_env_value') 
     81 
     82        if new_name and new_value: 
     83            self._cfg['%s!env!%s'%(self._prefix, new_name)] = new_value 
     84 
    5485        checkboxes = ['error_handler', 'pass_req_headers', 'xsendfile'] 
    5586 
  • cherokee/trunk/admin/PageInfoSource.py

    r2287 r2308  
    131131        value = self.InstanceEntry('new_env_value', 'text', size=25) 
    132132 
    133         table = Table(3, 1, style='width="90%%"') 
     133        table = Table(3, 1, style='width="90%"') 
    134134        table += ('Variable', 'Value', '') 
    135135        table += (name, value, SUBMIT_ADD) 
     
    194194 
    195195            txt += "<h2>Known sources</h2>" 
    196             table  = '<table width="90%%" id="sources" class="rulestable">' 
     196            table  = '<table width="90%" id="sources" class="rulestable">' 
    197197            table += '<tr><th>Nick</th><th>Type</th><th>Connection</th></tr>' 
    198198 
  • cherokee/trunk/admin/static/js/common.js

    r2250 r2308  
    159159/* Auto submission of some forms */ 
    160160function autosubmit(event) { 
    161   $(".auto input").change(function(event) { 
    162          if (check_all_or_none('required')) { 
    163                 setConfirmUnload(false); 
    164                 this.form.submit(); 
    165          } 
    166   }); 
     161        $(".auto input").change(function(event) { 
     162                if (this.className == 'noautosubmit') { 
     163                        return false; 
     164                } 
     165 
     166                if (check_all_or_none('required')) { 
     167                        setConfirmUnload(false); 
     168                        this.form.submit(); 
     169                } 
     170        }); 
    167171} 
    168172