Skip to content

Add dependency on plone.formwidget.namedfile 1.0.15+#173

Open
tobiasherp wants to merge 2 commits intocollective:masterfrom
visaplan:dependencies
Open

Add dependency on plone.formwidget.namedfile 1.0.15+#173
tobiasherp wants to merge 2 commits intocollective:masterfrom
visaplan:dependencies

Conversation

@tobiasherp
Copy link
Copy Markdown

... because of the b64decode_file function.

tobiasherp and others added 2 commits July 26, 2019 15:16
(... which have been created by virtualenv .)
plone.formwidget.namedfile 1.0.9 (KGS of Plone 4.3.3) lacks the
b64decode_file function; v1.0.15 (KGS 4.3.9 to 4.3.18) has it.

Looking at the history, it seems it has been added in version 1.0.12,
but buildout couldn't find a distribution for this.
Copy link
Copy Markdown
Member

@hvelarde hvelarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this?

@idgserpro
Copy link
Copy Markdown
Member

@hvelarde we really need this. See:

from plone.formwidget.namedfile.converter import b64decode_file

Copy link
Copy Markdown
Member

@idgserpro idgserpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops; build is failing

@rafaelbco
Copy link
Copy Markdown

I think adding the dependency just because of this function is not optimal. The function is pretty simple, and depends only on the base64 module from the stdlib:

def b64decode_file(value):
    if isinstance(value, six.text_type):
        value = value.encode('utf8')
    filename, data = value.split(b';')

    filename = filename.split(b':')[1]
    filename = base64.standard_b64decode(filename)
    filename = filename.decode('utf-8')

    data = data.split(b':')[1]
    data = base64.standard_b64decode(data)

    return filename, data

I'd rather duplicate the function.

Just my 2 cents.

@idgserpro
Copy link
Copy Markdown
Member

@rafaelbco it's not just because of the function. The widget is also used:

from plone.formwidget.namedfile.widget import NamedImageFieldWidget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants