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
b5d92f77
Commit
b5d92f77
authored
Aug 14, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some more places to check for `__parent__`.
parent
2e99e17c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
src/App/Common.py
src/App/Common.py
+5
-5
src/Products/PageTemplates/PageTemplate.py
src/Products/PageTemplates/PageTemplate.py
+5
-3
No files found.
src/App/Common.py
View file @
b5d92f77
...
...
@@ -16,7 +16,7 @@ import os
import
sys
import
time
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
,
aq_parent
# BBB
from
os.path
import
realpath
# NOQA
...
...
@@ -83,11 +83,11 @@ def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr):
# Note that this method is misnamed since parents can (and do)
# spoof it. It is not a true measure of whether something is
# acquired, it relies on the parent's parent-ness exclusively
if
not
hasattr
(
ob
,
'
aq_parent
'
):
# We can't be acquired if we don't have an
aq_parent
if
not
hasattr
(
ob
,
'
__parent__
'
):
# We can't be acquired if we don't have an
__parent__
return
0
parent
=
aq_base
(
ob
.
aq_parent
)
parent
=
aq_base
(
aq_parent
(
ob
)
)
absId
=
absattr
(
ob
.
id
)
if
hasattr
(
parent
,
absId
):
...
...
@@ -100,7 +100,7 @@ def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr):
try
:
# We assume that getitem will not acquire which
# is the standard behavior for Zope objects
if
aq_base
(
ob
.
aq_parent
[
absId
])
is
aq_base
(
ob
):
if
aq_base
(
aq_parent
(
ob
)
[
absId
])
is
aq_base
(
ob
):
# This object is an item of the aq_parent, its not acquired
return
0
except
KeyError
:
...
...
src/Products/PageTemplates/PageTemplate.py
View file @
b5d92f77
...
...
@@ -14,6 +14,8 @@
"""
import
sys
from
Acquisition
import
aq_base
import
ExtensionClass
import
zope.pagetemplate.pagetemplate
from
zope.pagetemplate.pagetemplate
import
PTRuntimeError
...
...
@@ -35,14 +37,14 @@ class PageTemplate(ExtensionClass.Base,
'request'
:
None
,
'modules'
:
SimpleModuleImporter
(),
}
parent
=
getattr
(
self
,
'
aq_parent
'
,
None
)
parent
=
getattr
(
self
,
'
__parent__
'
,
None
)
if
parent
is
not
None
:
c
[
'here'
]
=
parent
c
[
'context'
]
=
parent
c
[
'container'
]
=
self
.
aq_inner
.
aq_parent
while
parent
is
not
None
:
self
=
parent
parent
=
getattr
(
self
,
'
aq_parent
'
,
None
)
parent
=
getattr
(
self
,
'
__parent__
'
,
None
)
c
[
'root'
]
=
self
return
c
...
...
@@ -119,6 +121,6 @@ class PageTemplate(ExtensionClass.Base,
# implementation had this as well, but arguably on the wrong class
# (this should be a ZopePageTemplate thing if at all)
def
html
(
self
):
if
not
hasattr
(
getattr
(
self
,
'aq_base'
,
self
),
'is_html'
):
if
not
hasattr
(
aq_base
(
self
),
'is_html'
):
return
self
.
content_type
==
'text/html'
return
self
.
is_html
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