[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/http/ Conform to RFC2616 for PUT requests by returning a Location-header.

Marius Gedminas marius at pov.lt
Thu Sep 28 13:51:56 EDT 2006


On Thu, Sep 28, 2006 at 04:25:54AM -0400, Wolfgang Schnerring wrote:
> Log message for revision 70412:
>   Conform to RFC2616 for PUT requests by returning a Location-header.
>   
>   This is a merge from branches/ctheune-issue-125, rev. 70404-70411.
>   
> 
> Changed:
>   A   Zope3/trunk/src/zope/app/http/ftests/
>   U   Zope3/trunk/src/zope/app/http/put.py
>   U   Zope3/trunk/src/zope/app/http/tests/test_put.py
> 
> -=-
> Copied: Zope3/trunk/src/zope/app/http/ftests (from rev 70411, Zope3/branches/ctheune-issue-125/src/zope/app/http/ftests)
> 
> Modified: Zope3/trunk/src/zope/app/http/put.py
> ===================================================================
> --- Zope3/trunk/src/zope/app/http/put.py	2006-09-28 08:16:37 UTC (rev 70411)
> +++ Zope3/trunk/src/zope/app/http/put.py	2006-09-28 08:25:52 UTC (rev 70412)
...
> @@ -95,11 +110,9 @@
>          file = self.context
>          adapter = IWriteFile(file)
>  
> -        # TODO: Need to add support for large files
> -        data = body.read()
> +        chunk = body.read(2**6)
> +        while chunk:
> +            adapter.write(chunk)
> +            chunk = body.read(2**6)
>  
> -        adapter.write(data)
> -
>          return ''

Ouch!  This change broke HTTP PUT for an application I'm working on.

The IWriteFile adapter for ZPTPage assumes ``write`` will be called
only once, and overwrites the contents on each call:

  # src/zope/app/zptpage/zptpage.py
  class ZPTWriteFile(object):

      implements(IWriteFile)

      def __init__(self, context):
          self.context = context

      def write(self, data):
          # We cannot communicate an encoding via FTP. Zope's default is UTF-8,
          # so use it.
          self.context.setSource(data.decode('UTF-8'), None)

as a result only the last 64-byte chunk gets written.

The interface description is not very clear:

  class IWriteFile(Interface):

      def write(data):
          """Update the file data
          """

but my reading of it is that each write() is supposed to completely
replace the existing file data, especially when you consider it in
context (IReadFile.read() returns the whole file data).

Please revert this part of your change.

Marius Gedminas
-- 
MCSE == Minesweeper Consultant / Solitaire Expert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-checkins/attachments/20060928/611c8a0d/attachment.bin


More information about the Zope3-Checkins mailing list