Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
add SOAPAccess permission
Browse files Browse the repository at this point in the history
  • Loading branch information
jfroche committed Nov 14, 2008
1 parent b1aef49 commit 0815b16
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 26 deletions.
1 change: 1 addition & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ eggs =
z3c.soap

zcml =
z3c.soap
z3c.soap-meta

[test]
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
zip_safe=False,
install_requires=[
'setuptools',
'Products.CMFCore==2.1.1',
'Products.PluggableAuthService==1.5.3',
'ZSI'],
entry_points="""
Expand Down
3 changes: 2 additions & 1 deletion z3c/soap/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ view for folder objects and call it on the root folder:
...
... <include package="z3c.soap" file="meta.zcml" />
... <include package="Products.Five" file="meta.zcml" />
... <include package="z3c.soap"/>
...
... <soap:view
... for="OFS.interfaces.IFolder"
... methods="echoString echoStringArray echoInteger echoIntegerArray
... echoFloat echoFloatArray echoStruct echoVoid echoBase64
... echoDate echoDecimal echoBoolean ValidateEmailRequest"
... class="z3c.soap.README.EchoView"
... permission="cmf.ManageProperties"
... permission="zope2.SOAPAccess"
... />
...
... <utility
Expand Down
1 change: 1 addition & 0 deletions z3c/soap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# This is a Python package.
import HTTPRequest
from patch import *
from permissions import *
9 changes: 9 additions & 0 deletions z3c/soap/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<configure xmlns="http://namespaces.zope.org/zope"
i18n_domain="z3c.soap">

<permission
id="zope2.SOAPAccess"
title="SOAP Access"/>

</configure>

25 changes: 1 addition & 24 deletions z3c/soap/metaconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"""

from zope.interface import Interface
from zope.security.checker import CheckerPublic #, Checker
#from zope.location import Location
from zope.security.checker import CheckerPublic
from zope.component.interface import provideInterface
from Products.Five.security import protectClass, protectName
from zope.app.publisher.browser.viewmeta import _handle_for
Expand Down Expand Up @@ -64,19 +63,6 @@ def view(_context, for_=None, interface=None, methods=None,
cdict = getSecurityInfo(class_)

if name:
# Register a single view
# if permission:
# checker = Checker(require)
#
# def proxyView(context, request, class_=class_, checker=checker):
# view = class_(context, request)
# # We need this in case the resource gets unwrapped and
# # needs to be rewrapped
# view.__Security_checker__ = checker
# return view
#
# class_ = proxyView
cdict = getSecurityInfo(class_)
cdict['__name__'] = name
new_class = makeClass(class_.__name__,
(class_, BrowserView), cdict)
Expand Down Expand Up @@ -115,22 +101,13 @@ def view(_context, for_=None, interface=None, methods=None,
args = (new_class, attr, CheckerPrivateId))

else:
# if permission:
# checker = Checker({'__call__': permission})
# else:
for name in require:
# create a new callable class with a security checker; mix
# in zope.app.location.Location so that the view inherits
# a security context
cdict.update({'__page_attribute__': name,
'__name__': name})
new_class = makeClass(class_.__name__,
(class_, ViewMixinForAttributes),
cdict)

# in case the attribute does not provide a docstring,
# ZPublisher refuses to publish it. So, as a workaround,
# we provide a stub docstring
func = getattr(new_class, name)
if not func.__doc__:
# cannot test for MethodType/UnboundMethod here
Expand Down
18 changes: 18 additions & 0 deletions z3c/soap/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
"""
z3c.soap
Licensed under the GPL license, see LICENCE.txt for more details.
Copyright by Affinitic sprl
$Id$
"""
from AccessControl import ModuleSecurityInfo
from Products.CMFCore.permissions import setDefaultRoles


security = ModuleSecurityInfo('z3c.soap.permissions')

security.declarePublic('SOAP Access')
SoapAccess = 'SOAP Access'
setDefaultRoles(SoapAccess, ('Authenticated', ))
2 changes: 1 addition & 1 deletion z3c/soap/tests/soap.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<include package="z3c.soap" file="meta.zcml"/>
<include package="zope.app.security" file="meta.zcml"/>

<include package="z3c.soap" />
<soap:view
name="test"
class="zope.app.component.tests.views.V1"
Expand Down

0 comments on commit 0815b16

Please sign in to comment.