mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 13:07:16 +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
|
|
@ -3,7 +3,7 @@ The custom manager for Scripts.
|
|||
"""
|
||||
|
||||
from django.db.models import Q
|
||||
from src.typeclasses.managers import TypedObjectManager
|
||||
from src.typeclasses.managers import TypedObjectManager, TypeclassManager
|
||||
from src.typeclasses.managers import returns_typeclass_list
|
||||
from src.utils.utils import make_iter
|
||||
__all__ = ("ScriptManager",)
|
||||
|
|
@ -12,7 +12,7 @@ _GA = object.__getattribute__
|
|||
VALIDATE_ITERATION = 0
|
||||
|
||||
|
||||
class ScriptManager(TypedObjectManager):
|
||||
class ScriptDBManager(TypedObjectManager):
|
||||
"""
|
||||
This Scriptmanager implements methods for searching
|
||||
and manipulating Scripts directly from the database.
|
||||
|
|
@ -230,3 +230,6 @@ class ScriptManager(TypedObjectManager):
|
|||
new_script = create.create_script(typeclass, key=new_key, obj=new_obj,
|
||||
locks=new_locks, autostart=True)
|
||||
return new_script
|
||||
|
||||
class ScriptManager(ScriptDBManager, TypeclassManager):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ from django.conf import settings
|
|||
from django.db import models
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from src.typeclasses.models import TypedObject
|
||||
from src.scripts.manager import ScriptManager
|
||||
from src.scripts.manager import ScriptDBManager
|
||||
from src.utils.utils import dbref, to_str
|
||||
|
||||
__all__ = ("ScriptDB",)
|
||||
|
|
@ -98,7 +98,7 @@ class ScriptDB(TypedObject):
|
|||
db_is_active = models.BooleanField('script active', default=False)
|
||||
|
||||
# Database manager
|
||||
objects = ScriptManager()
|
||||
objects = ScriptDBManager()
|
||||
|
||||
# caches for quick lookups
|
||||
_typeclass_paths = settings.SCRIPT_TYPECLASS_PATHS
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from django.conf import settings
|
|||
from src.typeclasses.models import TypeclassBase
|
||||
from django.utils.translation import ugettext as _
|
||||
from src.scripts.models import ScriptDB
|
||||
from src.scripts.manager import ScriptManager
|
||||
from src.comms import channelhandler
|
||||
from src.utils import logger
|
||||
|
||||
|
|
@ -114,6 +115,7 @@ class ScriptBase(ScriptDB):
|
|||
from the class 'Script' instead.
|
||||
"""
|
||||
__metaclass__ = TypeclassBase
|
||||
objects = ScriptManager()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue