Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
temporary fixes to get rid of the zope.app.http and zope.app.exceptio…
Browse files Browse the repository at this point in the history
…n dependencies
  • Loading branch information
janwijbrand committed Jan 18, 2011
1 parent 26ca160 commit 50ea9c1
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 49 deletions.
34 changes: 12 additions & 22 deletions buildout.cfg
@@ -1,33 +1,23 @@
[buildout]
extends = http://svn.zope.org/repos/main/groktoolkit/trunk/grok.cfg
develop = .
parts =
test
omelette
develop =
.
versions = versions
extensions =
buildout.dumppickedversions
mr.developer

sources = sources
auto-checkout =
grokcore.traverser

[sources]
grokcore.traverser = svn http://svn.zope.org/repos/main/grokcore.traverser/trunk


[omelette]
recipe = collective.recipe.omelette
eggs = ${test:eggs}
test
omelette
extensions =
buildout.dumppickedversions
mr.developer

[versions]
grokcore.rest =

[test]
recipe = zc.recipe.testrunner
eggs =
grokcore.rest
grokcore.rest[test]
grokcore.rest
grokcore.rest[test]
defaults = ['--tests-pattern', '^f?tests$', '-v', '-c']

[omelette]
recipe = collective.recipe.omelette
eggs = ${test:eggs}
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -19,8 +19,8 @@ def read(*rnames):
'zope.testing',
'zope.app.wsgi',
'zope.app.appsetup',
'zope.app.exception',
'zope.app.http',
# 'zope.app.exception',
# 'zope.app.http',
'grokcore.content',
]

Expand Down
44 changes: 30 additions & 14 deletions src/grokcore/rest/configure.zcml
@@ -1,26 +1,42 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:grok="http://namespaces.zope.org/grok">
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:grok="http://namespaces.zope.org/grok">

<include file="meta.zcml" />

<!-- we register a ++rest++ traversal namespace -->
<adapter
factory=".rest.rest_skin"
for="* zope.publisher.interfaces.browser.IHTTPRequest"
provides="zope.traversing.interfaces.ITraversable"
name="rest"
/>
factory=".rest.rest_skin"
for="* zope.publisher.interfaces.browser.IHTTPRequest"
provides="zope.traversing.interfaces.ITraversable"
name="rest"
/>

<publisher
name="HTTP"
factory=".publication.GrokHTTPFactory"
methods="*"
mimetypes="*"
priority="1"
/>
name="HTTP"
factory=".publication.GrokHTTPFactory"
methods="*"
mimetypes="*"
priority="1"
/>

<grok:grok package=".rest" />

<!--
XXX temporary registrations copied from zope.app.http.exception;
awaiting a [zope|grokcore].errorview package.
-->
<browser:defaultView
for="zope.security.interfaces.IUnauthorized"
layer="zope.publisher.interfaces.http.IHTTPRequest"
name="index.html"
/>

<browser:defaultView
for="zope.publisher.interfaces.http.IMethodNotAllowed"
layer="zope.publisher.interfaces.http.IHTTPRequest"
name="index.html"
/>

</configure>
3 changes: 0 additions & 3 deletions src/grokcore/rest/ftesting.zcml
Expand Up @@ -5,15 +5,12 @@
i18n_domain="grokcore.rest"
package="grokcore.rest">


<include package="zope.securitypolicy" />
<include package="zope.annotation" />
<include package="grokcore.view" file="ftesting.zcml" />
<include package="grokcore.view" file="publication_security.zcml" />
<include package="grokcore.rest" />

<include package="zope.app.http.exception" />

<browser:defaultView name="index.html" />
<grok:grok package=".ftests" />

Expand Down
42 changes: 37 additions & 5 deletions src/grokcore/rest/ftests/rest/rest.py
Expand Up @@ -5,7 +5,7 @@
>>> from zope.component import getMultiAdapter
>>> from grokcore.rest.rest import GrokMethodNotAllowed
>>> erview = getMultiAdapter((GrokMethodNotAllowed(None, None),
>>> erview = getMultiAdapter((GrokMethodNotAllowed(None, None),
... TestRequest()), name="index.html")
>>> erview
Expand Down Expand Up @@ -173,20 +173,44 @@
POST, PUT and DELETE however are not public::
>>> print http('POST /++rest++e/app/alpha HTTP/1.1')
>>> print http('POST /++rest++e/app/alpha HTTP/1.1', handle_errors=False)
Traceback (most recent call last):
...
Unauthorized: (<grokcore.rest.meta.SecurityRest object at 0x...>,
'__call__', 'zope.ManageContent')
XXX handle_errors should be set to True once we have a
[zope|grokcore].errorview package.
HTTP/1.0 401 Unauthorized
Content-Length: 0
Content-Type: text/plain
WWW-Authenticate: basic realm="Zope"
<BLANKLINE>
>>> print http('PUT /++rest++e/app/alpha HTTP/1.1')
>>> print http('PUT /++rest++e/app/alpha HTTP/1.1', handle_errors=False)
Traceback (most recent call last):
...
Unauthorized: (<grokcore.rest.meta.SecurityRest object at 0x...>,
'__call__', 'zope.ManageContent')
XXX handle_errors should be set to True once we have a
[zope|grokcore].errorview package.
HTTP/1.0 401 Unauthorized
Content-Length: 0
WWW-Authenticate: basic realm="Zope"
<BLANKLINE>
>>> print http('DELETE /++rest++e/app/alpha HTTP/1.1')
>>> print http('DELETE /++rest++e/app/alpha HTTP/1.1', handle_errors=False)
Traceback (most recent call last):
...
Unauthorized: (<grokcore.rest.meta.SecurityRest object at 0x...>,
'__call__', 'zope.ManageContent')
XXX handle_errors should be set to True once we have a
[zope|grokcore].errorview package.
HTTP/1.0 401 Unauthorized
Content-Length: 0
WWW-Authenticate: basic realm="Zope"
Expand Down Expand Up @@ -234,7 +258,15 @@
We shouldn't be allowed to PUT either::
>>> print http('PUT /app/beta HTTP/1.1')
>>> print http('PUT /app/beta HTTP/1.1', handle_errors=False)
Traceback (most recent call last):
...
NotFound: Object: <grokcore.rest.ftests.rest.rest.MyApp object at 0x...>,
name: u'beta'
XXX handle_errors should be set to True once we have a
[zope|grokcore].errorview package.
HTTP/1.0 404 Not Found
Content-Length: 0
Expand Down
4 changes: 1 addition & 3 deletions src/grokcore/rest/rest.py
Expand Up @@ -15,8 +15,7 @@
from zope.traversing.interfaces import TraversalError
from zope.traversing.namespace import view
from zope.interface import Interface
from zope.publisher.interfaces.http import IHTTPRequest
from zope.app.publication.http import MethodNotAllowed
from zope.publisher.interfaces.http import IHTTPRequest, MethodNotAllowed
from zope.publisher.browser import applySkin


Expand Down Expand Up @@ -64,7 +63,6 @@ def __call__(self):
self.request.response.setStatus(405)
return 'Method Not Allowed'


class rest_skin(view):
"""A rest skin.
Expand Down

0 comments on commit 50ea9c1

Please sign in to comment.