Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when doing GenericSetup export #396

Closed
fulv opened this issue Feb 21, 2014 · 8 comments · Fixed by #706
Closed

error when doing GenericSetup export #396

fulv opened this issue Feb 21, 2014 · 8 comments · Fixed by #706
Assignees
Labels
Milestone

Comments

@fulv
Copy link
Member

fulv commented Feb 21, 2014

This is collective.cover 1.0a7 on Plone 4.3.2.

Steps:

  • create new Plone site, add collective.cover
  • create new cover (no need to do anything else, i.e. layout, compose, or anything)
  • in the ZMI, go to portal_setup, Export tab
  • click "Export all steps" button

Result:

2014-02-21 14:17:56 ERROR Zope.SiteErrorLog 1393021076.560.214411682715 http://localhost:8080/Plone/portal_setup/manage_exportAllSteps
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.GenericSetup.tool, line 593, in manage_exportAllSteps
  Module Products.GenericSetup.tool, line 370, in runAllExportSteps
  Module Products.GenericSetup.tool, line 1038, in _doRunExportSteps
  Module Products.CMFCore.exportimport.content, line 31, in exportSiteStructure
  Module Products.CMFCore.exportimport.content, line 132, in export
  Module Products.GenericSetup.content, line 389, in export
  Module Products.GenericSetup.context, line 476, in writeDataFile
AttributeError: 'DefaultReadFile' object has no attribute 'file'

The text object in writeDataFile is:

text = <plone.dexterity.filerepresentation.DefaultReadFile object at 0x1079dcdd0>
@fulv fulv added the bug label Feb 21, 2014
@hvelarde
Copy link
Member

I don't see how this can be related with collective.cover; could you please give more information?

@fulv
Copy link
Member Author

fulv commented Mar 24, 2014

It's really simple, if you follow the steps I outlined, you will reproduce the behavior. You can't do an Export in portal_setup, it only fails when I add a cover content item to the site. When you remove the cover object from the site, Export works again. I also tried adding another dexterity content item, or an AT item, and it did not fail. Export fails only with a Cover object in the site.

@hvelarde
Copy link
Member

yes, but this seems to be an issue in Generic Setup of Dexterity; as you can see there is no cover code mentioned above. could you please dig a little bit deeper?

@hvelarde hvelarde added this to the 1.0a9 milestone May 2, 2014
@hvelarde hvelarde modified the milestones: 1.0a9, 1.0b1 Aug 19, 2014
@idgserpro
Copy link
Member

Just FYI, we tested this in newer versions and the error still exists.

Did the same as @fulv with '1.4b2.dev0' (commit 0b43480): create a Plone Site, create a simple cover with empty layout, go to portal_setup and do "Export All Steps", it gives you the same error.

Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Products.GenericSetup.tool, line 634, in manage_exportAllSteps
Module Products.GenericSetup.tool, line 399, in runAllExportSteps
Module Products.GenericSetup.tool, line 1249, in _doRunExportSteps
Module Products.CMFCore.exportimport.content, line 36, in exportSiteStructure
Module Products.CMFCore.exportimport.content, line 177, in export
Module Products.GenericSetup.content, line 396, in export
Module Products.GenericSetup.context, line 456, in writeDataFile
AttributeError: 'DefaultReadFile' object has no attribute 'file'

In a vanilla Plone 4.3.12, we don't have this problem. We have no idea why this happens.

@idgserpro
Copy link
Member

Well, the problem isn't with "Export all steps", is with the option

Content
Export the site's structure and content.

Adding plone.dexterity.interfaces.IDexterityContainer (you can test doing http://localhost:8080/Plone/my_cover/manage_interfaces and checking it in Available Marker Interfaces) to the cover object and trying to export again in portal_setup the error is gone. Since I don't know what is the correct approach to this error I'm leaving this idea here as a workaround if someone searches for this traceback, after exporting you should remove the marker interface. @fulv could you check it the workaround works in your situation?

@hvelarde
Copy link
Member

hvelarde commented Apr 17, 2017

that's weird, because the content type is not a container; but I think it was probably a container in the past so it may have something left behind.

maybe this?

@implementer(IDAVAware)

@barseghyanartur
Copy link

I think this issue is still valid.

And it's defnitely a problem of this package.

Products.GenericSetup/Products/GenericSetup/context.py near line 443:

security.declareProtected( ManagePortal, 'writeDataFile' )
    def writeDataFile( self, filename, text, content_type, subdir=None ):

        """ See IExportContext.
        """
        if subdir is not None:
            filename = '/'.join( ( subdir, filename ) )

        parents = filename.split('/')[:-1]
        while parents:
            path = '/'.join(parents) + '/'
            if path not in self._archive.getnames():
                info = TarInfo(path)
                info.type = DIRTYPE
                # tarfile.filemode(0755) == '-rwxr-xr-x'
                info.mode = 0755
                info.mtime = time.time()
                self._archive.addfile(info)
            parents.pop()

        info = TarInfo(filename)
        if isinstance(text, str):
            stream = StringIO(text)
            info.size = len(text)
        elif isinstance(text, unicode):
            raise ValueError("Unicode text is not supported, even if it only "
                             "contains ascii. Please encode your data. See "
                             "GS 1.7.0 changes for more")
        else:
            # Assume text is a an instance of a class like
            # Products.Archetypes.WebDAVSupport.PdataStreamIterator, 
            # as in the case of ATFile
            stream = text.file
            info.size = text.size
        info.mtime = time.time()
        self._archive.addfile( info, stream )

It's not a text, it's not a unicode, it's something else and that something else should be treated the same way as the Products.Archetypes.WebDAVSupport.PdataStreamIterator.

@hvelarde
Copy link
Member

feel free to open a new issue and provide more details on how to reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants