diff libervia/pages/register/page_meta.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 29eb15062416
children f511f8fbbf8a
line wrap: on
line diff
--- a/libervia/pages/register/page_meta.py	Tue Aug 13 09:39:33 2019 +0200
+++ b/libervia/pages/register/page_meta.py	Tue Aug 13 19:12:31 2019 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 from libervia.server.constants import Const as C
@@ -10,9 +10,9 @@
 
 """SàT account registration page"""
 
-name = u"register"
+name = "register"
 access = C.PAGES_ACCESS_PUBLIC
-template = u"login/register.html"
+template = "login/register.html"
 
 
 def prepare_render(self, request):
@@ -30,30 +30,30 @@
         template_data["login_error"] = login_error
 
     #  if fields were already filled, we reuse them
-    for k in (u"login", u"email", u"password"):
+    for k in ("login", "email", "password"):
         template_data[k] = session_data.popPageData(self, k)
 
 
 @defer.inlineCallbacks
 def on_data_post(self, request):
-    type_ = self.getPostedData(request, u"type")
-    if type_ == u"register":
+    type_ = self.getPostedData(request, "type")
+    if type_ == "register":
         login, email, password = self.getPostedData(
-            request, (u"login", u"email", u"password")
+            request, ("login", "email", "password")
         )
         status = yield self.host.registerNewAccount(request, login, password, email)
         session_data = self.host.getSessionData(request, session_iface.ISATSession)
         if status == C.REGISTRATION_SUCCEED:
             # we prefill login field for login page
-            session_data.setPageData(self.getPageByName(u"login"), u"login", login)
+            session_data.setPageData(self.getPageByName("login"), "login", login)
             # if we have a redirect_url we follow it
             self.redirectOrContinue(request)
             # else we redirect to login page
-            self.HTTPRedirect(request, self.getPageByName(u"login").url)
+            self.HTTPRedirect(request, self.getPageByName("login").url)
         else:
-            session_data.setPageData(self, u"login_error", status)
+            session_data.setPageData(self, "login_error", status)
             l = locals()
-            for k in (u"login", u"email", u"password"):
+            for k in ("login", "email", "password"):
                 # we save fields so user doesn't have to enter them again
                 session_data.setPageData(self, k, l[k])
             defer.returnValue(C.POST_NO_CONFIRM)