[Zope3-checkins] CVS: Zope3/src/zope/app/http - options.py:1.1 configure.zcml:1.4 put.py:1.4

Sidnei da Silva sidnei@x3ng.com.br
Tue, 20 May 2003 15:43:58 -0400


Update of /cvs-repository/Zope3/src/zope/app/http
In directory cvs.zope.org:/tmp/cvs-serv24523/src/zope/app/http

Modified Files:
	configure.zcml put.py 
Added Files:
	options.py 
Log Message:
More work on DAV support. Got it mostly working, but I cannot commit before writing tests :) Also, added OPTIONS view, and whitespace cleanup here and there.

=== Added File Zope3/src/zope/app/http/options.py ===
##############################################################################
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
##############################################################################
"""HTTP method OPTIONS

$Id: options.py,v 1.1 2003/05/20 19:43:27 sidnei Exp $
"""
__metaclass__ = type

_allowed_methods = ['PUT', 'DELETE', 'CONNECT', \
           'OPTIONS', 'PATCH', 'PROPFIND', 'PROPPATCH', 'MKCOL', \
           'COPY', 'MOVE', 'LOCK', 'UNLOCK', 'TRACE']
           # XXX 'GET', 'HEAD', 'POST' are always available?

from zope.component import getAdapter, queryView

class OPTIONS:
    """OPTIONS handler for all objects
    """

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

    def OPTIONS(self):
        allowed = ['GET', 'HEAD', 'POST']
        for m in _allowed_methods:
            view = queryView(self.context, m, self.request, None)
            if view is not None:
                allowed.append(m)

        self.request.response.setHeader('Allow', ', '.join(allowed))
        # XXX Most of the time, this is a lie. We not fully support
        # DAV 2 on all objects, so probably an interface check is needed.
        self.request.response.setHeader('DAV', '1,2', literal=True)
        # XXX UGLY! Some clients rely on this. eg: MacOS X
        self.request.response.setHeader('MS-Author-Via', 'DAV', literal=True)
        self.request.response.setStatus(200)
        return ''



=== Zope3/src/zope/app/http/configure.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/http/configure.zcml:1.3	Sat Mar 29 12:03:58 2003
+++ Zope3/src/zope/app/http/configure.zcml	Tue May 20 15:43:27 2003
@@ -4,7 +4,7 @@
   <allow interface="zope.app.interfaces.http.INullResource" />
 </content>
 
-<view 
+<view
   for="zope.app.interfaces.container.ISimpleReadContainer"
   name="_traverse"
   type="zope.publisher.interfaces.http.IHTTPPresentation"
@@ -13,7 +13,7 @@
   allowed_interface="zope.publisher.interfaces.IPublishTraverse"
   />
 
-<view 
+<view
   for="zope.app.interfaces.container.IItemContainer"
   name="_traverse"
   type="zope.publisher.interfaces.http.IHTTPPresentation"
@@ -22,7 +22,7 @@
   allowed_interface="zope.publisher.interfaces.IPublishTraverse"
   />
 
-<view 
+<view
   for="zope.app.interfaces.http.INullResource"
   name="PUT"
   type="zope.publisher.interfaces.http.IHTTPPresentation"
@@ -31,7 +31,7 @@
   allowed_attributes="PUT"
   />
 
-<view 
+<view
   for="*"
   name="PUT"
   type="zope.publisher.interfaces.http.IHTTPPresentation"
@@ -40,13 +40,22 @@
   allowed_attributes="PUT"
   />
 
-<view 
+<view
   for="*"
   name="DELETE"
   type="zope.publisher.interfaces.http.IHTTPPresentation"
   factory=".delete.DELETE"
   permission="zope.Public"
   allowed_attributes="DELETE"
+  />
+
+<view
+  for="*"
+  name="OPTIONS"
+  type="zope.publisher.interfaces.http.IHTTPPresentation"
+  factory=".options.OPTIONS"
+  permission="zope.ManageContent"
+  allowed_attributes="OPTIONS"
   />
 
 <include package=".exception" />


=== Zope3/src/zope/app/http/put.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/http/put.py:1.3	Sat Mar  1 06:25:52 2003
+++ Zope3/src/zope/app/http/put.py	Tue May 20 15:43:27 2003
@@ -1,7 +1,7 @@
 ##############################################################################
 # Copyright (c) 2003 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
@@ -23,7 +23,7 @@
 from zope.app.interfaces.container import IZopeWriteContainer
 from zope.app.event import publish
 from zope.app.event.objectevent import ObjectCreatedEvent
-        
+
 class NullResource:
     """Object representing objects to be created by a PUT.
     """
@@ -116,4 +116,4 @@
 
         return ''
 
-        
+