Some deprecation fixes for django1.4+. Added the ability to add lists to Attribute-stores lists using e.g. obj.db.mylist + [1,2,3,4]
This commit is contained in:
parent
c943b13351
commit
89c33a9197
7 changed files with 29 additions and 16 deletions
|
|
@ -81,10 +81,14 @@ from twisted.internet.defer import inlineCallbacks
|
||||||
|
|
||||||
# set up django, if necessary
|
# set up django, if necessary
|
||||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
||||||
from django.core.management import setup_environ
|
|
||||||
from game import settings
|
from game import settings
|
||||||
setup_environ(settings)
|
try:
|
||||||
#from src.utils.utils import run_async as thread_run_async
|
from django.conf import settings as settings2
|
||||||
|
settings2.configure()
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
del settings2
|
||||||
|
|
||||||
_LOGGER = None
|
_LOGGER = None
|
||||||
|
|
||||||
|
|
|
||||||
11
ev.py
11
ev.py
|
|
@ -48,7 +48,6 @@ Notes:
|
||||||
this API.
|
this API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
@ -89,10 +88,14 @@ if __name__ == "__main__":
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
from django.core.management import setup_environ
|
|
||||||
from game import settings
|
from game import settings
|
||||||
setup_environ(settings)
|
try:
|
||||||
del setup_environ
|
from django.conf import settings as settings2
|
||||||
|
settings2.configure()
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
del settings2
|
||||||
from django.conf import settings as settings_full
|
from django.conf import settings as settings_full
|
||||||
del sys, os
|
del sys, os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ class CmdWho(MuxPlayerCommand):
|
||||||
utils.time.format(delta_conn, 0),
|
utils.time.format(delta_conn, 0),
|
||||||
utils,time_format(delta_cmd, 1)])
|
utils,time_format(delta_cmd, 1)])
|
||||||
|
|
||||||
string = "{wPlayers:\n%s\n%s unique accounts logged in." % (table, nplayers==1 and "One player" or nplayers)
|
string = "{wPlayers:{n\n%s\n%s unique accounts logged in." % (table, nplayers==1 and "One player" or nplayers)
|
||||||
self.msg(string)
|
self.msg(string)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,6 @@ MEDIA_URL = '/media/'
|
||||||
# to use a trailing slash. Django1.4+ will look for admin files under
|
# to use a trailing slash. Django1.4+ will look for admin files under
|
||||||
# STATIC_URL/admin.
|
# STATIC_URL/admin.
|
||||||
STATIC_URL = '/media/'
|
STATIC_URL = '/media/'
|
||||||
ADMIN_MEDIA_PREFIX = STATIC_URL + "admin/" # needed for backwards compatibility django < 1.4
|
|
||||||
# The name of the currently selected web template. This corresponds to the
|
# The name of the currently selected web template. This corresponds to the
|
||||||
# directory names shown in the webtemplates directory.
|
# directory names shown in the webtemplates directory.
|
||||||
ACTIVE_TEMPLATE = 'prosimii'
|
ACTIVE_TEMPLATE = 'prosimii'
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,6 @@ import codecs
|
||||||
import traceback, sys
|
import traceback, sys
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management import setup_environ
|
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
from src.utils import utils
|
from src.utils import utils
|
||||||
from game import settings as settings_module
|
from game import settings as settings_module
|
||||||
|
|
@ -485,15 +484,14 @@ class BatchCodeProcessor(object):
|
||||||
extra_environ - dict with environment variables
|
extra_environ - dict with environment variables
|
||||||
"""
|
"""
|
||||||
# define the execution environment
|
# define the execution environment
|
||||||
environ = "setup_environ(settings_module)"
|
environ = "settings_module.configure()"
|
||||||
environdict = {"setup_environ":setup_environ,
|
environdict = {"settings_module":settings}
|
||||||
"settings_module":settings_module}
|
|
||||||
if extra_environ:
|
if extra_environ:
|
||||||
for key, value in extra_environ.items():
|
for key, value in extra_environ.items():
|
||||||
environdict[key] = value
|
environdict[key] = value
|
||||||
|
|
||||||
# merge all into one block
|
# merge all into one block
|
||||||
code = "%s # auto-added by Evennia\n%s" % (environ, codedict['code'])
|
code = "# auto-added by Evennia\ntry:%s\nexcept RuntimeError:pass\nfinally:del settings_module\n%s" % (environ, codedict['code'])
|
||||||
if debug:
|
if debug:
|
||||||
# try to delete marked objects
|
# try to delete marked objects
|
||||||
for obj in codedict['objs']:
|
for obj in codedict['objs']:
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,10 @@ class _SaverList(_SaverMutable, MutableSequence):
|
||||||
super(_SaverList, self).__init__(*args, **kwargs)
|
super(_SaverList, self).__init__(*args, **kwargs)
|
||||||
self._data = list(*args)
|
self._data = list(*args)
|
||||||
@_save
|
@_save
|
||||||
|
def __add__(self, otherlist):
|
||||||
|
self._data = self._data.__add__(otherlist)
|
||||||
|
return self._data
|
||||||
|
@_save
|
||||||
def insert(self, index, value):
|
def insert(self, index, value):
|
||||||
self._data.insert(index, self._convert_mutables(value))
|
self._data.insert(index, self._convert_mutables(value))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,14 @@ from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
# Tack on the root evennia directory to the python path and initialize django settings
|
# Tack on the root evennia directory to the python path and initialize django settings
|
||||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
|
||||||
from django.core.management import setup_environ
|
|
||||||
from game import settings
|
from game import settings
|
||||||
setup_environ(settings)
|
try:
|
||||||
|
from django.conf import settings as settings2
|
||||||
|
settings2.configure()
|
||||||
|
except RuntimeError
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
del settings2
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from src.utils import utils
|
from src.utils import utils
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue