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
52026276
Commit
52026276
authored
Dec 22, 2000
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make __careful_getattr__ simpler and a little more efficient
parent
51b3ff6c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
lib/python/Products/PythonScripts/Guarded.py
lib/python/Products/PythonScripts/Guarded.py
+7
-7
No files found.
lib/python/Products/PythonScripts/Guarded.py
View file @
52026276
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
from
zbytecodehacks.VSExec
import
SafeBlock
,
GuardedBinaryOps
,
\
UntupleFunction
,
RedirectWrites
,
WriteGuard
,
RedirectReads
,
ReadGuard
,
\
...
...
@@ -131,18 +131,18 @@ safebin['same_type'] = same_type
_marker
=
[]
# Create a new marker object.
def
aq_validate
(
*
args
):
return
apply
(
getSecurityManager
().
validate
,
args
[:
4
]
)
def
aq_validate
(
inst
,
obj
,
name
,
v
,
validate
):
return
validate
(
inst
,
obj
,
name
,
v
)
def
__careful_getattr__
(
inst
,
name
,
default
=
_marker
):
if
name
[:
1
]
!=
'_'
:
try
:
# Try to get the attribute normally so that we don't
# accidentally acquire when we shouldn't.
v
=
getattr
(
inst
,
name
)
# Filter out the objects we can't access.
if
hasattr
(
inst
,
'aq_acquire'
):
return
inst
.
aq_acquire
(
name
,
aq_validate
)
return
inst
.
aq_acquire
(
name
,
aq_validate
,
getSecurityManager
().
validate
)
# Or just try to get the attribute directly.
v
=
getattr
(
inst
,
name
)
except
AttributeError
:
if
default
is
not
_marker
:
return
default
...
...
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