Changeset 1130

Show
Ignore:
Timestamp:
02/21/08 12:38:21 (7 months ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/admin/CherokeeManagement.py

    r1096 r1130  
    55import select 
    66 
     7from consts import * 
    78from configured import * 
    89 
     
    110111            pass 
    111112 
     113    def create_config (self, file): 
     114        if os.path.exists (file): 
     115            return 
     116 
     117        f = open(file, 'w+') 
     118        f.write (CHEROKEE_MIN_DEFAULT_CONFIG) 
     119        f.close() 
     120 
    112121    # Protected 
    113122    # 
  • cherokee/trunk/admin/ModuleFile.py

    r1116 r1130  
    1414    def _op_render (self): 
    1515        table = Table(2) 
    16         self.AddTableCheckbox (table, "I/O cache", "%s!io_cache" % (self._prefix), True) 
     16        self.AddTableCheckbox (table, "Use I/O cache", "%s!io_cache" % (self._prefix), True) 
    1717        return str(table) 
    1818 
  • cherokee/trunk/admin/config.py

    r1079 r1130  
    223223    # Checks 
    224224    def is_writable (self): 
    225         try: 
    226             open (self.file, "a") 
    227         except
     225        import os 
     226 
     227        if not os.path.exists (self.file)
    228228            return False 
    229         return True 
     229        return os.access (self.file, os.W_OK) 
    230230 
    231231    def has_tree (self): 
  • cherokee/trunk/admin/consts.py

    r1115 r1130  
    5858    ('gzip',     'GZip') 
    5959] 
     60 
     61 
     62 
     63CHEROKEE_MIN_DEFAULT_CONFIG = """# Default configuration 
     64vserver!default!document_root = /tmp 
     65vserver!default!directory!/!handler = common 
     66vserver!default!directory!/!priority = 1 
     67""" 
     68 
  • cherokee/trunk/admin/error_not_found.template.html

    r1045 r1130  
    11<h1>ERROR</h1> 
    22 
    3 <p>Could not find the configuration file <b>%(cherokee_conf)s</b>.</p> 
    4 <p>You may need to reinstall the web server.</p> 
     3<div class="dialog-error"> 
     4  <p>Could not find the configuration file <b>%(cherokee_conf)s</b>.</p> 
     5</div> 
     6 
     7<h2>Create a new configuration file</h2> 
     8 
     9<div class="indented"> 
     10  <p>You can create a new configuration file and proceed to configure 
     11  the web server from scratch:</p> 
     12 
     13   <p style="text-align: center;"> 
     14    <a class="button" href="/create_config"> 
     15      <span>Create new configuration file</span> 
     16    </a> 
     17   </p> 
     18</div> 
  • cherokee/trunk/admin/error_not_writable.template.html

    r1045 r1130  
    11<h1>ERROR</h1> 
    22 
    3 <p>The configuration file <b>%(cherokee_conf)s</b> cannot be modified.</p> 
     3<div class="dialog-error"> 
     4 <p>The configuration file <b>%(cherokee_conf)s</b> cannot be modified.</p> 
     5</div> 
     6 
    47<p>You have to change its permissions in order to allow cherokee-admin to work with it.</p> 
    58 
  • cherokee/trunk/admin/server.py

    r1122 r1130  
    5353        # Ensure that the configuration file is writable 
    5454        if not cfg.has_tree(): 
    55             page = PageError (cfg, PageError.CONFIG_NOT_FOUND) 
     55            if not uri.startswith('/create_config'): 
     56                page = PageError (cfg, PageError.CONFIG_NOT_FOUND) 
    5657        elif not cfg.is_writable(): 
    5758            page = PageError (cfg, PageError.CONFIG_NOT_WRITABLE) 
     
    102103            cherokee_management_reset() 
    103104            body = "/" 
     105        elif uri.startswith('/create_config'): 
     106            manager = cherokee_management_get (cfg) 
     107            manager.create_config (cfg.file) 
     108            cherokee_management_reset() 
     109            cfg = Config (cfg.file) 
     110            body = "/" 
    104111        elif uri.startswith('/ajax/update'): 
    105112            page = PageAjaxUpdate (cfg) 
     
    112119        self.handle_post() 
    113120        post = Post (self.post) 
    114          
     121 
    115122        # Execute page 
    116123        if page: 
     
    125132        self.wfile.write('Status: %s\r\n' % (status) + 
    126133                         headers + '\r\n' + body) 
    127  
    128134 
    129135