The first of many re-arrangements. Eliminated gameconf in favor of using the manager on ConfigValue. Moved some commands while I was at it. There are going to be crash bugs that need to be found and worked out.
This commit is contained in:
parent
8a1204ce76
commit
d620f3b1f0
17 changed files with 216 additions and 200 deletions
|
|
@ -1,8 +1,32 @@
|
|||
"""
|
||||
Custom manager for ConfigValue objects.
|
||||
"""
|
||||
from traceback import format_exc
|
||||
from django.db import models
|
||||
import functions_log
|
||||
|
||||
class ConfigValueManager(models.Manager):
|
||||
pass
|
||||
|
||||
def get_configvalue(self, configname):
|
||||
"""
|
||||
Retrieve a configuration value.
|
||||
"""
|
||||
try:
|
||||
return self.get(conf_key__iexact=configname).conf_value
|
||||
except self.model.DoesNotExist:
|
||||
functions_log.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:
|
||||
functions_log.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