Enable export of ATFile objects

Bug #722726 reported by sureshvv
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope CMF buildout
Fix Released
Medium
Tres Seaver

Bug Description

If we make add the IDAVAware interface for ATFile objects, we could export the content using portal_setup with the following fix.

Revision history for this message
sureshvv (sureshvv) wrote :
Revision history for this message
sureshvv (sureshvv) wrote :

The change is in file called context.py. Forgot to mention this.

Revision history for this message
Tres Seaver (tseaver) wrote :

Thanks for the report, and the patch. A couple of observations:

- The patch will be easier to review / apply if made from a VCS checkout of
  the sources in 'unidiff' format. See the following resources for help:

  http://docs.zope.org/developer/noncommitter-svn.html

  http://docs.zope.org/developer/noncommitter-bzr.html

- We need unit tests for any new feature added or bug fixed.

- In the tarfile case, we don't need to copy the file object into memory,
  because we can just hand the file handle to 'addfile'. To get the length,
  we should be using 'seek' and 'tell'.

- Likely the other export context types (directory, snapshot) should be
  reviewed to ensure they work equally well with the file object.

Changed in zope-cmf:
status: New → Incomplete
Revision history for this message
sureshvv (sureshvv) wrote :

In the specific case of Plone and ATFile, a PdataStreamIterator object is passed in rather than a file. Do I mock this in the test? Is it ok to import the definition from Products.Archetypes.WebDAVSupport?

Revision history for this message
sureshvv (sureshvv) wrote :

Some tests are already broken. May be yuppie's most recent commit.

Revision history for this message
Tres Seaver (tseaver) wrote :

> In the specific case of Plone and ATFile, a PdataStreamIterator object
> is passed in rather than a file.

Ah, I thought ATFile was already using blobs.

> Do I mock this in the test? Is it ok to
> import the definition from Products.Archetypes.WebDAVSupport?

We should mock it: GenericSetup can't depend on Archetypes. Something
simple should do the trick: we just need an iterable which yields chunks
of text, so we could use a list::

  ['chunk1', 'chunk2']

We could maybe sniff for attributes 'file', 'size', and 'streamsize',
and special case them (since the 'file' attribute of PdataStreamIterator
is already a tempfile). The mock would be really simple::

  class DummyIterator(object):
      streamsize = 13
      def __init__(self, text):
          self.file = StringIO(text)
          self.size = len(text)

> Some tests are already broken. May be yuppie's most recent commit.

Hmm, they are passing for me::

--------------------------- %< --------------------------
$ cd /tmp
$ svn co svn+ssh://svn.zope.org/repos/main/Products.GenericSetup/trunk gs
$ cd gs
$ /opt/Python-2.6.5/bin/python bootstrap.py && bin/buildout
...
$ bin/test --all
...
Total: 396 tests, 0 failures, 0 errors in 1.986 seconds.
--------------------------- %< --------------------------

What branch are you starting from?

Revision history for this message
sureshvv (sureshvv) wrote :

Thanks for the hand holding, you slave driver (and I mean that in the best sense of the word :-) ) !

Revision history for this message
sureshvv (sureshvv) wrote :

>> Some tests are already broken. May be yuppie's most recent commit.

> What branch are you starting from?

I was running just the Products.GenericSetup tests from a Plone 4 buildout. This buildout works fine.

Revision history for this message
Tres Seaver (tseaver) wrote :

Thanks for extending your patch with a test!

I have merged your patch to the trunk for the 1.6.3 release:

 http://svn.zope.org/Products.GenericSetup/trunk/?rev=120550&view=rev

Changed in zope-cmf:
assignee: nobody → Tres Seaver (tseaver)
importance: Undecided → Medium
status: Incomplete → Fix Committed
Tres Seaver (tseaver)
Changed in zope-cmf:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.