Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Cherokee: commits

[3782] cherokee/trunk/admin: Adds a new main configuration file key: " config".

 

 

Cherokee commits RSS feed   Index | Next | Previous | View Threaded


cherokee at cherokee-project

Nov 5, 2009, 11:23 AM

Post #1 of 1 (28 views)
Permalink
[3782] cherokee/trunk/admin: Adds a new main configuration file key: " config".

Revision: 3782
http://svn.cherokee-project.com/changeset/3782
Author: alo
Date: 2009-11-05 20:23:50 +0100 (Thu, 05 Nov 2009)

Log Message:
-----------
Adds a new main configuration file key: "config". It holds information
about the configuration file itself. It will allow cherokee-admin to
migrate configuration automatically whenever the configuration file
format changes in a new server version. Target: the user should not
even know the configuration file format can evolve between versions.

Modified Paths:
--------------
cherokee/trunk/admin/Makefile.am
cherokee/trunk/admin/config.py
cherokee/trunk/admin/server.py

Added Paths:
-----------
cherokee/trunk/admin/config_version.py

Modified: cherokee/trunk/admin/Makefile.am
===================================================================
--- cherokee/trunk/admin/Makefile.am 2009-11-05 16:35:33 UTC (rev 3781)
+++ cherokee/trunk/admin/Makefile.am 2009-11-05 19:23:50 UTC (rev 3782)
@@ -104,6 +104,7 @@
ModuleEvhost.py \
ModuleRrd.py \
config.py \
+config_version.py \
pyscgi.py \
validations.py \
CherokeeManagement.py \

Modified: cherokee/trunk/admin/config.py
===================================================================
--- cherokee/trunk/admin/config.py 2009-11-05 16:35:33 UTC (rev 3781)
+++ cherokee/trunk/admin/config.py 2009-11-05 19:23:50 UTC (rev 3782)
@@ -260,7 +260,7 @@
# Serialization
def serialize (self):
def sorter(x,y):
- order = ['server', 'vserver', 'source', 'icons', 'mime']
+ order = ['config', 'server', 'vserver', 'source', 'icons', 'mime']
a = x.split('!')
b = y.split('!')
try:

Added: cherokee/trunk/admin/config_version.py
===================================================================
--- cherokee/trunk/admin/config_version.py (rev 0)
+++ cherokee/trunk/admin/config_version.py 2009-11-05 19:23:50 UTC (rev 3782)
@@ -0,0 +1,47 @@
+import configured
+
+def config_version_get_current():
+ ver = configured.VERSION.split ('b')[0]
+ v1,v2,v3 = ver.split (".")
+
+ major = int(v1)
+ minor = int(v2)
+ micro = int(v3)
+
+ return "%03d%03d%03d" %(major, minor, micro)
+
+
+def config_version_cfg_is_up_to_date (cfg):
+ # Cherokee's version
+ ver_cherokee = config_version_get_current()
+
+ # Configuration file version
+ ver_config = cfg.get_val("config!version")
+ if not ver_config:
+ cfg["config!version"] = ver_cherokee
+ return True
+
+ # Compare both of them
+ if int(ver_config) > int(ver_cherokee):
+ print "WARNING!! Running a new configuration file (version %s)" % (ver_config)
+ print "with anolder version of Cherokee (version %s)" % (ver_cherokee)
+ return True
+
+ elif int(ver_config) == int(ver_cherokee):
+ return True
+
+ else:
+ return False
+
+
+def config_version_update_cfg (cfg):
+ # Update only when it's outdated
+ if config_version_cfg_is_up_to_date (cfg):
+ return
+
+ # Update..
+ ver_config_s = cfg.get_val("config!version")
+ ver_config_i = int(ver_config_s)
+
+ print "Updating configuration.."
+ None

Modified: cherokee/trunk/admin/server.py
===================================================================
--- cherokee/trunk/admin/server.py 2009-11-05 16:35:33 UTC (rev 3781)
+++ cherokee/trunk/admin/server.py 2009-11-05 19:23:50 UTC (rev 3782)
@@ -30,6 +30,7 @@
from PageAjaxUpdate import *
from PageInfoSource import *
from CherokeeManagement import *
+from config_version import *

# Constants
#
@@ -234,6 +235,10 @@
global cfg
cfg = Config(cfg_file)

+ # Update the configuration file if needed
+ config_version_update_cfg (cfg)
+
+ # Let the user know what is going on
version = VERSION
pid = os.getpid()

Cherokee commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.