diff libervia/server/session_iface.py @ 1216:b2d067339de3

python 3 port: /!\ Python 3.6+ is now needed to use libervia /!\ instability may occur and features may not be working anymore, this will improve with time /!\ TxJSONRPC dependency has been removed The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs for details). Removed now deprecated code (Pyjamas compiled browser part, legacy blog, JSON RPC related code). Adapted code to work without `html` and `themes` dirs.
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:12:31 +0200
parents 352865f4a268
children 987595a254b0
line wrap: on
line diff
--- a/libervia/server/session_iface.py	Tue Aug 13 09:39:33 2019 +0200
+++ b/libervia/server/session_iface.py	Tue Aug 13 19:12:31 2019 +0200
@@ -16,7 +16,8 @@
 
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-from zope.interface import Interface, Attribute, implements
+from zope.interface import Interface, Attribute
+from zope.interface import implementer
 from sat.tools.common import data_objects
 from libervia.server.constants import Const as C
 from libervia.server.classes import Notification
@@ -37,8 +38,8 @@
     identities = Attribute("Identities of XMPP entities")
 
 
+@implementer(ISATSession)
 class SATSession(object):
-    implements(ISATSession)
 
     def __init__(self, session):
         self.profile = None
@@ -46,9 +47,9 @@
         self.started = time.time()
         # time when the backend session was started
         self.backend_started = None
-        self.uuid = unicode(shortuuid.uuid())
+        self.uuid = str(shortuuid.uuid())
         self.identities = data_objects.Identities()
-        self.csrf_token = unicode(shortuuid.uuid())
+        self.csrf_token = str(shortuuid.uuid())
         self.locale = None  # i18n of the pages
         self.pages_data = {}  # used to keep data accross reloads (key is page instance)
         self.affiliations = OrderedDict()  # cache for node affiliations
@@ -56,8 +57,8 @@
     @property
     def cache_dir(self):
         if self.profile is None:
-            return self.service_cache_url + u"/"
-        return os.path.join(u"/", C.CACHE_DIR, self.uuid) + u"/"
+            return self.service_cache_url + "/"
+        return os.path.join("/", C.CACHE_DIR, self.uuid) + "/"
 
     @property
     def connected(self):
@@ -178,9 +179,9 @@
         @return (unicode, None): affiliation, or None if it is not in cache
         """
         if service.resource:
-            raise ValueError(u"Service must not have a resource")
+            raise ValueError("Service must not have a resource")
         if not node:
-            raise ValueError(u"node must be set")
+            raise ValueError("node must be set")
         try:
             affiliation = self.affiliations.pop((service, node))
         except KeyError:
@@ -200,9 +201,9 @@
         @param affiliation(unicode): affiliation to this node
         """
         if service.resource:
-            raise ValueError(u"Service must not have a resource")
+            raise ValueError("Service must not have a resource")
         if not node:
-            raise ValueError(u"node must be set")
+            raise ValueError("node must be set")
         self.affiliations[(service, node)] = affiliation
         while len(self.affiliations) > MAX_CACHE_AFFILIATIONS:
             self.affiliations.popitem(last=False)
@@ -213,8 +214,8 @@
     data = Attribute("data associated with the guest")
 
 
+@implementer(ISATGuestSession)
 class SATGuestSession(object):
-    implements(ISATGuestSession)
 
     def __init__(self, session):
         self.id = None