diff --git a/src/settings_default.py b/src/settings_default.py index 7a6d5b2e11..db9a2d247e 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -298,7 +298,7 @@ BASE_ROOM_TYPECLASS = "src.objects.objects.DefaultRoom" # Typeclass for Exit objects (fallback). BASE_EXIT_TYPECLASS = "src.objects.objects.DefaultExit" # 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 # but create custom variations of scripts on a per-case basis instead. BASE_SCRIPT_TYPECLASS = "src.scripts.scripts.DoNothing" diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index 874e3dab8c..7a98390e40 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -46,7 +46,7 @@ from src.server.caches import get_prop_cache, set_prop_cache from src.typeclasses import managers from src.locks.lockhandler import LockHandler from src.utils.utils import ( - is_iter, to_str, inherits_from, lazy_property, + is_iter, inherits_from, lazy_property, class_from_module) from src.typeclasses.django_new_patch import patched_new @@ -191,7 +191,7 @@ class TypedObject(SharedMemoryModel): else: 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__ - self.__dbclass__ = self._meta.proxy_for_model + self.__dbclass__ = self._meta.proxy_for_model or self.__class__ # initialize all handlers in a lazy fashion @lazy_property @@ -348,6 +348,7 @@ class TypedObject(SharedMemoryModel): "right type instead." % self.key) self.typeclass_path = new_typeclass.path + self.__class__ = new_typeclass if clean_attributes: # Clean out old attributes diff --git a/src/utils/utils.py b/src/utils/utils.py index fa17d4e0e7..89c54bab80 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -933,24 +933,29 @@ def class_from_module(path, defaultpaths=None): """ cls = None 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: paths = [path] - for path in paths: - path, clsname = path.rsplit(".", 1) + for testpath in paths: + if "." in path: + testpath, clsname = testpath.rsplit(".", 1) + else: + testpath, clsname = ".", testpath try: - mod = import_module(path) + mod = import_module(testpath) except ImportError, ex: # normally this is due to a not-found property - if not str(ex).startswith ("No module named %s" % path): - raise ex + if not str(ex).startswith("No module named"): + exc = sys.exc_info() + raise exc[1], None, exc[2] try: cls = getattr(mod, clsname) break except AttributeError, ex: - if not str(ex).startswith("Object 'module' has no attribute '%s'" % clsname): - raise ex + if not str(ex).startswith("'module' object has no attribute '%s'" % clsname): + exc = sys.exc_info() + raise exc[1], None, exc[2] if not cls: raise ImportError("Could not load typeclass '%s'." % path) return cls