You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2020/10/08 17:07:01 UTC
[allura] branch master updated (bd5d617 -> 339fe0a)
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git.
from bd5d617 [#8380] pyflakes fix
new 92ab949 [#8376] upgrade formencode to py3 compatible version
new 2d97dae [#8376] revert previous formencode py3 workarounds, no longer needed
new 339fe0a [#8376] remove some unnecessary validations
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
Allura/allura/lib/validators.py | 17 ++-------
Allura/allura/lib/widgets/discuss.py | 7 +---
Allura/allura/lib/widgets/forms.py | 48 +++++-------------------
Allura/allura/tests/functional/test_auth.py | 12 ++----
ForgeImporters/forgeimporters/base.py | 12 ------
ForgeTracker/forgetracker/widgets/ticket_form.py | 2 +-
requirements.in | 3 +-
requirements.txt | 4 +-
8 files changed, 21 insertions(+), 84 deletions(-)
[allura] 02/03: [#8376] revert previous formencode py3 workarounds,
no longer needed
Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 2d97dae93d801875ef707a59ddadfc139278ca63
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Mon Oct 5 17:05:53 2020 -0400
[#8376] revert previous formencode py3 workarounds, no longer needed
---
Allura/allura/lib/validators.py | 17 +++--------------
Allura/allura/lib/widgets/discuss.py | 7 +------
Allura/allura/lib/widgets/forms.py | 14 --------------
ForgeImporters/forgeimporters/base.py | 12 ------------
ForgeTracker/forgetracker/widgets/ticket_form.py | 2 +-
5 files changed, 5 insertions(+), 47 deletions(-)
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 28c224b..a984958 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -72,6 +72,7 @@ class UnicodeString(fev.UnicodeString):
"""
Override UnicodeString to fix bytes handling.
Specifically ran into problems with its 'tooLong' check is running on bytes incorrectly and getting wrong length
+ And sometimes would return b'foo' when we wanted 'foo'
Fixed elsewhere like this too:
https://github.com/formencode/formencode/issues/2#issuecomment-378410047
@@ -81,13 +82,7 @@ class UnicodeString(fev.UnicodeString):
# make UnicodeString fix above work through this String alias, just like formencode aliases String
-String = UnicodeString if str is str else fev.ByteString
-
-
-class FieldStorageUploadConverter(fev.FieldStorageUploadConverter):
- # https://github.com/formencode/formencode/issues/101 local fix
- def is_empty(self, value):
- return value == b'' or super(FieldStorageUploadConverter, self).is_empty(value)
+String = UnicodeString if str is six.text_type else fev.ByteString
class Ming(fev.FancyValidator):
@@ -296,7 +291,7 @@ class JsonConverter(fev.FancyValidator):
return obj
-class JsonFile(FieldStorageUploadConverter):
+class JsonFile(fev.FieldStorageUploadConverter):
"""Validates that a file is JSON and returns the deserialized Python object
@@ -464,12 +459,6 @@ def convertTime(timestring):
class IconValidator(fev.FancyValidator):
regex = '(jpg|jpeg|gif|png|bmp)$'
-
- # https://github.com/formencode/formencode/issues/101 local fix
- # formencode is_empty doesn't handle empty bytestring by default
- def is_empty(self, val):
- return val == b'' or super(IconValidator, self).is_empty(val)
-
def _to_python(self, value, state):
p = re.compile(self.regex, flags=re.I)
result = p.search(value.filename)
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 5abdf4b..9338fbb 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -40,11 +40,6 @@ class NullValidator(fev.FancyValidator):
def _from_python(self, value, state):
return value
- # https://github.com/formencode/formencode/issues/101 local fix
- def is_empty(self, value):
- return value == b'' or super(NullValidator, self).is_empty(value)
-
-
# Discussion forms
@@ -211,7 +206,7 @@ class NewTopicPost(EditPost):
fields = super(NewTopicPost, self).fields
fields.append(ew.InputField(name='attachment', label='Attachment', field_type='file',
attrs={'multiple': 'True'},
- validator=v.FieldStorageUploadConverter(if_missing=None)))
+ validator=fev.FieldStorageUploadConverter(if_missing=None)))
return fields
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index d79b3ae..54082ce 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -125,20 +125,6 @@ class ForgeForm(ew.SimpleForm):
ctx['errors'])
return Markup(display)
- # https://github.com/formencode/formencode/issues/101 local fix
- def _make_schema(self):
- schema = super(ForgeForm, self)._make_schema()
-
- orig_val_is_iter = schema._value_is_iterator
-
- def _value_is_iterator(val):
- if isinstance(val, bytes):
- return False
- return orig_val_is_iter(val)
- schema._value_is_iterator = _value_is_iterator
-
- return schema
-
class ForgeFormResponsive(ForgeForm):
def __init__(self):
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index a37b8e3..ea87738 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -73,12 +73,6 @@ class ProjectImportForm(schema.Schema):
neighborhood = fev.NotEmpty()
project_name = v.UnicodeString(not_empty=True, max=40)
- # https://github.com/formencode/formencode/issues/101 local fix
- def _value_is_iterator(self, value):
- if isinstance(value, bytes):
- return False
- return super(ProjectImportForm, self)._value_is_iterator(value)
-
class ToolImportForm(schema.Schema):
@@ -87,12 +81,6 @@ class ToolImportForm(schema.Schema):
self.add_field('mount_point', v.MountPointValidator(tool_class))
mount_label = v.UnicodeString()
- # https://github.com/formencode/formencode/issues/101 local fix
- def _value_is_iterator(self, value):
- if isinstance(value, bytes):
- return False
- return super(ToolImportForm, self)._value_is_iterator(value)
-
class ImportErrorHandler(object):
diff --git a/ForgeTracker/forgetracker/widgets/ticket_form.py b/ForgeTracker/forgetracker/widgets/ticket_form.py
index 73eb753..fa1ddd4 100644
--- a/ForgeTracker/forgetracker/widgets/ticket_form.py
+++ b/ForgeTracker/forgetracker/widgets/ticket_form.py
@@ -124,7 +124,7 @@ class GenericTicketForm(ew.SimpleForm):
validator=fev.StringBool(),
attrs={'class': 'unlabeled'}),
ew.InputField(name='attachment', label='Attachment', field_type='file', attrs={
- 'multiple': 'True'}, validator=v.FieldStorageUploadConverter(if_missing=None)),
+ 'multiple': 'True'}, validator=fev.FieldStorageUploadConverter(if_missing=None)),
ffw.MarkdownEdit(name='comment', label='Comment',
attrs={'style': 'min-height:7em; width:97%'}),
ew.SubmitButton(label=self.submit_text, name='submit',
[allura] 03/03: [#8376] remove some unnecessary validations
Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 339fe0aab2c850df63b74847e2109fa558142df1
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Wed Oct 7 11:25:15 2020 -0400
[#8376] remove some unnecessary validations
---
Allura/allura/lib/widgets/forms.py | 34 ++++++++---------------------
Allura/allura/tests/functional/test_auth.py | 12 ++++------
2 files changed, 13 insertions(+), 33 deletions(-)
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 54082ce..507ea41 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -255,9 +255,7 @@ class PersonalDataForm(ForgeForm):
label='Gender',
options=[ew.Option(py_value=v, label=v, selected=False)
for v in ['Male', 'Female', 'Unknown', 'Other']],
- validator=formencode.All(
- V.OneOfValidator(['Male', 'Female', 'Unknown', 'Other']),
- V.UnicodeString(not_empty=True))),
+ validator=V.OneOfValidator(['Male', 'Female', 'Unknown', 'Other'])),
ew.SingleSelectField(
name='country',
label='Country of residence',
@@ -450,7 +448,7 @@ class AddSocialNetworkForm(ForgeForm):
ew.SingleSelectField(
name='socialnetwork',
label='Social network',
- validator=V.UnicodeString(not_empty=True),
+ validator=V.OneOfValidator(socialnetworks),
options=[ew.Option(py_value=name, label=name)
for name in socialnetworks]),
ew.TextField(
@@ -499,14 +497,10 @@ class AddInactivePeriodForm(ForgeForm):
class fields(ew_core.NameList):
startdate = ew.TextField(
label='Start date',
- validator=formencode.All(
- V.DateValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.DateValidator())
enddate = ew.TextField(
label='End date',
- validator=formencode.All(
- V.DateValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.DateValidator())
@ew_core.core.validator
def to_python(self, kw, state):
@@ -558,19 +552,13 @@ class AddTimeSlotForm(ForgeForm):
label='Weekday',
options=[ew.Option(py_value=wd, label=wd)
for wd in weekdays],
- validator=formencode.All(
- V.OneOfValidator(weekdays),
- V.UnicodeString(not_empty=True)))
+ validator=V.OneOfValidator(weekdays))
starttime = ew.TextField(
label='Start time',
- validator=formencode.All(
- V.TimeValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.TimeValidator())
endtime = ew.TextField(
label='End time',
- validator=formencode.All(
- V.TimeValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.TimeValidator())
@ew_core.core.validator
def to_python(self, kw, state):
@@ -700,9 +688,7 @@ class AddUserSkillForm(ForgeForm):
ew.Option(py_value="low", label="Low level"),
ew.Option(py_value="medium", label="Medium level"),
ew.Option(py_value="high", label="Advanced level")],
- validator=formencode.All(
- V.OneOfValidator(['low', 'medium', 'high']),
- V.UnicodeString(not_empty=True)))
+ validator=V.OneOfValidator(['low', 'medium', 'high']))
comment = ew.TextArea(
label="Additional comments",
validator=V.UnicodeString(not_empty=False),
@@ -730,9 +716,7 @@ class SelectSubCategoryForm(ForgeForm):
self.fields['selected_category'].options = [
ew.Option(py_value=el.trove_cat_id, label=el.fullname) for el in categories
]
- self.fields['selected_category'].validator = formencode.All(
- V.OneOfValidator(categories),
- V.UnicodeString(not_empty=True))
+ self.fields['selected_category'].validator = V.OneOfValidator(categories)
return super(ForgeForm, self).display(**kw)
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index c7dd677..0fa9a09 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -1333,10 +1333,8 @@ class TestPreferences(TestController):
_session_id=self.app.cookies['_session_id'],
))
user = M.User.query.get(username='test-admin')
- timeslot1dict = dict(
- week_day=weekday, start_time=starttime, end_time=endtime)
- assert len(
- user.availability) == 1 and timeslot1dict in user.get_availability_timeslots()
+ timeslot1dict = dict(week_day=weekday, start_time=starttime, end_time=endtime)
+ assert len(user.availability) == 1 and timeslot1dict in user.get_availability_timeslots()
weekday2 = 'Tuesday'
starttime2 = time(14, 0, 0)
@@ -1351,8 +1349,7 @@ class TestPreferences(TestController):
_session_id=self.app.cookies['_session_id'],
))
user = M.User.query.get(username='test-admin')
- timeslot2dict = dict(week_day=weekday2,
- start_time=starttime2, end_time=endtime2)
+ timeslot2dict = dict(week_day=weekday2, start_time=starttime2, end_time=endtime2)
assert len(user.availability) == 2
assert_in(timeslot1dict, user.get_availability_timeslots())
assert_in(timeslot2dict, user.get_availability_timeslots())
@@ -1378,8 +1375,7 @@ class TestPreferences(TestController):
))
assert 'Invalid period:' in str(r)
user = M.User.query.get(username='test-admin')
- timeslot2dict = dict(week_day=weekday2,
- start_time=starttime2, end_time=endtime2)
+ timeslot2dict = dict(week_day=weekday2, start_time=starttime2, end_time=endtime2)
assert len(user.availability) == 1 and timeslot2dict in user.get_availability_timeslots()
@td.with_user_project('test-admin')
[allura] 01/03: [#8376] upgrade formencode to py3 compatible version
Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 92ab949f05b6e0aa3c9d4375f32ac15328c23b08
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Mon Oct 5 16:54:54 2020 -0400
[#8376] upgrade formencode to py3 compatible version
---
requirements.in | 3 +--
requirements.txt | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/requirements.in b/requirements.in
index a4da5a0..12fff91 100644
--- a/requirements.in
+++ b/requirements.in
@@ -13,8 +13,7 @@ enum34 ; python_version < "3.4"
faulthandler ; python_version < "3.3"
feedgenerator
feedparser
-# FormEncode is not currently maintained :( Could go to 2.0.0a currently https://github.com/formencode/formencode/issues/140
-FormEncode
+FormEncode>=2
GitPython==2.1.11
html5lib==1.0.1
Jinja2
diff --git a/requirements.txt b/requirements.txt
index ec7dc38..0660a1a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -28,7 +28,7 @@ enum34==1.1.6 ; python_version < "3.4" # via -r requirements.in, colander, cryp
faulthandler==3.1 ; python_version < "3.3" # via -r requirements.in
feedgenerator==1.9.1 # via -r requirements.in
feedparser==5.2.1 # via -r requirements.in
-formencode==1.3.1 # via -r requirements.in, easywidgets
+formencode==2.0.0 # via -r requirements.in, easywidgets
funcsigs==1.0.2 # via beaker, mock
future==0.17.1 # via timermiddleware
genshi==0.7.3 # via creoleparser
@@ -80,7 +80,7 @@ requests==2.22.0 # via -r requirements.in, pysolr, requests-oauthlib
scandir==1.10.0 # via pathlib2
setproctitle==1.1.9 # via -r requirements.in
simplegeneric==0.8.1 # via ipython
-six==1.15.0 # via -r requirements.in, bleach, creoleparser, cryptography, easywidgets, feedgenerator, html5lib, ming, mock, paste, pastescript, pathlib2, prompt-toolkit, python-dateutil, qrcode, textile, traitlets, webhelpers2, webtest
+six==1.15.0 # via -r requirements.in, bleach, creoleparser, cryptography, easywidgets, feedgenerator, formencode, html5lib, ming, mock, paste, pastescript, pathlib2, prompt-toolkit, python-dateutil, qrcode, textile, traitlets, webhelpers2, webtest
smmap2==2.0.4 # via gitdb2
soupsieve==1.9.3 # via beautifulsoup4
testfixtures==6.10.0 # via -r requirements.in