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:08 UTC

[allura] branch db/8376 created (now cc9dd5d)

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a change to branch db/8376
in repository https://gitbox.apache.org/repos/asf/allura.git.


      at cc9dd5d  [#8376] revert previous formencode py3 workarounds, no longer needed

This branch includes the following new commits:

     new 50ca475  [#8376] upgrade formencode to py3 compatible version
     new cc9dd5d  [#8376] revert previous formencode py3 workarounds, no longer needed

The 2 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.



[allura] 02/02: [#8376] revert previous formencode py3 workarounds, no longer needed

Posted by br...@apache.org.
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',


[allura] 01/02: [#8376] upgrade formencode to py3 compatible version

Posted by br...@apache.org.
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 50ca4757e50040c784c3704acd5a74dee4fb0e82
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