summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2010-10-28 16:44:46 -0400
committerLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2010-12-03 10:55:44 -0500
commit620fe9b1d2dc3b8158e04551837a9c8694bcc8a4 (patch)
treec31d71dc33ff3c48229ed7713eef12fab4088958
parent6bfba32a582e3ee29033206c9d5c547817ca7dce (diff)
Add new way to set requestable channel classes on channel manager
We can pass the whole classes dictionary instead of splitting it. This way, the dict can be only specified once in the Protocol _requestable_channels property in CMs. Deprecated ways of specifying requestable channel classes are still supported.
-rw-r--r--src/server/channelmanager.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/server/channelmanager.py b/src/server/channelmanager.py
index 2752f3a..201ff99 100644
--- a/src/server/channelmanager.py
+++ b/src/server/channelmanager.py
@@ -37,7 +37,7 @@ class ChannelManager(object):
self._fixed_properties = dict()
self._available_properties = dict()
- self._requestables = dict()
+ self._requestables = list()
def close(self):
"""Close channel manager and all the existing channels."""
@@ -129,8 +129,9 @@ class ChannelManager(object):
"""Implement channel types in the channel manager, and add one channel
class that is retrieved in RequestableChannelClasses.
- self.implement_channel_classes should be used instead, as it allows
- implementing multiple channel classes."""
+ self.implement_channel_classes and self.set_requestable_channel_classes
+ should be used instead, as it allows implementing multiple channel
+ classes."""
warnings.warn('deprecated in favour of implement_channel_classes',
DeprecationWarning)
@@ -141,37 +142,36 @@ class ChannelManager(object):
self._available_properties[type] = available
# Use this function instead of _implement_channel_class.
- def implement_channel_classes(self, type, make_channel, classes):
+ def implement_channel_classes(self, type, make_channel, classes=None):
"""Implement channel types in the channel manager, and add channel
classes that are retrieved in RequestableChannelClasses.
@type: the channel type
@make_channel: a function to call which returns a Channel object
- @classes: a list of channel classes. E.g.
+ @classes: (deprecated)
- [ ( { '...ChannelType': '...Text', '...TargetHandleType': HANDLE_TYPE_CONTACT },
- ['...TargetHandle'] )
- ]
-
- See the spec for more documentation on the
- Requestable_Channel_Class struct.
+ The classes argument has been deprecated and the list of requestable
+ channel classes should be set using set_requestable_channel_classes.
"""
self._requestable_channels[type] = make_channel
self._channels.setdefault(type, {})
- self._requestables[type] = classes
+ if classes is not None:
+ warnings.warn('"classes" argument is deprecated',
+ DeprecationWarning)
+ self._requestables.extend(classes)
+
+ def set_requestable_channel_classes(self, requestables):
+ self._requestables = requestables
def get_requestable_channel_classes(self):
"""Return all the channel types that can be created"""
- retval = []
+ retval = self._requestables
+ # backward compatibility
for channel_type in self._requestable_channels:
- retval.extend(self._requestables.get(channel_type, []))
-
- # _implement_channel_class was used.
if channel_type in self._fixed_properties:
retval.append((self._fixed_properties[channel_type],
self._available_properties.get(channel_type, [])))
-
return retval