Mercurial > libervia-pubsub
diff sat_pubsub/mam.py @ 414:ccb2a22ea0fc
Python 3 port:
/!\ Python 3.6+ is now needed to use SàT Pubsub
/!\ instability may occur and features may not be working anymore, this will improve with time
The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs
for details).
Python minimal version has been updated in setup.py
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 16 Aug 2019 12:53:33 +0200 |
parents | c56a728412f1 |
children | 5e8b8ef5c862 |
line wrap: on
line diff
--- a/sat_pubsub/mam.py Fri Aug 16 12:48:34 2019 +0200 +++ b/sat_pubsub/mam.py Fri Aug 16 12:53:33 2019 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 #-*- coding: utf-8 -*- # Copyright (c) 2016 Jérôme Poisson @@ -25,7 +25,7 @@ """ -from zope.interface import implements +from zope.interface import implementer from twisted.words.xish import domish from twisted.python import log @@ -40,8 +40,8 @@ from wokkel import delay +@implementer(mam.IMAMResource) class MAMResource(object): - implements(mam.IMAMResource) _errorMap = backend.PubSubResourceFromBackend._errorMap def __init__(self, backend_): @@ -49,7 +49,7 @@ def _mapErrors(self, failure): # XXX: come from backend.PubsubResourceFromBackend - e = failure.trap(*self._errorMap.keys()) + e = failure.trap(*list(self._errorMap.keys())) condition, pubsubCondition, feature = self._errorMap[e] msg = failure.value.msg @@ -77,7 +77,7 @@ pep = False ext_data = {'pep': pep} if mam_request.form: - ext_data['filters'] = mam_request.form.fields.values() + ext_data['filters'] = list(mam_request.form.fields.values()) if mam_request.rsm is None: if const.VAL_RSM_MAX_DEFAULT != None: log.msg("MAM request without RSM limited to {}".format(const.VAL_RSM_MAX_DEFAULT)) @@ -114,7 +114,7 @@ # "complete" # attribute set to "true". page_max = (int(rsm_elt.first['index']) + 1) * mam_request.rsm.max - count = int(unicode(rsm_elt.count)) + count = int(str(rsm_elt.count)) if page_max >= count: # the maximum items which can be displayed is equal to or # above the total number of items, which means we are complete