Fixed some errors in channel loading.
This commit is contained in:
parent
dd20740e73
commit
11449f3d62
3 changed files with 17 additions and 11 deletions
|
|
@ -298,7 +298,7 @@ BASE_ROOM_TYPECLASS = "src.objects.objects.DefaultRoom"
|
||||||
# Typeclass for Exit objects (fallback).
|
# Typeclass for Exit objects (fallback).
|
||||||
BASE_EXIT_TYPECLASS = "src.objects.objects.DefaultExit"
|
BASE_EXIT_TYPECLASS = "src.objects.objects.DefaultExit"
|
||||||
# Typeclass for Channel (fallback).
|
# Typeclass for Channel (fallback).
|
||||||
BASE_CHANNEL_TYPECLASS = "src.comms.comms.DefaultChannel"
|
BASE_CHANNEL_TYPECLASS = "src.comms.comms.Channel"
|
||||||
# Typeclass for Scripts (fallback). You usually don't need to change this
|
# Typeclass for Scripts (fallback). You usually don't need to change this
|
||||||
# but create custom variations of scripts on a per-case basis instead.
|
# but create custom variations of scripts on a per-case basis instead.
|
||||||
BASE_SCRIPT_TYPECLASS = "src.scripts.scripts.DoNothing"
|
BASE_SCRIPT_TYPECLASS = "src.scripts.scripts.DoNothing"
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ from src.server.caches import get_prop_cache, set_prop_cache
|
||||||
from src.typeclasses import managers
|
from src.typeclasses import managers
|
||||||
from src.locks.lockhandler import LockHandler
|
from src.locks.lockhandler import LockHandler
|
||||||
from src.utils.utils import (
|
from src.utils.utils import (
|
||||||
is_iter, to_str, inherits_from, lazy_property,
|
is_iter, inherits_from, lazy_property,
|
||||||
class_from_module)
|
class_from_module)
|
||||||
from src.typeclasses.django_new_patch import patched_new
|
from src.typeclasses.django_new_patch import patched_new
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ class TypedObject(SharedMemoryModel):
|
||||||
else:
|
else:
|
||||||
self.db_typeclass_path = "%s.%s" % (self.__module__, self.__class__.__name__)
|
self.db_typeclass_path = "%s.%s" % (self.__module__, self.__class__.__name__)
|
||||||
# important to put this at the end since _meta is based on the set __class__
|
# important to put this at the end since _meta is based on the set __class__
|
||||||
self.__dbclass__ = self._meta.proxy_for_model
|
self.__dbclass__ = self._meta.proxy_for_model or self.__class__
|
||||||
|
|
||||||
# initialize all handlers in a lazy fashion
|
# initialize all handlers in a lazy fashion
|
||||||
@lazy_property
|
@lazy_property
|
||||||
|
|
@ -348,6 +348,7 @@ class TypedObject(SharedMemoryModel):
|
||||||
"right type instead." % self.key)
|
"right type instead." % self.key)
|
||||||
|
|
||||||
self.typeclass_path = new_typeclass.path
|
self.typeclass_path = new_typeclass.path
|
||||||
|
self.__class__ = new_typeclass
|
||||||
|
|
||||||
if clean_attributes:
|
if clean_attributes:
|
||||||
# Clean out old attributes
|
# Clean out old attributes
|
||||||
|
|
|
||||||
|
|
@ -933,24 +933,29 @@ def class_from_module(path, defaultpaths=None):
|
||||||
"""
|
"""
|
||||||
cls = None
|
cls = None
|
||||||
if defaultpaths:
|
if defaultpaths:
|
||||||
paths = [path] + make_iter(defaultpaths) if defaultpaths else []
|
paths = [path] + ["%s.%s" % (dpath, path) for dpath in make_iter(defaultpaths)] if defaultpaths else []
|
||||||
else:
|
else:
|
||||||
paths = [path]
|
paths = [path]
|
||||||
|
|
||||||
for path in paths:
|
for testpath in paths:
|
||||||
path, clsname = path.rsplit(".", 1)
|
if "." in path:
|
||||||
|
testpath, clsname = testpath.rsplit(".", 1)
|
||||||
|
else:
|
||||||
|
testpath, clsname = ".", testpath
|
||||||
try:
|
try:
|
||||||
mod = import_module(path)
|
mod = import_module(testpath)
|
||||||
except ImportError, ex:
|
except ImportError, ex:
|
||||||
# normally this is due to a not-found property
|
# normally this is due to a not-found property
|
||||||
if not str(ex).startswith ("No module named %s" % path):
|
if not str(ex).startswith("No module named"):
|
||||||
raise ex
|
exc = sys.exc_info()
|
||||||
|
raise exc[1], None, exc[2]
|
||||||
try:
|
try:
|
||||||
cls = getattr(mod, clsname)
|
cls = getattr(mod, clsname)
|
||||||
break
|
break
|
||||||
except AttributeError, ex:
|
except AttributeError, ex:
|
||||||
if not str(ex).startswith("Object 'module' has no attribute '%s'" % clsname):
|
if not str(ex).startswith("'module' object has no attribute '%s'" % clsname):
|
||||||
raise ex
|
exc = sys.exc_info()
|
||||||
|
raise exc[1], None, exc[2]
|
||||||
if not cls:
|
if not cls:
|
||||||
raise ImportError("Could not load typeclass '%s'." % path)
|
raise ImportError("Could not load typeclass '%s'." % path)
|
||||||
return cls
|
return cls
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue