Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. git-svn-id: svn://cherokee-project.com/cherokee/trunk@3782 5dc97367-97f1-0310-9951-d761b3857238
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters