Fix additional things needed for stand-alone import of evennia lib

This commit is contained in:
Griatch 2021-02-27 13:58:51 +01:00
parent 12933520b8
commit aefe2b070f

View file

@ -26,7 +26,7 @@ Example: To reach the search method 'get_object_with_account'
# Import the manager methods to be wrapped
from django.db.utils impoort OperationalError
from django.db.utils import OperationalError
from django.contrib.contenttypes.models import ContentType
# limit symbol import from API
@ -49,11 +49,11 @@ try:
AccountDB = ContentType.objects.get(app_label="accounts", model="accountdb").model_class()
ScriptDB = ContentType.objects.get(app_label="scripts", model="scriptdb").model_class()
Msg = ContentType.objects.get(app_label="comms", model="msg").model_class()
Channel = ContentType.objects.get(app_label="comms", model="channeldb").model_class()
ChannelDB = ContentType.objects.get(app_label="comms", model="channeldb").model_class()
HelpEntry = ContentType.objects.get(app_label="help", model="helpentry").model_class()
Tag = ContentType.objects.get(app_label="typeclasses", model="tag").model_class()
except OperationalError:
# this is a fallback used during tests/doc building
# this is a fallback used during tests/doc building
print("Couldn't initialize search managers - db not set up.")
from evennia.objects.models import ObjectDB
from evennia.accounts.models import AccountDB
@ -180,7 +180,7 @@ messages = search_messages
# exact - requires an exact ostring match (not case sensitive)
#
search_channel = Channel.objects.channel_search
search_channel = ChannelDB.objects.channel_search
search_channels = search_channel
channel_search = search_channel
channels = search_channels
@ -241,7 +241,7 @@ def search_script_attribute(
def search_channel_attribute(
key=None, category=None, value=None, strvalue=None, attrtype=None, **kwargs
):
return Channel.objects.get_by_attribute(
return ChannelDB.objects.get_by_attribute(
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
)
@ -356,7 +356,7 @@ def search_channel_tag(key=None, category=None, tagtype=None, **kwargs):
matches were found.
"""
return Channel.objects.get_by_tag(key=key, category=category, tagtype=tagtype, **kwargs)
return ChannelDB.objects.get_by_tag(key=key, category=category, tagtype=tagtype, **kwargs)
# search for tag objects (not the objects they are attached to