本文整理匯總了Python中ovs.lib.messaging.MessageController.subscribe方法的典型用法代碼示例。如果您正苦於以下問題:Python MessageController.subscribe方法的具體用法?Python MessageController.subscribe怎麽用?Python MessageController.subscribe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ovs.lib.messaging.MessageController
的用法示例。
在下文中一共展示了MessageController.subscribe方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: subscribe
# 需要導入模塊: from ovs.lib.messaging import MessageController [as 別名]
# 或者: from ovs.lib.messaging.MessageController import subscribe [as 別名]
def subscribe(self, request, pk):
"""
Subscribes a subscriber to a set of types
"""
try:
pk = int(pk)
subscriptions = request.DATA
cleaned_subscriptions = []
if not isinstance(subscriptions, list):
raise TypeError
for s in subscriptions:
if str(s) in MessageController.Type.ALL:
cleaned_subscriptions.append(str(s))
except (ValueError, TypeError):
return Response(status=status.HTTP_400_BAD_REQUEST)
MessageController.subscribe(pk, cleaned_subscriptions)
return Response(cleaned_subscriptions, status=status.HTTP_200_OK)