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
e4f59104
Commit
e4f59104
authored
Jan 27, 2004
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge bindings fix
parent
2a2f650d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
13 deletions
+29
-13
lib/python/Shared/DC/Scripts/Bindings.py
lib/python/Shared/DC/Scripts/Bindings.py
+29
-13
No files found.
lib/python/Shared/DC/Scripts/Bindings.py
View file @
e4f59104
...
@@ -15,6 +15,7 @@ __version__='$Revision$'[11:-2]
...
@@ -15,6 +15,7 @@ __version__='$Revision$'[11:-2]
import
Globals
import
Globals
from
AccessControl
import
getSecurityManager
from
AccessControl
import
getSecurityManager
from
AccessControl.ZopeGuards
import
guarded_getattr
from
Persistence
import
Persistent
from
Persistence
import
Persistent
from
string
import
join
,
strip
from
string
import
join
,
strip
import
re
import
re
...
@@ -161,19 +162,26 @@ class UnauthorizedBinding:
...
@@ -161,19 +162,26 @@ class UnauthorizedBinding:
actually using the container binding (for ex. workflow scripts)
actually using the container binding (for ex. workflow scripts)
need to take explicit action to fix existing sites."""
need to take explicit action to fix existing sites."""
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
,
wrapped
):
self
.
_name
=
name
self
.
_name
=
name
self
.
_wrapped
=
wrapped
__allow_access_to_unprotected_subobjects__
=
1
__allow_access_to_unprotected_subobjects__
=
1
def
__getattr__
(
self
,
name
,
default
=
None
):
def
__getattr__
(
self
,
name
,
default
=
None
):
name
=
self
.
__dict__
[
'_name'
]
raise
Unauthorized
(
'Not authorized to access binding: %s'
%
name
)
def
__getitem__
(
self
,
key
,
default
=
None
):
# Make *extra* sure that the wrapper isn't used to access
# __call__, __str__, __repr__, etc.
if
name
.
startswith
(
'__'
):
self
.
__you_lose
()
return
guarded_getattr
(
self
.
_wrapped
,
name
,
default
)
def
__you_lose
(
self
):
name
=
self
.
__dict__
[
'_name'
]
name
=
self
.
__dict__
[
'_name'
]
raise
Unauthorized
(
'Not authorized to access binding: %s'
%
name
)
raise
Unauthorized
(
'Not authorized to access binding: %s'
%
name
)
__str__
=
__call__
=
index_html
=
__you_lose
class
Bindings
:
class
Bindings
:
...
@@ -256,7 +264,7 @@ class Bindings:
...
@@ -256,7 +264,7 @@ class Bindings:
container
=
getattr
(
inner
,
'aq_parent'
,
None
)
container
=
getattr
(
inner
,
'aq_parent'
,
None
)
try
:
getSecurityManager
().
validate
(
parent
,
container
,
''
,
self
)
try
:
getSecurityManager
().
validate
(
parent
,
container
,
''
,
self
)
except
Unauthorized
:
except
Unauthorized
:
return
UnauthorizedBinding
(
'context'
)
return
UnauthorizedBinding
(
'context'
,
self
)
return
self
return
self
def
_getContainer
(
self
):
def
_getContainer
(
self
):
...
@@ -269,7 +277,7 @@ class Bindings:
...
@@ -269,7 +277,7 @@ class Bindings:
container
=
getattr
(
inner
,
'aq_parent'
,
None
)
container
=
getattr
(
inner
,
'aq_parent'
,
None
)
try
:
getSecurityManager
().
validate
(
parent
,
container
,
''
,
self
)
try
:
getSecurityManager
().
validate
(
parent
,
container
,
''
,
self
)
except
Unauthorized
:
except
Unauthorized
:
return
UnauthorizedBinding
(
'container'
)
return
UnauthorizedBinding
(
'container'
,
self
)
return
self
return
self
def
_getTraverseSubpath
(
self
):
def
_getTraverseSubpath
(
self
):
...
@@ -320,10 +328,18 @@ class Bindings:
...
@@ -320,10 +328,18 @@ class Bindings:
bindcode
=
getattr
(
self
,
'_v_bindcode'
,
_marker
)
bindcode
=
getattr
(
self
,
'_v_bindcode'
,
_marker
)
if
bindcode
is
_marker
:
if
bindcode
is
_marker
:
bindcode
=
self
.
_prepareBindCode
()
bindcode
=
self
.
_prepareBindCode
()
if
bindcode
is
None
:
bound_data
=
{}
# Execute the script in a new security context (including the
else
:
# bindings preparation).
bound_data
=
[]
security
=
getSecurityManager
()
exec
bindcode
security
.
addContext
(
self
)
bound_data
=
bound_data
[
0
]
try
:
return
self
.
_exec
(
bound_data
,
args
,
kw
)
if
bindcode
is
None
:
bound_data
=
{}
else
:
bound_data
=
[]
exec
bindcode
bound_data
=
bound_data
[
0
]
return
self
.
_exec
(
bound_data
,
args
,
kw
)
finally
:
security
.
removeContext
(
self
)
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