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 = [
__depends__ = {'cubicweb': '>= 3.25.0',
'pycrypto': None,
'Pillow': None,
'six': None,
}
......
......@@ -8,13 +8,13 @@ from datetime import datetime, timedelta
from logilab.common.decorators import monkeypatch
from yams import ValidationError
from cubicweb import _
from cubicweb.predicates import is_instance
from cubicweb.crypto import encrypt
from cubicweb.server import hook
from cubicweb.server.repository import Repository
from cubicweb.sobjects.notification import NotificationView
_ = unicode
class ServerStartupHook(hook.Hook):
"""on startup, register a task to delete old revocation key"""
......
......@@ -2,12 +2,10 @@ import random
import string
from datetime import datetime, timedelta
from cubicweb import ValidationError
from cubicweb import _, ValidationError
from cubicweb.predicates import match_kwargs
from cubicweb.server import Service
_ = unicode
class ForgotPwdEmailService(Service):
"""Generate a password reset request, store it in the database, and send
......@@ -20,8 +18,8 @@ class ForgotPwdEmailService(Service):
cnx = self._cw
repo = cnx.repo
revocation_limit = repo.config['revocation-limit']
revocation_id = u''.join(random.choice(string.letters+string.digits)
for x in xrange(10))
revocation_id = u''.join(random.choice(string.ascii_letters+string.digits)
for x in range(10))
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',
......
......@@ -6,17 +6,19 @@
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
from six import text_type
from yams import ValidationError
from logilab.mtconverter import xml_escape
from cubicweb import _
from cubicweb.view import StartupView
from cubicweb.crypto import decrypt
from cubicweb.web import (Redirect, controller, form, captcha,
formwidgets as wdg, formfields as ff)
from cubicweb.web.views import forms, urlrewrite, basetemplates
_ = unicode
# Login form
# ----------
......@@ -70,8 +72,8 @@ class ForgottenPasswordSendMailController(controller.Controller):
cnx.commit()
except ValidationError:
raise
except Exception, exc:
msg = unicode(exc)
except Exception as exc:
msg = text_type(exc)
else:
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))
......
......@@ -16,6 +16,7 @@ Depends:
python-cubicweb (>= 3.25),
python-crypto,
python-imaging,
python-six,
${python:Depends},
${misc:Depends},
Description: password recovery component for the CubicWeb framework
......
......@@ -10,7 +10,7 @@ class ForgotTC(CubicWebTC):
def setup_database(self):
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)
cnx.create_entity('EmailAddress',
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