Add DefaultChannel.basetype_setup and add default locks, empty at_channel_creation to avoid having to use super()
This commit is contained in:
parent
495078a49d
commit
84f7fbdd37
2 changed files with 12 additions and 5 deletions
|
|
@ -26,6 +26,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
the hooks called by this method.
|
the hooks called by this method.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
self.basetype_setup()
|
||||||
self.at_channel_creation()
|
self.at_channel_creation()
|
||||||
self.attributes.add("log_file", "channel_%s.log" % self.key)
|
self.attributes.add("log_file", "channel_%s.log" % self.key)
|
||||||
if hasattr(self, "_createdict"):
|
if hasattr(self, "_createdict"):
|
||||||
|
|
@ -46,11 +47,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
if cdict.get("desc"):
|
if cdict.get("desc"):
|
||||||
self.attributes.add("desc", cdict["desc"])
|
self.attributes.add("desc", cdict["desc"])
|
||||||
|
|
||||||
def at_channel_creation(self):
|
def basetype_setup(self):
|
||||||
"""
|
|
||||||
Called once, when the channel is first created.
|
|
||||||
|
|
||||||
"""
|
|
||||||
# delayed import of the channelhandler
|
# delayed import of the channelhandler
|
||||||
global _CHANNEL_HANDLER
|
global _CHANNEL_HANDLER
|
||||||
if not _CHANNEL_HANDLER:
|
if not _CHANNEL_HANDLER:
|
||||||
|
|
@ -58,6 +55,15 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
# register ourselves with the channelhandler.
|
# register ourselves with the channelhandler.
|
||||||
_CHANNEL_HANDLER.add(self)
|
_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
|
# helper methods, for easy overloading
|
||||||
|
|
||||||
def has_connection(self, subscriber):
|
def has_connection(self, subscriber):
|
||||||
|
|
|
||||||
|
|
@ -527,6 +527,7 @@ class SubscriptionHandler(object):
|
||||||
for subscriber in make_iter(entity):
|
for subscriber in make_iter(entity):
|
||||||
if subscriber:
|
if subscriber:
|
||||||
clsname = subscriber.__dbclass__.__name__
|
clsname = subscriber.__dbclass__.__name__
|
||||||
|
print("subscriber:", subscriber, clsname)
|
||||||
# chooses the right type
|
# chooses the right type
|
||||||
if clsname == "ObjectDB":
|
if clsname == "ObjectDB":
|
||||||
self.obj.db_object_subscriptions.add(subscriber)
|
self.obj.db_object_subscriptions.add(subscriber)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue