Git Product home page Git Product logo

Comments (6)

eehmke avatar eehmke commented on July 17, 2024

I could solve the problem by downgrading Products.Archetypes to 1.8.3. Plone 4.2.2 installed Archetypes 1.8.4 by default. Not sure if this pinning has other side effects, at least my form runs fine again.

from products.ploneformgen.

runyaga avatar runyaga commented on July 17, 2024

Products.Archetypes.Field.FileField._make_file blindly passes the PFGFileField into constructor.
This is kinda interesting in that.. Why cant you get to the data of the PFGFile easily? It seems you
need to know the name of the field id to access the value..

Patching _make_file with the below works.. This is certainly a problem with AT I think

def _pfg_make_file(self, id, title='', file='', instance=None):
    """File content factory. Awful practice passing in a builtin, file in signature"""
    if getattr(file, 'seek', None) is None:
        logger.info("%s does not have seek method using empty string as value" % file)
        file = ''
    return self.content_class(id, title, file)

from products.ploneformgen.

do3cc avatar do3cc commented on July 17, 2024

This part has never changed before. What has changed in 1.8.4 was that a mimetype icon gets added. This triggers the make file code which wasnt triggered before.
It seems wrong to me that Archetypes gets a Products.PloneFormGen.content.fields.FGFileField object which is a schema but nothing file like.
I opted to add these methods to FGFileField:

def seek(self, offset, whence=None):
    return

def read(self, size=None):
    return ''

def tell(self):
    return 0

Since the FGFileField is not in risk being used as a file for an uploaded file, I believe this to be pretty safe.

from products.ploneformgen.

eehmke avatar eehmke commented on July 17, 2024

I can confirm that the patch provided by runyaga works. I rebuild my testinstance with Archetypes 1.8.4 to reproduce the error. When I applied the patch to /buildout-cache/eggs/Products.Archetypes-1.8.4-py2.7.egg/Products/Archetypes/Field.py the error was gone.

Applying the other patch from do3cc solves the problem as well. I am not sure if custom validators on file fields might be affected if they make use of the methods involved. Is the assumption "Since the FGFileField is not in risk being used as a file..." correct?

from products.ploneformgen.

do3cc avatar do3cc commented on July 17, 2024

I can't really tell. In only feel pretty confident that my patch would not worse the situation. A PGFileField never behaved like a File like object, so if anybody expected that would have failed before the change too.
Because I can't really tell I am not going to try to fix it myself.

from products.ploneformgen.

huubbouma avatar huubbouma commented on July 17, 2024

I've done a quick test, and the validation still works fine with do3cc's patch (thanks!)
Since I needed this for a project, I've forked the repo and will do a pull request
https://github.com/huubbouma/Products.PloneFormGen

from products.ploneformgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.