Commit 4cb6a345 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

Make code base compatible with python3

parent fdd4ff0f95cc
...@@ -23,6 +23,7 @@ classifiers = [ ...@@ -23,6 +23,7 @@ classifiers = [
__depends__ = {'cubicweb': '>= 3.25.0', __depends__ = {'cubicweb': '>= 3.25.0',
'pycrypto': None, 'pycrypto': None,
'Pillow': None, 'Pillow': None,
'six': None,
} }
......
...@@ -8,13 +8,13 @@ from datetime import datetime, timedelta ...@@ -8,13 +8,13 @@ from datetime import datetime, timedelta
from logilab.common.decorators import monkeypatch from logilab.common.decorators import monkeypatch
from yams import ValidationError from yams import ValidationError
from cubicweb import _
from cubicweb.predicates import is_instance from cubicweb.predicates import is_instance
from cubicweb.crypto import encrypt from cubicweb.crypto import encrypt
from cubicweb.server import hook from cubicweb.server import hook
from cubicweb.server.repository import Repository from cubicweb.server.repository import Repository
from cubicweb.sobjects.notification import NotificationView from cubicweb.sobjects.notification import NotificationView
_ = unicode
class ServerStartupHook(hook.Hook): class ServerStartupHook(hook.Hook):
"""on startup, register a task to delete old revocation key""" """on startup, register a task to delete old revocation key"""
......
...@@ -2,12 +2,10 @@ import random ...@@ -2,12 +2,10 @@ import random
import string import string
from datetime import datetime, timedelta from datetime import datetime, timedelta
from cubicweb import ValidationError from cubicweb import _, ValidationError
from cubicweb.predicates import match_kwargs from cubicweb.predicates import match_kwargs
from cubicweb.server import Service from cubicweb.server import Service
_ = unicode
class ForgotPwdEmailService(Service): class ForgotPwdEmailService(Service):
"""Generate a password reset request, store it in the database, and send """Generate a password reset request, store it in the database, and send
...@@ -20,8 +18,8 @@ class ForgotPwdEmailService(Service): ...@@ -20,8 +18,8 @@ class ForgotPwdEmailService(Service):
cnx = self._cw cnx = self._cw
repo = cnx.repo repo = cnx.repo
revocation_limit = repo.config['revocation-limit'] revocation_limit = repo.config['revocation-limit']
revocation_id = u''.join(random.choice(string.letters+string.digits) revocation_id = u''.join(random.choice(string.ascii_letters+string.digits)
for x in xrange(10)) for x in range(10))
revocation_date = datetime.now() + timedelta(minutes=revocation_limit) revocation_date = datetime.now() + timedelta(minutes=revocation_limit)
existing_requests = cnx.execute('Any F WHERE U primary_email E, E address %(e)s, U has_fpasswd F', existing_requests = cnx.execute('Any F WHERE U primary_email E, E address %(e)s, U has_fpasswd F',
......
...@@ -6,17 +6,19 @@ ...@@ -6,17 +6,19 @@
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
""" """
from six import text_type
from yams import ValidationError from yams import ValidationError
from logilab.mtconverter import xml_escape from logilab.mtconverter import xml_escape
from cubicweb import _
from cubicweb.view import StartupView from cubicweb.view import StartupView
from cubicweb.crypto import decrypt from cubicweb.crypto import decrypt
from cubicweb.web import (Redirect, controller, form, captcha, from cubicweb.web import (Redirect, controller, form, captcha,
formwidgets as wdg, formfields as ff) formwidgets as wdg, formfields as ff)
from cubicweb.web.views import forms, urlrewrite, basetemplates from cubicweb.web.views import forms, urlrewrite, basetemplates
_ = unicode
# Login form # Login form
# ---------- # ----------
...@@ -70,8 +72,8 @@ class ForgottenPasswordSendMailController(controller.Controller): ...@@ -70,8 +72,8 @@ class ForgottenPasswordSendMailController(controller.Controller):
cnx.commit() cnx.commit()
except ValidationError: except ValidationError:
raise raise
except Exception, exc: except Exception as exc:
msg = unicode(exc) msg = text_type(exc)
else: else:
msg = self._cw._(u'An email has been sent, follow instructions in there to change your password.') msg = self._cw._(u'An email has been sent, follow instructions in there to change your password.')
raise Redirect(self._cw.build_url('pwdsent', __message=msg)) raise Redirect(self._cw.build_url('pwdsent', __message=msg))
......
...@@ -16,6 +16,7 @@ Depends: ...@@ -16,6 +16,7 @@ Depends:
python-cubicweb (>= 3.25), python-cubicweb (>= 3.25),
python-crypto, python-crypto,
python-imaging, python-imaging,
python-six,
${python:Depends}, ${python:Depends},
${misc:Depends}, ${misc:Depends},
Description: password recovery component for the CubicWeb framework Description: password recovery component for the CubicWeb framework
......
...@@ -10,7 +10,7 @@ class ForgotTC(CubicWebTC): ...@@ -10,7 +10,7 @@ class ForgotTC(CubicWebTC):
def setup_database(self): def setup_database(self):
with self.admin_access.repo_cnx() as cnx: with self.admin_access.repo_cnx() as cnx:
for index in xrange(4): for index in range(4):
user = self.create_user(cnx, u'test_user%s' % index) user = self.create_user(cnx, u'test_user%s' % index)
cnx.create_entity('EmailAddress', cnx.create_entity('EmailAddress',
address=u'test_user%s@logilab.fr' % index, address=u'test_user%s@logilab.fr' % index,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment