Make channelhandler easier to import at different stages without a circular import problem.
This commit is contained in:
parent
73bb293156
commit
589d6737db
1 changed files with 10 additions and 3 deletions
|
|
@ -26,13 +26,13 @@ does this for you.
|
||||||
from builtins import object
|
from builtins import object
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from evennia.comms.models import ChannelDB
|
|
||||||
from evennia.commands import cmdset, command
|
from evennia.commands import cmdset, command
|
||||||
from evennia.utils.logger import tail_log_file
|
from evennia.utils.logger import tail_log_file
|
||||||
from evennia.utils.utils import class_from_module
|
from evennia.utils.utils import class_from_module
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
_CHANNEL_COMMAND_CLASS = None
|
_CHANNEL_COMMAND_CLASS = None
|
||||||
|
_CHANNELDB = None
|
||||||
|
|
||||||
class ChannelCommand(command.Command):
|
class ChannelCommand(command.Command):
|
||||||
"""
|
"""
|
||||||
|
|
@ -85,12 +85,16 @@ class ChannelCommand(command.Command):
|
||||||
Create a new message and send it to channel, using
|
Create a new message and send it to channel, using
|
||||||
the already formatted input.
|
the already formatted input.
|
||||||
"""
|
"""
|
||||||
|
global _CHANNELDB
|
||||||
|
if not _CHANNELDB:
|
||||||
|
from evennia.comms.models import ChannelDB as _CHANNELDB
|
||||||
|
|
||||||
channelkey, msg = self.args
|
channelkey, msg = self.args
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
if not msg:
|
if not msg:
|
||||||
self.msg(_("Say what?"))
|
self.msg(_("Say what?"))
|
||||||
return
|
return
|
||||||
channel = ChannelDB.objects.get_channel(channelkey)
|
channel = _CHANNELDB.objects.get_channel(channelkey)
|
||||||
|
|
||||||
if not channel:
|
if not channel:
|
||||||
self.msg(_("Channel '%s' not found.") % channelkey)
|
self.msg(_("Channel '%s' not found.") % channelkey)
|
||||||
|
|
@ -200,9 +204,12 @@ class ChannelHandler(object):
|
||||||
Channel objects. This must be called after deleting a Channel.
|
Channel objects. This must be called after deleting a Channel.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
global _CHANNELDB
|
||||||
|
if not _CHANNELDB:
|
||||||
|
from evennia.comms.models import ChannelDB as _CHANNELDB
|
||||||
self.cached_channel_cmds = []
|
self.cached_channel_cmds = []
|
||||||
self.cached_cmdsets = {}
|
self.cached_cmdsets = {}
|
||||||
for channel in ChannelDB.objects.get_all_channels():
|
for channel in _CHANNELDB.objects.get_all_channels():
|
||||||
self.add_channel(channel)
|
self.add_channel(channel)
|
||||||
|
|
||||||
def get_cmdset(self, source_object):
|
def get_cmdset(self, source_object):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue