From 84f7fbdd37c414fc90d9b4e039b1451be01f2ef8 Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 8 Feb 2018 22:46:14 +0100 Subject: [PATCH] Add DefaultChannel.basetype_setup and add default locks, empty at_channel_creation to avoid having to use super() --- evennia/comms/comms.py | 16 +++++++++++----- evennia/comms/models.py | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/evennia/comms/comms.py b/evennia/comms/comms.py index e40de664d1..7ff62dfc27 100644 --- a/evennia/comms/comms.py +++ b/evennia/comms/comms.py @@ -26,6 +26,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)): the hooks called by this method. """ + self.basetype_setup() self.at_channel_creation() self.attributes.add("log_file", "channel_%s.log" % self.key) if hasattr(self, "_createdict"): @@ -46,11 +47,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)): if cdict.get("desc"): self.attributes.add("desc", cdict["desc"]) - def at_channel_creation(self): - """ - Called once, when the channel is first created. - - """ + def basetype_setup(self): # delayed import of the channelhandler global _CHANNEL_HANDLER if not _CHANNEL_HANDLER: @@ -58,6 +55,15 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)): # register ourselves with the channelhandler. _CHANNEL_HANDLER.add(self) + self.locks.add("send:all();listen:all();control:perm(Admin)") + + def at_channel_creation(self): + """ + Called once, when the channel is first created. + + """ + pass + # helper methods, for easy overloading def has_connection(self, subscriber): diff --git a/evennia/comms/models.py b/evennia/comms/models.py index b1a5a37ed9..c456a6e72c 100644 --- a/evennia/comms/models.py +++ b/evennia/comms/models.py @@ -527,6 +527,7 @@ class SubscriptionHandler(object): for subscriber in make_iter(entity): if subscriber: clsname = subscriber.__dbclass__.__name__ + print("subscriber:", subscriber, clsname) # chooses the right type if clsname == "ObjectDB": self.obj.db_object_subscriptions.add(subscriber)