zope.app.http-3.10.2/ 0000755 0001771 0002004 00000000000 11620224621 015427 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/CHANGES.txt 0000644 0001771 0002004 00000006217 11620224476 017256 0 ustar menesis menesis 0000000 0000000 =======
CHANGES
=======
3.10.2 (2011-08-09)
-------------------
- Fixing brown bag release 3.10.1, failing tests.
3.10.1 (2011-08-04)
-------------------
- Replaced an undeclared test dependency on ``zope.app.authentication`` with
``zope.password``.
- Replaced the testing dependency on ``zope.app.zcmlfiles`` with explicit
dependencies of a minimal set of packages.
3.10.0 (2011-01-25)
-------------------
- PUT raises ``405 MethodNotAllowed`` when the context cannot be adapted to
``zope.filerepresentation.interfaces.IWriteFile`` for existing objects
resp. ``zope.filerepresentation.interfaces.IFileFactory`` for not existing
ones.
3.9.0 (2010-09-17)
------------------
- Replaced a testing dependency on `zope.app.securitypolicy` with one on
`zope.securitypolicy`.
- Removed test dependency on `zope.app.file` by moving the test which needs
this package to `zope.app.file`.
3.8 (2010-04-19)
----------------
- Remove dependency on `zope.app.testing` by using the
`zope.app.wsgi.testlayer` support instead.
At the time of this writing the test dependency on
`zope.app.zcmlfiles` cannot be removed however, because there is a
dependency on `zope.app.file` for testing, which pulls in the world.
3.7 (2010-04-13)
----------------
- Remove unnecessary dependency on `zope.app.publisher`.
- Fix for an edge case:
If someone does a ``defaultView`` for the context object and someone comes with
a not allowed method, the exception view fails on ``getAdapters``.
3.6.1 (2010-01-08)
------------------
- Replaced the dependency on `zope.deprecation` with BBB imports
- Made the dependency on `zope.app.publisher` explicit
- Fix tests using a newer `zope.publisher` that requires `zope.login`.
3.6.0 (2009-05-23)
------------------
- Moved ``IHTTPException``, ``IMethodNotAllowed``, and ``MethodNotAllowed`` from
`zope.app.http` to `zope.publisher.interfaces.http`, fixing dependency
cycles involving `zope.app.http`.
3.5.2 (2009-04-01)
------------------
- Replaced deprecated ``zope:defaultView`` directive with
``browser:defaultView``.
3.5.1 (2009-03-12)
------------------
- If the 'CONTENT_LENGTH' header is provided, provide this length as
argument to the ``read`` method of the input stream object.
3.5.0 (2009-02-01)
------------------
- Change dependency on `zope.app.container` to `zope.container`.
3.4.5 (2010-01-28)
------------------
- Backport r108613 from trunk:
Fix for an edge case:
If someone does a ``defaultView`` for the context object and someone comes with
a not allowed method, the exception view fails on ``getAdapters``.
3.4.4 (2009-01-29)
------------------
- Make tests compatible with new `zope.traversing` release.
3.4.3 (2009-01-27)
------------------
- Added missing depencendy: `zope.app.zcmlfiles`.
3.4.2 (2009-01-26)
------------------
- Add a couple of tests to the OPTIONS verb.
- Substitute `zope.app.zapi` by direct calls to its wrapped APIs and get
rid of `zope.app.zapi` as a dependency. See bug #LP219302.
3.4.1 (2007-10-31)
------------------
- Resolved ``ZopeSecurityPolicy`` deprecation warning.
3.4.0 (2007-10-24)
------------------
- Initial release independent of the main Zope tree.
zope.app.http-3.10.2/PKG-INFO 0000644 0001771 0002004 00000012136 11620224621 016527 0 ustar menesis menesis 0000000 0000000 Metadata-Version: 1.0
Name: zope.app.http
Version: 3.10.2
Summary: HTTP Behavior for the Zope Publisher
Home-page: http://pypi.python.org/pypi/zope.app.http
Author: Zope Corporation and Contributors
Author-email: zope-dev@zope.org
License: ZPL 2.1
Description: zope.app.http
*************
This package implements the simplest HTTP behavior within the Zope
Publisher. It implements all HTTP verbs as views and defines the necessary
HTTP exceptions.
=======
CHANGES
=======
3.10.2 (2011-08-09)
-------------------
- Fixing brown bag release 3.10.1, failing tests.
3.10.1 (2011-08-04)
-------------------
- Replaced an undeclared test dependency on ``zope.app.authentication`` with
``zope.password``.
- Replaced the testing dependency on ``zope.app.zcmlfiles`` with explicit
dependencies of a minimal set of packages.
3.10.0 (2011-01-25)
-------------------
- PUT raises ``405 MethodNotAllowed`` when the context cannot be adapted to
``zope.filerepresentation.interfaces.IWriteFile`` for existing objects
resp. ``zope.filerepresentation.interfaces.IFileFactory`` for not existing
ones.
3.9.0 (2010-09-17)
------------------
- Replaced a testing dependency on `zope.app.securitypolicy` with one on
`zope.securitypolicy`.
- Removed test dependency on `zope.app.file` by moving the test which needs
this package to `zope.app.file`.
3.8 (2010-04-19)
----------------
- Remove dependency on `zope.app.testing` by using the
`zope.app.wsgi.testlayer` support instead.
At the time of this writing the test dependency on
`zope.app.zcmlfiles` cannot be removed however, because there is a
dependency on `zope.app.file` for testing, which pulls in the world.
3.7 (2010-04-13)
----------------
- Remove unnecessary dependency on `zope.app.publisher`.
- Fix for an edge case:
If someone does a ``defaultView`` for the context object and someone comes with
a not allowed method, the exception view fails on ``getAdapters``.
3.6.1 (2010-01-08)
------------------
- Replaced the dependency on `zope.deprecation` with BBB imports
- Made the dependency on `zope.app.publisher` explicit
- Fix tests using a newer `zope.publisher` that requires `zope.login`.
3.6.0 (2009-05-23)
------------------
- Moved ``IHTTPException``, ``IMethodNotAllowed``, and ``MethodNotAllowed`` from
`zope.app.http` to `zope.publisher.interfaces.http`, fixing dependency
cycles involving `zope.app.http`.
3.5.2 (2009-04-01)
------------------
- Replaced deprecated ``zope:defaultView`` directive with
``browser:defaultView``.
3.5.1 (2009-03-12)
------------------
- If the 'CONTENT_LENGTH' header is provided, provide this length as
argument to the ``read`` method of the input stream object.
3.5.0 (2009-02-01)
------------------
- Change dependency on `zope.app.container` to `zope.container`.
3.4.5 (2010-01-28)
------------------
- Backport r108613 from trunk:
Fix for an edge case:
If someone does a ``defaultView`` for the context object and someone comes with
a not allowed method, the exception view fails on ``getAdapters``.
3.4.4 (2009-01-29)
------------------
- Make tests compatible with new `zope.traversing` release.
3.4.3 (2009-01-27)
------------------
- Added missing depencendy: `zope.app.zcmlfiles`.
3.4.2 (2009-01-26)
------------------
- Add a couple of tests to the OPTIONS verb.
- Substitute `zope.app.zapi` by direct calls to its wrapped APIs and get
rid of `zope.app.zapi` as a dependency. See bug #LP219302.
3.4.1 (2007-10-31)
------------------
- Resolved ``ZopeSecurityPolicy`` deprecation warning.
3.4.0 (2007-10-24)
------------------
- Initial release independent of the main Zope tree.
Keywords: zope3 http publisher view
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Programming Language :: Python
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Framework :: Zope3
zope.app.http-3.10.2/README.txt 0000644 0001771 0002004 00000000274 11620224476 017140 0 ustar menesis menesis 0000000 0000000 zope.app.http
*************
This package implements the simplest HTTP behavior within the Zope
Publisher. It implements all HTTP verbs as views and defines the necessary
HTTP exceptions.
zope.app.http-3.10.2/setup.py 0000644 0001771 0002004 00000005323 11620224476 017154 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
# This package is developed by the Zope Toolkit project, documented here:
# http://docs.zope.org/zopetoolkit
# When developing and releasing this package, please follow the documented
# Zope Toolkit policies as described by this documentation.
##############################################################################
"""Setup for zope.app.http package
"""
import os
from setuptools import setup, find_packages
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.app.http',
version='3.10.2',
author='Zope Corporation and Contributors',
author_email='zope-dev@zope.org',
description='HTTP Behavior for the Zope Publisher',
long_description=(
read('README.txt')
+ '\n\n' +
read('CHANGES.txt')
),
keywords="zope3 http publisher view",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'],
url='http://pypi.python.org/pypi/zope.app.http',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope', 'zope.app'],
extras_require=dict(
test=['zope.app.wsgi >= 3.9.0',
'zope.browserpage',
'zope.component [test]',
'zope.login',
'zope.password',
'zope.principalregistry',
'zope.securitypolicy',
'zope.site',]),
install_requires=['setuptools',
'zope.interface',
'zope.publisher>=3.12',
'zope.container',
'zope.filerepresentation',
],
include_package_data=True,
zip_safe=False,
)
zope.app.http-3.10.2/COPYRIGHT.txt 0000644 0001771 0002004 00000000040 11620224476 017542 0 ustar menesis menesis 0000000 0000000 Zope Foundation and Contributors zope.app.http-3.10.2/LICENSE.txt 0000644 0001771 0002004 00000004026 11620224476 017264 0 ustar menesis menesis 0000000 0000000 Zope Public License (ZPL) Version 2.1
A copyright notice accompanies this license document that identifies the
copyright holders.
This license has been certified as open source. It has also been designated as
GPL compatible by the Free Software Foundation (FSF).
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions in source code must retain the accompanying copyright
notice, this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the accompanying copyright
notice, this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Names of the copyright holders must not be used to endorse or promote
products derived from this software without prior written permission from the
copyright holders.
4. The right to distribute this software or to use it for any purpose does not
give you the right to use Servicemarks (sm) or Trademarks (tm) of the
copyright
holders. Use of them is covered by separate agreement with the copyright
holders.
5. If any files are modified, you must cause the modified files to carry
prominent notices stating that you changed the files and the date of any
change.
Disclaimer
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zope.app.http-3.10.2/bootstrap.py 0000644 0001771 0002004 00000003302 11620224476 020024 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
"""
import os, shutil, sys, tempfile, urllib2
tmpeggs = tempfile.mkdtemp()
ez = {}
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
import pkg_resources
cmd = 'from setuptools.command.easy_install import main; main()'
if sys.platform == 'win32':
cmd = '"%s"' % cmd # work around spawn lamosity on windows
ws = pkg_resources.working_set
assert os.spawnle(
os.P_WAIT, sys.executable, sys.executable,
'-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('setuptools')).location
),
) == 0
ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
zope.app.http-3.10.2/setup.cfg 0000644 0001771 0002004 00000000073 11620224621 017250 0 ustar menesis menesis 0000000 0000000 [egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0
zope.app.http-3.10.2/src/ 0000755 0001771 0002004 00000000000 11620224621 016216 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope.app.http.egg-info/ 0000755 0001771 0002004 00000000000 11620224621 022422 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope.app.http.egg-info/PKG-INFO 0000644 0001771 0002004 00000012136 11620224617 023527 0 ustar menesis menesis 0000000 0000000 Metadata-Version: 1.0
Name: zope.app.http
Version: 3.10.2
Summary: HTTP Behavior for the Zope Publisher
Home-page: http://pypi.python.org/pypi/zope.app.http
Author: Zope Corporation and Contributors
Author-email: zope-dev@zope.org
License: ZPL 2.1
Description: zope.app.http
*************
This package implements the simplest HTTP behavior within the Zope
Publisher. It implements all HTTP verbs as views and defines the necessary
HTTP exceptions.
=======
CHANGES
=======
3.10.2 (2011-08-09)
-------------------
- Fixing brown bag release 3.10.1, failing tests.
3.10.1 (2011-08-04)
-------------------
- Replaced an undeclared test dependency on ``zope.app.authentication`` with
``zope.password``.
- Replaced the testing dependency on ``zope.app.zcmlfiles`` with explicit
dependencies of a minimal set of packages.
3.10.0 (2011-01-25)
-------------------
- PUT raises ``405 MethodNotAllowed`` when the context cannot be adapted to
``zope.filerepresentation.interfaces.IWriteFile`` for existing objects
resp. ``zope.filerepresentation.interfaces.IFileFactory`` for not existing
ones.
3.9.0 (2010-09-17)
------------------
- Replaced a testing dependency on `zope.app.securitypolicy` with one on
`zope.securitypolicy`.
- Removed test dependency on `zope.app.file` by moving the test which needs
this package to `zope.app.file`.
3.8 (2010-04-19)
----------------
- Remove dependency on `zope.app.testing` by using the
`zope.app.wsgi.testlayer` support instead.
At the time of this writing the test dependency on
`zope.app.zcmlfiles` cannot be removed however, because there is a
dependency on `zope.app.file` for testing, which pulls in the world.
3.7 (2010-04-13)
----------------
- Remove unnecessary dependency on `zope.app.publisher`.
- Fix for an edge case:
If someone does a ``defaultView`` for the context object and someone comes with
a not allowed method, the exception view fails on ``getAdapters``.
3.6.1 (2010-01-08)
------------------
- Replaced the dependency on `zope.deprecation` with BBB imports
- Made the dependency on `zope.app.publisher` explicit
- Fix tests using a newer `zope.publisher` that requires `zope.login`.
3.6.0 (2009-05-23)
------------------
- Moved ``IHTTPException``, ``IMethodNotAllowed``, and ``MethodNotAllowed`` from
`zope.app.http` to `zope.publisher.interfaces.http`, fixing dependency
cycles involving `zope.app.http`.
3.5.2 (2009-04-01)
------------------
- Replaced deprecated ``zope:defaultView`` directive with
``browser:defaultView``.
3.5.1 (2009-03-12)
------------------
- If the 'CONTENT_LENGTH' header is provided, provide this length as
argument to the ``read`` method of the input stream object.
3.5.0 (2009-02-01)
------------------
- Change dependency on `zope.app.container` to `zope.container`.
3.4.5 (2010-01-28)
------------------
- Backport r108613 from trunk:
Fix for an edge case:
If someone does a ``defaultView`` for the context object and someone comes with
a not allowed method, the exception view fails on ``getAdapters``.
3.4.4 (2009-01-29)
------------------
- Make tests compatible with new `zope.traversing` release.
3.4.3 (2009-01-27)
------------------
- Added missing depencendy: `zope.app.zcmlfiles`.
3.4.2 (2009-01-26)
------------------
- Add a couple of tests to the OPTIONS verb.
- Substitute `zope.app.zapi` by direct calls to its wrapped APIs and get
rid of `zope.app.zapi` as a dependency. See bug #LP219302.
3.4.1 (2007-10-31)
------------------
- Resolved ``ZopeSecurityPolicy`` deprecation warning.
3.4.0 (2007-10-24)
------------------
- Initial release independent of the main Zope tree.
Keywords: zope3 http publisher view
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Programming Language :: Python
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Framework :: Zope3
zope.app.http-3.10.2/src/zope.app.http.egg-info/top_level.txt 0000644 0001771 0002004 00000000005 11620224617 025154 0 ustar menesis menesis 0000000 0000000 zope
zope.app.http-3.10.2/src/zope.app.http.egg-info/SOURCES.txt 0000644 0001771 0002004 00000002356 11620224617 024321 0 ustar menesis menesis 0000000 0000000 CHANGES.txt
COPYRIGHT.txt
LICENSE.txt
README.txt
bootstrap.py
buildout.cfg
setup.py
src/zope/__init__.py
src/zope.app.http.egg-info/PKG-INFO
src/zope.app.http.egg-info/SOURCES.txt
src/zope.app.http.egg-info/dependency_links.txt
src/zope.app.http.egg-info/namespace_packages.txt
src/zope.app.http.egg-info/not-zip-safe
src/zope.app.http.egg-info/requires.txt
src/zope.app.http.egg-info/top_level.txt
src/zope/app/__init__.py
src/zope/app/http/__init__.py
src/zope/app/http/configure.zcml
src/zope/app/http/delete.py
src/zope/app/http/ftesting.zcml
src/zope/app/http/httpdate.py
src/zope/app/http/interfaces.py
src/zope/app/http/options.py
src/zope/app/http/put.py
src/zope/app/http/traversal.py
src/zope/app/http/exception/__init__.py
src/zope/app/http/exception/configure.zcml
src/zope/app/http/exception/methodnotallowed.py
src/zope/app/http/exception/notfound.py
src/zope/app/http/exception/unauthorized.py
src/zope/app/http/exception/tests/__init__.py
src/zope/app/http/exception/tests/test_methodnotallowed.py
src/zope/app/http/exception/tests/test_unauthorized.py
src/zope/app/http/tests/__init__.py
src/zope/app/http/tests/test_delete.py
src/zope/app/http/tests/test_options.py
src/zope/app/http/tests/test_put.py
src/zope/app/http/tests/test_traversers.py zope.app.http-3.10.2/src/zope.app.http.egg-info/namespace_packages.txt 0000644 0001771 0002004 00000000016 11620224617 026757 0 ustar menesis menesis 0000000 0000000 zope
zope.app
zope.app.http-3.10.2/src/zope.app.http.egg-info/not-zip-safe 0000644 0001771 0002004 00000000001 11620224500 024644 0 ustar menesis menesis 0000000 0000000
zope.app.http-3.10.2/src/zope.app.http.egg-info/dependency_links.txt 0000644 0001771 0002004 00000000001 11620224617 026475 0 ustar menesis menesis 0000000 0000000
zope.app.http-3.10.2/src/zope.app.http.egg-info/requires.txt 0000644 0001771 0002004 00000000351 11620224617 025026 0 ustar menesis menesis 0000000 0000000 setuptools
zope.interface
zope.publisher>=3.12
zope.container
zope.filerepresentation
[test]
zope.app.wsgi >= 3.9.0
zope.browserpage
zope.component [test]
zope.login
zope.password
zope.principalregistry
zope.securitypolicy
zope.site zope.app.http-3.10.2/src/zope/ 0000755 0001771 0002004 00000000000 11620224621 017173 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope/__init__.py 0000644 0001771 0002004 00000000311 11620224476 021307 0 ustar menesis menesis 0000000 0000000 # this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
zope.app.http-3.10.2/src/zope/app/ 0000755 0001771 0002004 00000000000 11620224621 017753 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope/app/__init__.py 0000644 0001771 0002004 00000000311 11620224476 022067 0 ustar menesis menesis 0000000 0000000 # this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
zope.app.http-3.10.2/src/zope/app/http/ 0000755 0001771 0002004 00000000000 11620224621 020732 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope/app/http/__init__.py 0000644 0001771 0002004 00000000075 11620224476 023055 0 ustar menesis menesis 0000000 0000000 #
# This file is necessary to make this directory a package.
zope.app.http-3.10.2/src/zope/app/http/options.py 0000644 0001771 0002004 00000004034 11620224476 023010 0 ustar menesis menesis 0000000 0000000 ##############################################################################
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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`
"""
__docformat__ = 'restructuredtext'
_allowed_methods = ['PUT', 'DELETE', 'CONNECT', \
'OPTIONS', 'PATCH', 'PROPFIND', 'PROPPATCH', 'MKCOL', \
'COPY', 'MOVE', 'LOCK', 'UNLOCK', 'TRACE']
# 'GET', 'HEAD', 'POST' are always available. See OPTIONS() method.
from zope.component import queryMultiAdapter
class OPTIONS(object):
"""`OPTIONS` handler for all objects
"""
def __init__(self, context, request):
self.context = context
self.request = request
def OPTIONS(self):
allowed = ['GET', 'HEAD', 'POST']
# TODO: This could be cleaned up by providing special target
# interfaces for HTTP methods. This way we can even list verbs that
# are not in the lists above.
for m in _allowed_methods:
view = queryMultiAdapter((self.context, self.request), name=m)
if view is not None:
allowed.append(m)
self.request.response.setHeader('Allow', ', '.join(allowed))
# TODO: 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)
# 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 ''
zope.app.http-3.10.2/src/zope/app/http/put.py 0000644 0001771 0002004 00000007123 11620224476 022127 0 ustar menesis menesis 0000000 0000000 ##############################################################################
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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 `PUT` verb"""
__docformat__ = 'restructuredtext'
from zope.component import queryAdapter
from zope.event import notify
from zope.lifecycleevent import ObjectCreatedEvent
from zope.interface import implements
from zope.filerepresentation.interfaces import IWriteFile
from zope.filerepresentation.interfaces import \
IWriteDirectory, IReadDirectory, IFileFactory
import zope.traversing.browser
import zope.publisher.interfaces.http
from zope.app.http.interfaces import INullResource
class NullResource(object):
"""Object representing objects to be created by a `PUT`.
"""
implements(INullResource)
def __init__(self, container, name):
self.container = container
self.name = name
class NullPUT(object):
"""Put handler for null resources (new file-like things)
This view creates new objects in containers.
"""
def __init__(self, context, request):
self.context = context
self.request = request
def PUT(self):
request = self.request
body = request.bodyStream
name = self.context.name
container = self.context.container
# Find the extension
ext_start = name.rfind('.')
if ext_start > 0:
ext = name[ext_start:]
else:
ext = "."
# Get a "directory" surrogate for the container
# TODO: Argh. Why don't we have a unioned Interface for that?!?
dir_write = IWriteDirectory(container)
dir_read = IReadDirectory(container)
# Now try to get a custom factory for he container
factory = queryAdapter(container, IFileFactory, ext)
# Fall back to a non-custom one
if factory is None:
factory = IFileFactory(container, None)
if factory is None:
raise zope.publisher.interfaces.http.MethodNotAllowed(
container, self.request)
# TODO: Need to add support for large files
data = body.read()
newfile = factory(name, request.getHeader('content-type', ''), data)
notify(ObjectCreatedEvent(newfile))
dir_write[name] = newfile
# Ickyness with non-predictable support for containment:
# make sure we get a containment proxy
newfile = dir_read[name]
request.response.setStatus(201)
request.response.setHeader(
'Location', zope.traversing.browser.absoluteURL(newfile, request))
return ''
class FilePUT(object):
"""Put handler for existing file-like things
"""
def __init__(self, context, request):
self.context = context
self.request = request
def PUT(self):
body = self.request.bodyStream
file = self.context
adapter = IWriteFile(file, None)
if adapter is None:
raise zope.publisher.interfaces.http.MethodNotAllowed(
self.context, self.request)
length = int(self.request.get('CONTENT_LENGTH', -1))
adapter.write(body.read(length))
return ''
zope.app.http-3.10.2/src/zope/app/http/interfaces.py 0000644 0001771 0002004 00000002060 11620224476 023435 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Zope-specific HTTP interfaces
"""
__docformat__ = 'restructuredtext'
from zope.interface import Interface, Attribute
from zope.publisher.interfaces.http import IHTTPException #BBB import
class INullResource(Interface):
"""Placeholder objects for new container items to be created via PUT
"""
container = Attribute("The container of the future resource")
name = Attribute("The name of the object to be created.")
zope.app.http-3.10.2/src/zope/app/http/configure.zcml 0000644 0001771 0002004 00000003125 11620224476 023613 0 ustar menesis menesis 0000000 0000000
zope.app.http-3.10.2/src/zope/app/http/ftesting.zcml 0000644 0001771 0002004 00000002272 11620224476 023457 0 ustar menesis menesis 0000000 0000000
zope.app.http-3.10.2/src/zope/app/http/exception/ 0000755 0001771 0002004 00000000000 11620224621 022730 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope/app/http/exception/__init__.py 0000644 0001771 0002004 00000000077 11620224476 025055 0 ustar menesis menesis 0000000 0000000 # empty __init__.py file to make this directory into a package
zope.app.http-3.10.2/src/zope/app/http/exception/unauthorized.py 0000644 0001771 0002004 00000002077 11620224476 026041 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Unauthorized Exception
"""
__docformat__ = 'restructuredtext'
from zope.publisher.interfaces.http import IHTTPException
from zope.interface import implements
class Unauthorized(object):
implements(IHTTPException)
def __init__(self, context, request):
self.context = context
self.request = request
def __call__(self):
self.request.unauthorized('basic realm="Zope"')
return ''
__str__ = __call__
zope.app.http-3.10.2/src/zope/app/http/exception/configure.zcml 0000644 0001771 0002004 00000002404 11620224476 025610 0 ustar menesis menesis 0000000 0000000
zope.app.http-3.10.2/src/zope/app/http/exception/tests/ 0000755 0001771 0002004 00000000000 11620224621 024072 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope/app/http/exception/tests/__init__.py 0000644 0001771 0002004 00000000077 11620224476 026217 0 ustar menesis menesis 0000000 0000000 # empty __init__.py file to make this directory into a package
zope.app.http-3.10.2/src/zope/app/http/exception/tests/test_methodnotallowed.py 0000644 0001771 0002004 00000007777 11620224476 031106 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Tests for HTTP error views
"""
from unittest import TestCase, TestSuite, main, makeSuite
from StringIO import StringIO
from zope.interface import Interface, implements
from zope.publisher.http import HTTPRequest
from zope.publisher.interfaces.http import IHTTPRequest
from zope.component import provideAdapter
class I(Interface):
pass
class C(object):
implements(I)
class GetView(object):
def __init__(self, context, request):
pass
def GET(self):
pass
class DeleteView(object):
def __init__(self, context, request):
pass
def DELETE(self):
pass
class TestMethodNotAllowedView(TestCase):
def setUp(self):
from zope.publisher.interfaces.http import IHTTPRequest
provideAdapter(GetView, (I, IHTTPRequest), Interface, 'GET')
provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'DELETE')
provideAdapter(GetView, (I, IHTTPRequest), Interface, 'irrelevant')
provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'also_irr.')
from zope.publisher.interfaces import IDefaultViewName
from zope.publisher.interfaces.browser import IBrowserRequest
#do the same as defaultView would for something like:
#
provideAdapter(u'index.html', (I, IBrowserRequest), IDefaultViewName)
def test(self):
from zope.publisher.interfaces.http import MethodNotAllowed
from zope.app.http.exception.methodnotallowed \
import MethodNotAllowedView
from zope.publisher.http import HTTPRequest
context = C()
request = HTTPRequest(StringIO('PUT /bla/bla HTTP/1.1\n\n'), {})
error = MethodNotAllowed(context, request)
view = MethodNotAllowedView(error, request)
result = view()
self.assertEqual(request.response.getStatus(), 405)
self.assertEqual(request.response.getHeader('Allow'), 'DELETE, GET')
self.assertEqual(result, 'Method Not Allowed')
def test_defaultView(self):
# do the same with a BrowserRequest
# edge case is that if someone does a defaultView for the context object
# but the app is not prepared for webdav or whatever
# and someone comes with a not allowed method, the exception
# view fails on getAdapters
# this might be an issue with zope.publisher, as it provides
# a unicode object with provideAdapter, but I don't think I can
# change zope.publisher
from zope.publisher.interfaces.http import MethodNotAllowed
from zope.app.http.exception.methodnotallowed \
import MethodNotAllowedView
from zope.publisher.browser import BrowserRequest
context = C()
request = BrowserRequest(StringIO('PUT /bla/bla HTTP/1.1\n\n'), {})
error = MethodNotAllowed(context, request)
view = MethodNotAllowedView(error, request)
result = view()
self.assertEqual(request.response.getStatus(), 405)
#well this is empty, but we're grateful that it does not break
self.assertEqual(request.response.getHeader('Allow'), '')
self.assertEqual(result, 'Method Not Allowed')
def test_suite():
return TestSuite((
makeSuite(TestMethodNotAllowedView),
))
if __name__=='__main__':
main(defaultTest='test_suite')
zope.app.http-3.10.2/src/zope/app/http/exception/tests/test_unauthorized.py 0000644 0001771 0002004 00000003117 11620224476 030236 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Unauthorized Exception Test
"""
from unittest import TestCase, main, makeSuite
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.http import IHTTPException
class Test(TestCase):
def testbasicauth(self):
from zope.app.http.exception.unauthorized import Unauthorized
exception = Exception()
try:
raise exception
except:
pass
request = TestRequest()
u = Unauthorized(exception, request)
# Chech that we implement the right interface
self.failUnless(IHTTPException.providedBy(u))
# Call the view
u()
# Make sure the response status was set
self.assertEqual(request.response.getStatus(), 401)
self.failUnless(request.response.getHeader('WWW-Authenticate', '', True).startswith('basic'))
def test_suite():
return makeSuite(Test)
if __name__=='__main__':
main(defaultTest='test_suite')
zope.app.http-3.10.2/src/zope/app/http/exception/notfound.py 0000644 0001771 0002004 00000002401 11620224476 025143 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Not found Exception
"""
__docformat__ = 'restructuredtext'
from zope.publisher.interfaces.http import IHTTPException
from zope.interface import implements
class NotFound(object):
implements(IHTTPException)
def __init__(self, context, request):
self.context = context
self.request = request
def __call__(self):
if self.request.method in ['MKCOL'] and \
self.request.getTraversalStack():
# MKCOL with non-existing parent.
self.request.response.setStatus(409)
else:
self.request.response.setStatus(404)
return ''
__str__ = __call__
zope.app.http-3.10.2/src/zope/app/http/exception/methodnotallowed.py 0000644 0001771 0002004 00000003405 11620224476 026665 0 ustar menesis menesis 0000000 0000000 ##############################################################################
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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 405: Method Not Allowed view
"""
from zope.component import getAdapters
from zope.interface import Interface
from zope.publisher.interfaces.http import IMethodNotAllowed
class MethodNotAllowedView(object):
"""A view for MethodNotAllowed that renders a HTTP 405 response."""
__used_for__ = IMethodNotAllowed
def __init__(self, error, request):
self.error = error
self.request = request
allow = []
try:
# see test_methodnotallowed.TestMethodNotAllowedView.test_defaultView
# I could not solve this with a while ... next() iterator
# because it seems like once the generator had an exception it
# stops returning items
self.allow = [
name for name, adapter
in getAdapters((error.object, error.request), Interface)
if hasattr(adapter, name)]
self.allow.sort()
except TypeError:
self.allow = []
def __call__(self):
self.request.response.setHeader('Allow', ', '.join(self.allow))
self.request.response.setStatus(405)
return 'Method Not Allowed'
zope.app.http-3.10.2/src/zope/app/http/tests/ 0000755 0001771 0002004 00000000000 11620224621 022074 5 ustar menesis menesis 0000000 0000000 zope.app.http-3.10.2/src/zope/app/http/tests/__init__.py 0000644 0001771 0002004 00000000075 11620224476 024217 0 ustar menesis menesis 0000000 0000000 #
# This file is necessary to make this directory a package.
zope.app.http-3.10.2/src/zope/app/http/tests/test_delete.py 0000644 0001771 0002004 00000003736 11620224476 024770 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Test HTTP DELETE verb
"""
from unittest import TestCase, TestSuite, makeSuite
from zope.interface import implements
from zope.publisher.browser import TestRequest
from zope.filerepresentation.interfaces import IWriteDirectory, IFileFactory
import zope.app.http.delete
from zope.container.contained import contained
from zope.publisher.interfaces.http import MethodNotAllowed
class UnwritableContainer(object):
pass
class Container(object):
implements(IWriteDirectory, IFileFactory)
def __delitem__(self, name):
delattr(self, name)
class TestDelete(TestCase):
def test(self):
container = Container()
container.a = 'spam'
item = contained(Container(), container, name='a')
request = TestRequest()
delete = zope.app.http.delete.DELETE(item, request)
self.assert_(hasattr(container, 'a'))
self.assertEqual(delete.DELETE(), '')
self.assert_(not hasattr(container, 'a'))
def test_not_deletable(self):
container = UnwritableContainer()
container.a = 'spam'
item = contained(UnwritableContainer(), container, name='a')
request = TestRequest()
delete = zope.app.http.delete.DELETE(item, request)
self.assertRaises(MethodNotAllowed, delete.DELETE)
def test_suite():
return TestSuite((
makeSuite(TestDelete),
))
zope.app.http-3.10.2/src/zope/app/http/tests/test_put.py 0000644 0001771 0002004 00000015410 11620224476 024326 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Test HTTP PUT verb
"""
from unittest import TestCase, TestSuite, makeSuite
from StringIO import StringIO
from zope.interface import implements
from zope.publisher.browser import TestRequest
from zope.filerepresentation.interfaces import IWriteFile
from zope.filerepresentation.interfaces import IWriteDirectory, IReadDirectory, IFileFactory
import zope.app.http.put
from zope.location.interfaces import ILocation
from zope.site.folder import rootFolder
from zope.app.wsgi.testlayer import BrowserLayer
class File(object):
implements(IWriteFile, ILocation)
def __init__(self, name, content_type, data):
self.name = name
self.content_type = content_type
self.data = data
def write(self, data):
self.data = data
class Container(object):
implements(IWriteDirectory, IReadDirectory, IFileFactory, ILocation)
__name__ = None
__parent__ = None
def __init__(self, path):
self.path = path
def __setitem__(self, name, object):
object.__name__ = name
object.__parent__ = self
setattr(self, name, object)
def __getitem__(self, name):
return getattr(self, name)
def __call__(self, name, content_type, data):
return File(name, content_type, data)
class TestNullPUT(TestCase):
layer = BrowserLayer(zope.app.http)
def test(self):
self.rootFolder = rootFolder()
container = Container("put")
self.rootFolder["put"] = container
content = "some content\n for testing"
request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
})
null = zope.app.http.put.NullResource(container, 'spam.txt')
put = zope.app.http.put.NullPUT(null, request)
self.assertEqual(getattr(container, 'spam', None), None)
self.assertEqual(put.PUT(), '')
request.response.setResult('')
file = getattr(container, 'spam.txt')
self.assertEqual(file.__class__, File)
self.assertEqual(file.name, 'spam.txt')
self.assertEqual(file.content_type, 'test/foo')
self.assertEqual(file.data, content)
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 201)
self.assertEqual(request.response.getHeader("Location"),
"http://127.0.0.1/put/spam.txt")
def test_bad_content_header(self):
## The previous behavour of the PUT method was to fail if the request
## object had a key beginning with 'HTTP_CONTENT_' with a status of 501.
## This was breaking the new Twisted server, so I am now allowing this
## this type of request to be valid.
self.rootFolder = rootFolder()
container = Container("/put")
self.rootFolder["put"] = container
content = "some content\n for testing"
request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
'HTTP_CONTENT_FOO': 'Bar',
})
null = zope.app.http.put.NullResource(container, 'spam')
put = zope.app.http.put.NullPUT(null, request)
self.assertEqual(getattr(container, 'spam', None), None)
self.assertEqual(put.PUT(), '')
request.response.setResult('')
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 201)
def test_put_on_invalid_container_raises_MethodNotAllowed(self):
import zope.publisher.interfaces.http
request = TestRequest(StringIO(),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': '0',
})
null = zope.app.http.put.NullResource(rootFolder(), 'spam.txt')
put = zope.app.http.put.NullPUT(null, request)
self.assertRaises(zope.publisher.interfaces.http.MethodNotAllowed,
put.PUT)
class TestFilePUT(TestCase):
layer = BrowserLayer(zope.app.http)
def test(self):
file = File("thefile", "text/x", "initial content")
content = "some content\n for testing"
request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
})
put = zope.app.http.put.FilePUT(file, request)
self.assertEqual(put.PUT(), '')
request.response.setResult('')
self.assertEqual(file.data, content)
def test_bad_content_header(self):
## The previous behavour of the PUT method was to fail if the request
## object had a key beginning with 'HTTP_CONTENT_' with a status of 501.
## This was breaking the new Twisted server, so I am now allowing this
## this type of request to be valid.
file = File("thefile", "text/x", "initial content")
content = "some content\n for testing"
request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
'HTTP_CONTENT_FOO': 'Bar',
})
put = zope.app.http.put.FilePUT(file, request)
self.assertEqual(put.PUT(), '')
request.response.setResult('')
self.assertEqual(file.data, content)
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 200)
def test_put_on_invalid_file_raises_MethodNotAllowed(self):
import zope.publisher.interfaces.http
file = object()
request = TestRequest(StringIO(),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': '0',
})
put = zope.app.http.put.FilePUT(file, request)
self.assertRaises(zope.publisher.interfaces.http.MethodNotAllowed,
put.PUT)
def test_suite():
return TestSuite((
makeSuite(TestFilePUT),
makeSuite(TestNullPUT),
))
zope.app.http-3.10.2/src/zope/app/http/tests/test_options.py 0000644 0001771 0002004 00000004616 11620224476 025217 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2008 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Test HTTP OPTIONS verb
"""
from unittest import TestCase, TestSuite, makeSuite
import zope.interface
from zope.publisher.browser import IBrowserRequest
from zope.publisher.browser import TestRequest
import zope.app.http.options
class IDeletable(zope.interface.Interface):
"Marker interface that says that something understand the DELETE method"
class Deletable(object):
"Rocket science implementation of IDeletable"
zope.interface.implements(IDeletable)
class DeleteView(object):
"A view for a deletable object"
def __init__(self, context, request):
self.context = context
self.request = request
class TestOptions(TestCase):
def testDefaultMethods(self):
dumbObj = object()
request = TestRequest()
options = zope.app.http.options.OPTIONS(dumbObj, request)
self.assertEqual(options.OPTIONS(), '')
getHeader = request.response.getHeader
self.assertEqual(getHeader('Allow'), 'GET, HEAD, POST')
self.assertEqual(getHeader('DAV', literal=True), '1,2')
self.assertEqual(getHeader('MS-Author-Via', literal=True), 'DAV')
self.assertEqual(request.response.getStatus(), 200)
def testExtendedMethods(self):
gst = zope.component.getGlobalSiteManager()
gst.registerAdapter(DeleteView, (IDeletable, IBrowserRequest),
zope.interface.Interface, 'PUT')
deletableObject = Deletable()
request = TestRequest()
options = zope.app.http.options.OPTIONS(deletableObject, request)
self.assertEqual(options.OPTIONS(), '')
getHeader = request.response.getHeader
self.assertEqual(getHeader('Allow'), 'GET, HEAD, POST, PUT')
def test_suite():
return TestSuite((
makeSuite(TestOptions),
))
zope.app.http-3.10.2/src/zope/app/http/tests/test_traversers.py 0000644 0001771 0002004 00000004661 11620224476 025724 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Test HTTP-specific object traversers
"""
from unittest import TestCase, TestSuite, main, makeSuite
from zope.publisher.interfaces import NotFound
from zope.app.http.traversal import ContainerTraverser, ItemTraverser
from zope.publisher.browser import TestRequest
from zope.app.http.put import NullResource
class Items(object):
def __init__(self, data):
self.data = data
def __getitem__(self, name):
return self.data[name]
class Container(Items):
def get(self, name, default=None):
return self.data.get(name, default)
class TestContainer(TestCase):
Container = Container
Traverser = ContainerTraverser
def testSubobject(self):
container = self.Container({'foo': 42})
request = TestRequest()
traverser = self.Traverser(container, request)
self.assertEqual(traverser.publishTraverse(request, 'foo'), 42)
def testNotFound(self):
container = self.Container({'foo': 42})
request = TestRequest()
traverser = self.Traverser(container, request)
self.assertRaises(NotFound,
traverser.publishTraverse, request, 'bar')
def testNull(self):
container = self.Container({'foo': 42})
request = TestRequest()
request.method = 'PUT'
traverser = self.Traverser(container, request)
null = traverser.publishTraverse(request, 'bar')
self.assertEqual(null.__class__, NullResource)
self.assertEqual(null.container, container)
self.assertEqual(null.name, 'bar')
class TestItem(TestContainer):
Container = Items
Traverser = ItemTraverser
def test_suite():
return TestSuite((
makeSuite(TestContainer),
makeSuite(TestItem),
))
if __name__=='__main__':
main(defaultTest='test_suite')
zope.app.http-3.10.2/src/zope/app/http/delete.py 0000644 0001771 0002004 00000002501 11620224476 022554 0 ustar menesis menesis 0000000 0000000 ##############################################################################
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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 DELETE verb
"""
__docformat__ = 'restructuredtext'
from zope.filerepresentation.interfaces import IWriteDirectory
from zope.publisher.interfaces.http import MethodNotAllowed
class DELETE(object):
"""Delete handler for all objects
"""
def __init__(self, context, request):
self.context = context
self.request = request
def DELETE(self):
victim = self.context
container = victim.__parent__
name = victim.__name__
# Get a "directory" surrogate for the container
dir = IWriteDirectory(container, None)
if dir is None:
raise MethodNotAllowed(self.context, self.request)
del dir[name]
return ''
zope.app.http-3.10.2/src/zope/app/http/httpdate.py 0000644 0001771 0002004 00000010023 11620224476 023125 0 ustar menesis menesis 0000000 0000000 ##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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 Server Date/Time utilities
"""
import re
import string
import time
import calendar
def concat(*args):
return ''.join(args)
def join(seq, field=' '):
return field.join(seq)
def group(s):
return '(' + s + ')'
short_days = ['sun','mon','tue','wed','thu','fri','sat']
long_days = ['sunday','monday','tuesday','wednesday',
'thursday','friday','saturday']
short_day_reg = group(join(short_days, '|'))
long_day_reg = group(join(long_days, '|'))
daymap = {}
for i in range(7):
daymap[short_days[i]] = i
daymap[long_days[i]] = i
hms_reg = join(3 * [group('[0-9][0-9]')], ':')
months = ['jan','feb','mar','apr','may','jun','jul',
'aug','sep','oct','nov','dec']
monmap = {}
for i in range(12):
monmap[months[i]] = i+1
months_reg = group(join(months, '|'))
# From draft-ietf-http-v11-spec-07.txt/3.3.1
# Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
# Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
# Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
# rfc822 format
rfc822_date = join(
[concat (short_day_reg,','), # day
group('[0-9][0-9]?'), # date
months_reg, # month
group('[0-9]+'), # year
hms_reg, # hour minute second
'gmt'
],
' '
)
rfc822_reg = re.compile(rfc822_date)
def unpack_rfc822(m):
g = m.group
a = string.atoi
return (
a(g(4)), # year
monmap[g(3)], # month
a(g(2)), # day
a(g(5)), # hour
a(g(6)), # minute
a(g(7)), # second
0,
0,
0
)
# rfc850 format
rfc850_date = join(
[concat(long_day_reg,','),
join(
[group ('[0-9][0-9]?'),
months_reg,
group ('[0-9]+')
],
'-'
),
hms_reg,
'gmt'
],
' '
)
rfc850_reg = re.compile(rfc850_date)
# they actually unpack the same way
def unpack_rfc850(m):
g = m.group
a = string.atoi
return (
a(g(4)), # year
monmap[g(3)], # month
a(g(2)), # day
a(g(5)), # hour
a(g(6)), # minute
a(g(7)), # second
0,
0,
0
)
# parsdate.parsedate - ~700/sec.
# parse_http_date - ~1333/sec.
weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
def build_http_date(when):
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(when)
return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
weekdayname[wd],
day, monthname[month], year,
hh, mm, ss)
def parse_http_date(d):
d = d.lower()
m = rfc850_reg.match(d)
if m and m.end() == len(d):
retval = int(calendar.timegm(unpack_rfc850(m)))
else:
m = rfc822_reg.match(d)
if m and m.end() == len(d):
retval = int(calendar.timegm(unpack_rfc822(m)))
else:
return 0
return retval
zope.app.http-3.10.2/src/zope/app/http/traversal.py 0000644 0001771 0002004 00000004327 11620224476 023325 0 ustar menesis menesis 0000000 0000000 ##############################################################################
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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-specific traversers
For straight HTTP, we need to be able to create null resources.
We also never traverse to views.
"""
__docformat__ = 'restructuredtext'
from zope.publisher.interfaces.http import IHTTPPublisher
from zope.container.interfaces import ISimpleReadContainer, IItemContainer
from zope.app.http.put import NullResource
from zope.publisher.interfaces import NotFound
from zope.interface import implements
class ContainerTraverser(object):
implements(IHTTPPublisher)
__used_for__ = ISimpleReadContainer
def __init__(self, container, request):
self.context = container
self.request = request
def publishTraverse(self, request, name):
subob = self.context.get(name, None)
if subob is None:
subob = self.nullResource(request, name)
return subob
def nullResource(self, request, name):
# we traversed to something that doesn't exist.
# The name must be the last name in the path, so the traversal
# name stack better be empty:
if request.getTraversalStack():
raise NotFound(self.context, name, request)
# This should only happen for a PUT or MKCOL:
if request.method not in ['PUT', 'MKCOL']:
raise NotFound(self.context, name, request)
return NullResource(self.context, name)
class ItemTraverser(ContainerTraverser):
__used_for__ = IItemContainer
def publishTraverse(self, request, name):
context = self.context
try:
return context[name]
except KeyError:
return self.nullResource(request, name)
zope.app.http-3.10.2/buildout.cfg 0000644 0001771 0002004 00000000607 11620224476 017752 0 ustar menesis menesis 0000000 0000000 [buildout]
develop = .
parts = test coverage-test coverage-report
[test]
recipe = zc.recipe.testrunner
eggs = zope.app.http [test]
[coverage-test]
recipe = zc.recipe.testrunner
eggs = zope.app.http [test]
defaults = ['--coverage', '../../coverage']
[coverage-report]
recipe = zc.recipe.egg
eggs = z3c.coverage
scripts = coverage=coverage-report
arguments = ('coverage', 'coverage/report')