mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 20:47:17 +02:00
Migration needed. Refactored the config.configValue model into server.ServerConfig (that's what the config model were used for anyway). The new model can handle arbitrary data structures through pickle. Run ./manage.py migrate to sync your database with the new setup.
Moved Connect screens (the text screen first seen when connecting) away from the database and into a module in gamesrc/world. This module allows for conveniently adding new connect screens on the fly. More than one screen in the given module will mean a random screen is used.
This commit is contained in:
parent
f1404356ea
commit
7f9f21f45e
21 changed files with 162 additions and 257 deletions
31
src/server/manager.py
Normal file
31
src/server/manager.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"""
|
||||
Custom manager for ServerConfig objects.
|
||||
"""
|
||||
from django.db import models
|
||||
|
||||
class ServerConfigManager(models.Manager):
|
||||
"""
|
||||
This gives some access methods to search and edit
|
||||
the configvalue database.
|
||||
|
||||
If no match is found, return default.
|
||||
"""
|
||||
def conf(self, key=None, value=None, delete=False, default=None):
|
||||
"""
|
||||
Access and manipulate config values
|
||||
"""
|
||||
if not key:
|
||||
return self.all()
|
||||
elif delete == True:
|
||||
for conf in self.filter(db_key=key):
|
||||
conf.delete()
|
||||
elif value != None:
|
||||
conf = self.filter(db_key=key)
|
||||
if not conf:
|
||||
conf = self.model(db_key=key)
|
||||
conf.value = value # this will pickle
|
||||
else:
|
||||
conf = self.filter(db_key=key)
|
||||
if not conf:
|
||||
return default
|
||||
return conf[0].value
|
||||
Loading…
Add table
Add a link
Reference in a new issue