Starting here, trunk is broken pending re-organizations. Check out the previous revision if you'd like to tinker.
This commit is contained in:
parent
4b25a08597
commit
837f1152c6
28 changed files with 0 additions and 0 deletions
32
src/config/managers/configvalue.py
Normal file
32
src/config/managers/configvalue.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"""
|
||||
Custom manager for ConfigValue objects.
|
||||
"""
|
||||
from traceback import format_exc
|
||||
from django.db import models
|
||||
from src import logger
|
||||
|
||||
class ConfigValueManager(models.Manager):
|
||||
def get_configvalue(self, configname):
|
||||
"""
|
||||
Retrieve a configuration value.
|
||||
"""
|
||||
try:
|
||||
return self.get(conf_key__iexact=configname).conf_value
|
||||
except self.model.DoesNotExist:
|
||||
logger.log_errmsg("Unable to get config value for %s (does not exist):\n%s" % (
|
||||
configname, (format_exc())))
|
||||
|
||||
def set_configvalue(self, configname, newvalue):
|
||||
"""
|
||||
Sets a configuration value with the specified name.
|
||||
Returns the new value for the directive.
|
||||
"""
|
||||
try:
|
||||
conf = self.get(conf_key=configname)
|
||||
conf.conf_value = newvalue
|
||||
conf.save()
|
||||
# We'll do this instead of conf.conf_value, might save a DB query.
|
||||
return newvalue
|
||||
except self.model.DoesNotExist:
|
||||
logger.log_errmsg("Unable to set config value for %s (does not exist):\n%s" % (
|
||||
configname, (format_exc())))
|
||||
Loading…
Add table
Add a link
Reference in a new issue