# HG changeset patch # User Thomas De Schampheleire # Date 1560709004 -7200 # Node ID 624971c4d246e08ea830c97325232e71265e0826 # Parent b5fe8bc0b939b6f5b97595ba09858ab718889ef9 setup: bump formencode minimum version to 1.3.0 The formencode version range included both 1.2.x and 1.3.x releases. However, since 1.3.0, _to_python and validate_python are deprecated and renamed to _convert_to_python and _validate_python, respectively. With current pytest, these (long) deprecation warnings are shown in the test logs. There are two options: - restrict maximum version to 1.2.x - bump minimum version to 1.3.x In this commit we choose the latter approach, going towards the future rather than the past. diff -r b5fe8bc0b939 -r 624971c4d246 kallithea/model/validators.py --- a/kallithea/model/validators.py Fri Jun 07 03:37:14 2019 +0200 +++ b/kallithea/model/validators.py Sun Jun 16 20:16:44 2019 +0200 @@ -55,7 +55,7 @@ missing_value=_('Value cannot be an empty list'), ) - def _to_python(self, value, state): + def _convert_to_python(self, value, state): value = aslist(value, ',') seen = set() return [c for c in value if not (c in seen or seen.add(c))] @@ -80,7 +80,7 @@ 'alphanumeric character or underscore') } - def validate_python(self, value, state): + def _validate_python(self, value, state): if value in ['default', 'new_user']: msg = self.message('system_invalid_username', state, username=value) raise formencode.Invalid(msg, value, state) @@ -112,7 +112,7 @@ 'invalid_username': _('Username %(username)s is not valid') } - def validate_python(self, value, state): + def _validate_python(self, value, state): try: User.query().filter(User.active == True) \ .filter(User.username == value).one() @@ -138,7 +138,7 @@ 'with alphanumeric character') } - def validate_python(self, value, state): + def _validate_python(self, value, state): if value in ['default']: msg = self.message('invalid_group', state) raise formencode.Invalid(msg, value, state, @@ -179,7 +179,7 @@ _('Repository with name "%(group_name)s" already exists') } - def validate_python(self, value, state): + def _validate_python(self, value, state): # TODO WRITE VALIDATIONS group_name = value.get('group_name') parent_group_id = value.get('parent_group_id') @@ -235,7 +235,7 @@ _('Invalid characters (non-ascii) in password') } - def validate_python(self, value, state): + def _validate_python(self, value, state): try: (value or '').decode('ascii') except UnicodeError: @@ -250,7 +250,7 @@ 'invalid_password': _('Invalid old password') } - def validate_python(self, value, state): + def _validate_python(self, value, state): from kallithea.lib import auth_modules if auth_modules.authenticate(username, value, '') is None: msg = self.message('invalid_password', state) @@ -266,7 +266,7 @@ 'password_mismatch': _('Passwords do not match'), } - def validate_python(self, value, state): + def _validate_python(self, value, state): if value.get(password_field) != value[password_confirmation_field]: msg = self.message('password_mismatch', state) raise formencode.Invalid(msg, value, state, @@ -281,7 +281,7 @@ 'invalid_auth': _(u'Invalid username or password'), } - def validate_python(self, value, state): + def _validate_python(self, value, state): from kallithea.lib import auth_modules password = value['password'] @@ -312,7 +312,7 @@ 'invalid_token': _('Token mismatch') } - def validate_python(self, value, state): + def _validate_python(self, value, state): if value != authentication_token(): msg = self.message('invalid_token', state) raise formencode.Invalid(msg, value, state) @@ -334,7 +334,7 @@ 'already exists') } - def _to_python(self, value, state): + def _convert_to_python(self, value, state): repo_name = repo_name_slug(value.get('repo_name', '')) repo_group = value.get('repo_group') if repo_group: @@ -355,7 +355,7 @@ value['group_name'] = group_name return value - def validate_python(self, value, state): + def _validate_python(self, value, state): repo_name = value.get('repo_name') repo_name_full = value.get('repo_name_full') group_path = value.get('group_path') @@ -402,10 +402,10 @@ def SlugifyName(): class _validator(formencode.validators.FancyValidator): - def _to_python(self, value, state): + def _convert_to_python(self, value, state): return repo_name_slug(value) - def validate_python(self, value, state): + def _validate_python(self, value, state): pass return _validator @@ -421,7 +421,7 @@ 'valid http, https, ssh, svn+http or svn+https URL'), } - def validate_python(self, value, state): + def _validate_python(self, value, state): repo_type = value.get('repo_type') url = value.get('clone_uri') @@ -445,7 +445,7 @@ 'invalid_fork_type': _('Fork has to be the same type as parent') } - def validate_python(self, value, state): + def _validate_python(self, value, state): if old_data['repo_type'] != value: msg = self.message('invalid_fork_type', state) raise formencode.Invalid(msg, value, state, @@ -463,13 +463,13 @@ "in root location") } - def _to_python(self, value, state): + def _convert_to_python(self, value, state): # root location if value == -1: return None return value - def validate_python(self, value, state): + def _validate_python(self, value, state): gr = RepoGroup.get(value) gr_name = gr.group_name if gr is not None else None # None means ROOT location @@ -519,7 +519,7 @@ return None return value - def validate_python(self, value, state): + def _validate_python(self, value, state): gr = RepoGroup.get(value) gr_name = gr.group_name if gr is not None else None # None means ROOT location @@ -619,7 +619,7 @@ def ValidSettings(): class _validator(formencode.validators.FancyValidator): - def _to_python(self, value, state): + def _convert_to_python(self, value, state): # settings form for users that are not admin # can't edit certain parameters, it's extra backup if they mangle # with forms @@ -634,7 +634,7 @@ del value[param] return value - def validate_python(self, value, state): + def _validate_python(self, value, state): pass return _validator @@ -645,7 +645,7 @@ 'invalid_path': _('This is not a valid path') } - def validate_python(self, value, state): + def _validate_python(self, value, state): if not os.path.isdir(value): msg = self.message('invalid_path', state) raise formencode.Invalid(msg, value, state, @@ -662,10 +662,10 @@ 'email_taken': _('This email address is already in use') } - def _to_python(self, value, state): + def _convert_to_python(self, value, state): return value.lower() - def validate_python(self, value, state): + def _validate_python(self, value, state): if (old_data.get('email') or '').lower() != value: user = User.get_by_email(value) if user is not None: @@ -682,10 +682,10 @@ 'non_existing_email': _('Email address "%(email)s" not found') } - def _to_python(self, value, state): + def _convert_to_python(self, value, state): return value.lower() - def validate_python(self, value, state): + def _validate_python(self, value, state): user = User.get_by_email(value) if user is None: msg = self.message('non_existing_email', state, email=value) @@ -702,7 +702,7 @@ } - def validate_python(self, value, state): + def _validate_python(self, value, state): try: import ldap ldap # pyflakes silence ! @@ -747,7 +747,7 @@ v += '/128' return v - def validate_python(self, value, state): + def _validate_python(self, value, state): try: addr = value.strip() # this raises an ValueError if address is not IPv4 or IPv6 @@ -766,7 +766,7 @@ 'underscore, dash or numbers') ) - def validate_python(self, value, state): + def _validate_python(self, value, state): if not re.match('[a-zA-Z0-9_-]+$', value): raise formencode.Invalid(self.message('badFormat', state), value, state) @@ -779,10 +779,10 @@ badPath=_('Filename cannot be inside a directory') ) - def _to_python(self, value, state): + def _convert_to_python(self, value, state): return value - def validate_python(self, value, state): + def _validate_python(self, value, state): if value != os.path.basename(value): raise formencode.Invalid(self.message('badPath', state), value, state) @@ -795,11 +795,11 @@ import_duplicate=_('Plugins %(loaded)s and %(next_to_load)s both export the same name') ) - def _to_python(self, value, state): + def _convert_to_python(self, value, state): # filter empty values return filter(lambda s: s not in [None, ''], value) - def validate_python(self, value, state): + def _validate_python(self, value, state): from kallithea.lib import auth_modules module_list = value unique_names = {} diff -r b5fe8bc0b939 -r 624971c4d246 setup.py --- a/setup.py Fri Jun 07 03:37:14 2019 +0200 +++ b/setup.py Sun Jun 16 20:16:44 2019 +0200 @@ -44,7 +44,7 @@ "tgext.routes >= 0.2.0, < 1", "Beaker >= 1.7.0, < 2", "WebHelpers >= 1.3, < 1.4", - "FormEncode >= 1.2.4, < 1.4", + "FormEncode >= 1.3.0, < 1.4", "SQLAlchemy >= 1.1, < 1.4", "Mako >= 0.9.0, < 1.1", "Pygments >= 2.0, < 2.5",