Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
644f8279
Commit
644f8279
authored
Jul 10, 2010
by
Martin Aspeli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for the 'permission' attribute to browser:view
parent
46d57afe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
11 deletions
+69
-11
src/Products/Five/browser/metaconfigure.py
src/Products/Five/browser/metaconfigure.py
+37
-9
src/Products/Five/browser/tests/pages.txt
src/Products/Five/browser/tests/pages.txt
+23
-1
src/Products/Five/browser/tests/pages.zcml
src/Products/Five/browser/tests/pages.zcml
+9
-1
No files found.
src/Products/Five/browser/metaconfigure.py
View file @
644f8279
...
@@ -201,15 +201,7 @@ class view(zope.app.publisher.browser.viewmeta.view):
...
@@ -201,15 +201,7 @@ class view(zope.app.publisher.browser.viewmeta.view):
):
):
if
permission
is
None
:
if
permission
is
None
:
permission
=
'zope.Public'
permission
=
'zope.Public'
elif
permission
in
(
'zope.Public'
,
'zope2.Public'
):
# No need to warn about the default case
pass
else
:
warnings
.
warn
(
"The permission option of the <browser:view /> "
"directive is not supported in Zope 2. "
+
\
"Ignored for %s in %s"
%
(
str
(
class_
),
_context
.
info
),
stacklevel
=
3
)
super
(
view
,
self
).
__init__
(
super
(
view
,
self
).
__init__
(
_context
,
for_
,
permission
,
name
=
name
,
layer
=
layer
,
_context
,
for_
,
permission
,
name
=
name
,
layer
=
layer
,
class_
=
class_
,
allowed_interface
=
allowed_interface
,
class_
=
class_
,
allowed_interface
=
allowed_interface
,
...
@@ -314,6 +306,42 @@ class view(zope.app.publisher.browser.viewmeta.view):
...
@@ -314,6 +306,42 @@ class view(zope.app.publisher.browser.viewmeta.view):
newclass
,
(
for_
,
layer
),
self
.
provides
,
name
,
newclass
,
(
for_
,
layer
),
self
.
provides
,
name
,
_context
.
info
),
_context
.
info
),
)
)
# Security
_context
.
action
(
discriminator
=
(
'five:protectClass'
,
newclass
),
callable
=
protectClass
,
args
=
(
newclass
,
permission
)
)
if
allowed_attributes
:
for
attr
in
allowed_attributes
:
_context
.
action
(
discriminator
=
(
'five:protectName'
,
newclass
,
attr
),
callable
=
protectName
,
args
=
(
newclass
,
attr
,
permission
)
)
# Make everything else private
allowed
=
allowed_attributes
or
[]
private_attrs
=
[
name
for
name
in
dir
(
newclass
)
if
(
not
name
.
startswith
(
'_'
))
and
(
name
not
in
allowed
)
and
ismethod
(
getattr
(
newclass
,
name
))]
for
attr
in
private_attrs
:
_context
.
action
(
discriminator
=
(
'five:protectName'
,
newclass
,
attr
),
callable
=
protectName
,
args
=
(
newclass
,
attr
,
CheckerPrivateId
)
)
# Protect the class
_context
.
action
(
discriminator
=
(
'five:initialize:class'
,
newclass
),
callable
=
InitializeClass
,
args
=
(
newclass
,)
)
_factory_map
=
{
'image'
:{
'prefix'
:
'ImageResource'
,
_factory_map
=
{
'image'
:{
'prefix'
:
'ImageResource'
,
'count'
:
0
,
'count'
:
0
,
...
...
src/Products/Five/browser/tests/pages.txt
View file @
644f8279
...
@@ -253,12 +253,34 @@ C methods work the same
...
@@ -253,12 +253,34 @@ C methods work the same
>>> aq_parent(aq_inner(context))
>>> aq_parent(aq_inner(context))
<Folder at /test_folder_1_>
<Folder at /test_folder_1_>
The same applies to a view registered with <browser:view /> instead of
<browser:page />
>>> request = TestRequest()
>>> view = getMultiAdapter((self.folder.testoid, request), name=u'permission_view')
>>> view.__ac_permissions__
(('View management screens', ('',)),)
>>> aq_acquire(view, '__roles__')
('Manager',)
>>> context = view.context
>>> from Acquisition import ImplicitAcquisitionWrapper
>>> type(context) == ImplicitAcquisitionWrapper
True
>>> view.__parent__ == view.context
True
>>> aq_parent(view) == view.context
True
>>> context.aq_inner.aq_parent
<Folder at /test_folder_1_>
>>> aq_parent(aq_inner(context))
<Folder at /test_folder_1_>
High-level security
High-level security
-------------------
-------------------
>>> protected_view_names = [
>>> protected_view_names = [
... 'eagle.txt', 'falcon.html', 'owl.html', 'flamingo.html',
... 'eagle.txt', 'falcon.html', 'owl.html', 'flamingo.html',
... 'condor.html']
... 'condor.html'
, 'permission_view'
]
>>>
>>>
>>> public_view_names = [
>>> public_view_names = [
... 'public_attribute_page',
... 'public_attribute_page',
...
...
src/Products/Five/browser/tests/pages.zcml
View file @
644f8279
...
@@ -232,7 +232,15 @@
...
@@ -232,7 +232,15 @@
class=".pages.SimpleView"
class=".pages.SimpleView"
permission="zope2.Public"
permission="zope2.Public"
/>
/>
<!-- A named view with permissions -->
<browser:view
name="permission_view"
for="Products.Five.tests.testing.simplecontent.ISimpleContent"
class=".pages.CallView"
permission="zope2.ViewManagementScreens"
/>
<!-- stuff that we'll override in overrides.zcml -->
<!-- stuff that we'll override in overrides.zcml -->
<browser:page
<browser:page
for="Products.Five.tests.testing.simplecontent.ISimpleContent"
for="Products.Five.tests.testing.simplecontent.ISimpleContent"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment