[Zope-CVS] CVS: Packages/Moztop/moztopsupport/http - options.py:1.1 configure.zcml:1.2

Sidnei da Silva sidnei@x3ng.com.br
Mon, 24 Mar 2003 14:19:46 -0500


Update of /cvs-repository/Packages/Moztop/moztopsupport/http
In directory cvs.zope.org:/tmp/cvs-serv23493/http

Modified Files:
	configure.zcml 
Added Files:
	options.py 
Log Message:
Stupid simple OPTIONS handler for HTTP. It does less than expected and the results are not completely true, but its enough to fool cadaver.

=== Added File Packages/Moztop/moztopsupport/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/03/24 19:19:45 sidnei Exp $
"""
__metaclass__ = type

_allowed_methods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', \
           'OPTIONS', 'PATCH', 'PROPFIND', 'PROPPATCH', 'MKCOL', \
           'COPY', 'MOVE', 'LOCK', 'UNLOCK', 'TRACE']

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 = []
        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))
        self.request.response.setStatus(200)
        return ''



=== Packages/Moztop/moztopsupport/http/configure.zcml 1.1 => 1.2 ===
--- Packages/Moztop/moztopsupport/http/configure.zcml:1.1	Thu Mar 20 13:24:27 2003
+++ Packages/Moztop/moztopsupport/http/configure.zcml	Mon Mar 24 14:19:45 2003
@@ -1,5 +1,10 @@
 <zopeConfigure xmlns='http://namespaces.zope.org/zope'>
 
+<!--
+
+     Disabled for now. there is a bug in ZCML that doesnt let you
+     override configurations at this point
+
 <view 
   for="zope.app.interfaces.http.INullResource"
   name="PUT"
@@ -7,6 +12,16 @@
   factory=".put.NullPUT"
   permission="zope.Public"
   allowed_attributes="PUT"
+  />
+-->
+
+<view 
+  for="*"
+  name="OPTIONS"
+  type="zope.publisher.interfaces.http.IHTTPPresentation"
+  factory=".options.OPTIONS"
+  permission="zope.Public"
+  allowed_attributes="OPTIONS"
   />
 
 <adapter