mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 21:47:17 +02:00
Fixed correct and separate handling of database model bases as compared to its proxy classes using different managers for each type (e.g. ObjectDB.objects.all() will return all ObjectDB instances(including proxy instances) whereas Object.objects.all() will only return Objects)
This commit is contained in:
parent
554d1b9834
commit
2ee9e62336
15 changed files with 105 additions and 79 deletions
|
|
@ -6,7 +6,7 @@ Also, the initiated object manager is available as src.objects.manager.
|
|||
|
||||
"""
|
||||
|
||||
from src.objects.objects import *
|
||||
#from src.objects.objects import *
|
||||
from src.objects.models import ObjectDB
|
||||
|
||||
manager = ObjectDB.objects
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from itertools import chain
|
|||
from django.db.models import Q
|
||||
from django.conf import settings
|
||||
from django.db.models.fields import exceptions
|
||||
from src.typeclasses.managers import TypedObjectManager
|
||||
from src.typeclasses.managers import TypedObjectManager, TypeclassManager
|
||||
from src.typeclasses.managers import returns_typeclass, returns_typeclass_list
|
||||
from src.utils import utils
|
||||
from src.utils.utils import to_unicode, is_iter, make_iter, string_partial_matching
|
||||
|
|
@ -22,7 +22,7 @@ _ATTR = None
|
|||
_AT_MULTIMATCH_INPUT = utils.variable_from_module(*settings.SEARCH_AT_MULTIMATCH_INPUT.rsplit('.', 1))
|
||||
|
||||
|
||||
class ObjectManager(TypedObjectManager):
|
||||
class ObjectDBManager(TypedObjectManager):
|
||||
"""
|
||||
This ObjectManager implementes methods for searching
|
||||
and manipulating Objects directly from the database.
|
||||
|
|
@ -413,3 +413,6 @@ class ObjectManager(TypedObjectManager):
|
|||
"""
|
||||
self.filter(db_sessid__isnull=False).update(db_sessid=None)
|
||||
|
||||
|
||||
class ObjectManager(ObjectDBManager, TypeclassManager):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ from django.conf import settings
|
|||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from src.typeclasses.models import TypedObject, NickHandler
|
||||
from src.objects.manager import ObjectManager
|
||||
from src.objects.manager import ObjectDBManager
|
||||
from src.players.models import PlayerDB
|
||||
from src.commands.cmdsethandler import CmdSetHandler
|
||||
from src.commands import cmdhandler
|
||||
|
|
@ -171,7 +171,7 @@ class ObjectDB(TypedObject):
|
|||
help_text="optional python path to a cmdset class.")
|
||||
|
||||
# Database manager
|
||||
objects = ObjectManager()
|
||||
objects = ObjectDBManager()
|
||||
|
||||
# caches for quick lookups of typeclass loading.
|
||||
_typeclass_paths = settings.OBJECT_TYPECLASS_PATHS
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ they control by simply linking to a new object's user property.
|
|||
|
||||
from django.conf import settings
|
||||
from src.typeclasses.models import TypeclassBase
|
||||
from src.objects.manager import ObjectTypeclassManager
|
||||
from src.objects.models import ObjectDB
|
||||
from src.commands import cmdset, command
|
||||
from src.utils.logger import log_depmsg
|
||||
|
|
@ -39,6 +40,7 @@ class Object(ObjectDB):
|
|||
|
||||
"""
|
||||
__metaclass__ = TypeclassBase
|
||||
objects = ObjectTypeclassManager()
|
||||
|
||||
# __init__ is only defined here in order to present docstring to API.
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue