Updates for making Evennia compatible with Django 1.8+. Still not fully functioning.

This commit is contained in:
Griatch 2015-04-03 20:48:20 +02:00
parent 1bb886de03
commit ee1ec3979c
7 changed files with 8 additions and 17 deletions

View file

@ -471,6 +471,7 @@ class ChannelDB(TypedObject):
__settingclasspath__ = settings.BASE_CHANNEL_TYPECLASS
__defaultclasspath__ = "evennia.comms.comms.DefaultChannel"
__applabel__ = "comms"
class Meta:
"Define Django meta options"

View file

@ -182,6 +182,7 @@ class ObjectDB(TypedObject):
# defaults
__settingsclasspath__ = settings.BASE_OBJECT_TYPECLASS
__defaultclasspath__ = "evennia.objects.objects.DefaultObject"
__applabel__ = "objects"
@lazy_property
def contents_cache(self):

View file

@ -96,9 +96,9 @@ class PlayerDB(TypedObject, AbstractUser):
# defaults
__settingsclasspath__ = settings.BASE_SCRIPT_TYPECLASS
__defaultclasspath__ = "evennia.players.players.DefaultPlayer"
__applabel__ = "players"
class Meta:
app_label = 'players'
verbose_name = 'Player'
# alias to the objs property

View file

@ -44,7 +44,7 @@ class ScriptDBManager(TypedObjectManager):
"""
if not obj:
return []
player = _GA(_GA(obj, "__class__"), "__name__") == "PlayerDB"
player = _GA(_GA(obj, "__dbclass__"), "__name__") == "PlayerDB"
if key:
dbref = self.dbref(key)
if dbref or dbref == 0:

View file

@ -103,6 +103,7 @@ class ScriptDB(TypedObject):
# defaults
__settingsclasspath__ = settings.BASE_SCRIPT_TYPECLASS
__defaultclasspath__ = "evennia.scripts.scripts.DefaultScript"
__applabel__ = "scripts"
class Meta:
"Define Django meta options"

View file

@ -454,6 +454,8 @@ def check_database():
# Check so a database exists and is accessible
from django.db import connection
tables = connection.introspection.get_table_list(connection.cursor())
if not isinstance(tables, basestring): # django 1.8+
tables = [tableinfo.name for tableinfo in tables]
if tables and u'players_playerdb' in tables:
# database exists and seems set up. Initialize evennia.
import evennia

View file

@ -91,26 +91,12 @@ class TypeclassBase(SharedMemoryModelBase):
# storage of stats
attrs["typename"] = name
attrs["path"] = "%s.%s" % (attrs["__module__"], name)
#defaultpath = attrs["__defaultclasspath__"]
#attrs["__defaultclass__"] = class_from_module(attrs["__defaultclasspath__"])
#try:
# defaultpath = attrs["__defaultclasspath__"]
# attrs["__defaultclass__"] = class_from_module(attrs["__defaultclasspath__"])
#except Exception:
# log_trace("Typeclass error for %s: Default typeclass '%s' could not load. "
# "Falling back to library base." % (name, defaultpath))
# try:
# # two levels down from TypedObject will always be the default base class.
# attrs["__defaultclass__"] = cls.__mro__[cls.__mro__.index(TypedObject)-2]
# except Exception:
# log_trace("Critical error for %s: Neither typeclass, "
# "default fallback nor base class could load." % name)
# attrs["__defaultclass__"] = cls
# typeclass proxy setup
if not "Meta" in attrs:
class Meta:
proxy = True
app_label = attrs.get("__applabel__", "typeclasses")
attrs["Meta"] = Meta
attrs["Meta"].proxy = True