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
b5633ae4
Commit
b5633ae4
authored
Aug 01, 2011
by
Nikolay Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
micro optimization
parent
482a309b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
+17
-15
src/OFS/ObjectManager.py
src/OFS/ObjectManager.py
+2
-2
src/OFS/Traversable.py
src/OFS/Traversable.py
+3
-5
src/Products/PageTemplates/Expressions.py
src/Products/PageTemplates/Expressions.py
+1
-1
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+11
-7
No files found.
src/OFS/ObjectManager.py
View file @
b5633ae4
...
@@ -425,7 +425,7 @@ class ObjectManager(CopyContainer,
...
@@ -425,7 +425,7 @@ class ObjectManager(CopyContainer,
# Returns a list of actual subobjects of the current object.
# Returns a list of actual subobjects of the current object.
# If 'spec' is specified, returns only objects whose meta_type
# If 'spec' is specified, returns only objects whose meta_type
# match 'spec'.
# match 'spec'.
return
[
self
.
_getOb
(
id
)
for
id
in
self
.
objectIds
(
spec
)
]
return
[
getattr
(
self
,
id
)
for
id
in
self
.
objectIds
(
spec
)
]
security
.
declareProtected
(
access_contents_information
,
'objectItems'
)
security
.
declareProtected
(
access_contents_information
,
'objectItems'
)
def
objectItems
(
self
,
spec
=
None
):
def
objectItems
(
self
,
spec
=
None
):
...
@@ -763,7 +763,7 @@ class ObjectManager(CopyContainer,
...
@@ -763,7 +763,7 @@ class ObjectManager(CopyContainer,
return
self
.
manage_delObjects
(
ids
=
[
name
])
return
self
.
manage_delObjects
(
ids
=
[
name
])
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
v
=
self
.
_getOb
(
key
,
None
)
v
=
getattr
(
self
,
key
,
None
)
if
v
is
not
None
:
return
v
if
v
is
not
None
:
return
v
if
hasattr
(
self
,
'REQUEST'
):
if
hasattr
(
self
,
'REQUEST'
):
request
=
self
.
REQUEST
request
=
self
.
REQUEST
...
...
src/OFS/Traversable.py
View file @
b5633ae4
...
@@ -153,17 +153,16 @@ class Traversable:
...
@@ -153,17 +153,16 @@ class Traversable:
path
=
list
(
path
)
path
=
list
(
path
)
REQUEST
=
{
'TraversalRequestNameStack'
:
path
}
REQUEST
=
{
'TraversalRequestNameStack'
:
path
}
#path.reverse()
path_pop
=
path
.
pop
path_pop
=
path
.
pop
if
len
(
path
)
>
1
and
not
path
[
-
1
]:
if
not
path
[
-
1
]:
# Remove trailing slash
# Remove trailing slash
path_pop
()
path_pop
()
if
restricted
:
if
restricted
:
validate
=
getSecurityManager
().
validate
validate
=
getSecurityManager
().
validate
if
not
path
[
0
]:
if
path
and
not
path
[
0
]:
# If the path starts with an empty string, go to the root first.
# If the path starts with an empty string, go to the root first.
path_pop
(
0
)
path_pop
(
0
)
obj
=
self
.
getPhysicalRoot
()
obj
=
self
.
getPhysicalRoot
()
...
@@ -189,7 +188,7 @@ class Traversable:
...
@@ -189,7 +188,7 @@ class Traversable:
obj
=
next
obj
=
next
continue
continue
bobo_traverse
=
None
bobo_traverse
=
getattr
(
obj
,
'__bobo_traverse__'
,
None
)
try
:
try
:
if
name
and
name
[:
1
]
in
'@+'
and
name
!=
'+'
and
nsParse
(
name
)[
1
]:
if
name
and
name
[:
1
]
in
'@+'
and
name
!=
'+'
and
nsParse
(
name
)[
1
]:
# Process URI segment parameters.
# Process URI segment parameters.
...
@@ -208,7 +207,6 @@ class Traversable:
...
@@ -208,7 +207,6 @@ class Traversable:
else
:
else
:
next
=
UseTraversalDefault
# indicator
next
=
UseTraversalDefault
# indicator
try
:
try
:
bobo_traverse
=
getattr
(
obj
,
'__bobo_traverse__'
,
None
)
if
bobo_traverse
is
not
None
:
if
bobo_traverse
is
not
None
:
next
=
bobo_traverse
(
REQUEST
,
name
)
next
=
bobo_traverse
(
REQUEST
,
name
)
if
restricted
:
if
restricted
:
...
...
src/Products/PageTemplates/Expressions.py
View file @
b5633ae4
...
@@ -71,7 +71,7 @@ def boboAwareZopeTraverse(object, path_items, econtext):
...
@@ -71,7 +71,7 @@ def boboAwareZopeTraverse(object, path_items, econtext):
while
path_items
:
while
path_items
:
name
=
path_items
.
pop
()
name
=
path_items
.
pop
()
if
OFS
.
interfaces
.
ITraversable
.
providedBy
(
object
):
if
OFS
.
interfaces
.
ITraversable
.
providedBy
(
object
):
object
=
object
.
restrictedTraverse
(
nam
e
)
object
=
object
.
unrestrictedTraverse
(
name
,
restricted
=
Tru
e
)
else
:
else
:
object
=
traversePathElement
(
object
,
name
,
path_items
,
object
=
traversePathElement
(
object
,
name
,
path_items
,
request
=
request
)
request
=
request
)
...
...
src/ZPublisher/HTTPRequest.py
View file @
b5633ae4
...
@@ -169,6 +169,9 @@ class HTTPRequest(BaseRequest):
...
@@ -169,6 +169,9 @@ class HTTPRequest(BaseRequest):
retry_max_count
=
3
retry_max_count
=
3
def
__conform__
(
self
,
iface
):
return
iface
.
__adapt__
(
self
)
def
supports_retry
(
self
):
def
supports_retry
(
self
):
if
self
.
retry_count
<
self
.
retry_max_count
:
if
self
.
retry_count
<
self
.
retry_max_count
:
time
.
sleep
(
random
.
uniform
(
0
,
2
**
(
self
.
retry_count
)))
time
.
sleep
(
random
.
uniform
(
0
,
2
**
(
self
.
retry_count
)))
...
@@ -254,11 +257,11 @@ class HTTPRequest(BaseRequest):
...
@@ -254,11 +257,11 @@ class HTTPRequest(BaseRequest):
def
physicalPathToURL
(
self
,
path
,
relative
=
0
):
def
physicalPathToURL
(
self
,
path
,
relative
=
0
):
""" Convert a physical path into a URL in the current context """
""" Convert a physical path into a URL in the current context """
path
=
self
.
_script
+
map
(
quote
,
self
.
physicalPathToVirtualPath
(
path
))
path
=
self
.
_script
+
[
quote
(
s
)
for
s
in
self
.
physicalPathToVirtualPath
(
path
)]
if
relative
:
if
relative
:
path
.
insert
(
0
,
''
)
path
.
insert
(
0
,
''
)
else
:
else
:
path
.
insert
(
0
,
self
[
'SERVER_URL'
])
path
.
insert
(
0
,
self
.
other
[
'SERVER_URL'
])
return
'/'
.
join
(
path
)
return
'/'
.
join
(
path
)
def
physicalPathFromURL
(
self
,
URL
):
def
physicalPathFromURL
(
self
,
URL
):
...
@@ -338,7 +341,7 @@ class HTTPRequest(BaseRequest):
...
@@ -338,7 +341,7 @@ class HTTPRequest(BaseRequest):
self
.
steps
=
[]
self
.
steps
=
[]
self
.
_steps
=
[]
self
.
_steps
=
[]
self
.
_lazies
=
{}
self
.
_lazies
=
{}
self
.
_
debug
=
DebugFlags
()
self
.
debug
=
DebugFlags
()
# We don't set up the locale initially but just on first access
# We don't set up the locale initially but just on first access
self
.
_locale
=
_marker
self
.
_locale
=
_marker
...
@@ -450,6 +453,9 @@ class HTTPRequest(BaseRequest):
...
@@ -450,6 +453,9 @@ class HTTPRequest(BaseRequest):
self
.
cookies
=
cookies
self
.
cookies
=
cookies
self
.
taintedcookies
=
taintedcookies
self
.
taintedcookies
=
taintedcookies
def
__nonzero__
(
self
):
return
True
def
processInputs
(
def
processInputs
(
self
,
self
,
# "static" variables that we want to be local for speed
# "static" variables that we want to be local for speed
...
@@ -1251,7 +1257,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1251,7 +1257,7 @@ class HTTPRequest(BaseRequest):
categories. The search order is environment variables,
categories. The search order is environment variables,
other variables, form data, and then cookies.
other variables, form data, and then cookies.
"""
#"
"""
other
=
self
.
other
other
=
self
.
other
if
key
in
other
:
if
key
in
other
:
return
other
[
key
]
return
other
[
key
]
...
@@ -1379,8 +1385,6 @@ class HTTPRequest(BaseRequest):
...
@@ -1379,8 +1385,6 @@ class HTTPRequest(BaseRequest):
if
self
.
_locale
is
_marker
:
if
self
.
_locale
is
_marker
:
self
.
setupLocale
()
self
.
setupLocale
()
return
self
.
_locale
return
self
.
_locale
if
key
==
'debug'
:
return
self
.
_debug
raise
AttributeError
,
key
raise
AttributeError
,
key
return
v
return
v
...
@@ -1517,7 +1521,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1517,7 +1521,7 @@ class HTTPRequest(BaseRequest):
base64
.
decodestring
(
auth
.
split
()[
-
1
]).
split
(
':'
,
1
)
base64
.
decodestring
(
auth
.
split
()[
-
1
]).
split
(
':'
,
1
)
return
name
,
password
return
name
,
password
def
taintWrapper
(
self
,
enabled
=
False
):
def
taintWrapper
(
self
,
enabled
=
TAINTING_ENABLED
):
return
enabled
and
TaintRequestWrapper
(
self
)
or
self
return
enabled
and
TaintRequestWrapper
(
self
)
or
self
def
shiftNameToApplication
(
self
):
def
shiftNameToApplication
(
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