You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/10/05 21:20:10 UTC
[allura] 02/02: [#8376] revert previous formencode py3 workarounds,
no longer needed
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8376
in repository https://gitbox.apache.org/repos/asf/allura.git
commit cc9dd5d1c724529869b5e8f49dfac1c201f24c2f
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 | 31 +++---------------------
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, 6 insertions(+), 60 deletions(-)
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 28c224b..18361ca 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -68,26 +68,9 @@ class NonHttpUrl(URL):
''', re.I | re.VERBOSE)
-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
-
- Fixed elsewhere like this too:
- https://github.com/formencode/formencode/issues/2#issuecomment-378410047
- https://github.com/sightmachine/formencode/commit/665c9d0141dacb2dc84fb7d20ad3f8c0a5fe5e2d
- """
- encoding = None
-
-
-# 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)
+# leftover aliases when we had local overrides of these for a little while (and code still references these)
+UnicodeString = fev.UnicodeString
+String = fev.String
class Ming(fev.FancyValidator):
@@ -296,7 +279,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 +447,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',