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
96fb65c6
Commit
96fb65c6
authored
Jun 15, 2011
by
Nikolay Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize access to product packages
parent
28347c19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
src/App/FactoryDispatcher.py
src/App/FactoryDispatcher.py
+15
-7
No files found.
src/App/FactoryDispatcher.py
View file @
96fb65c6
...
...
@@ -32,16 +32,17 @@ def _product_packages():
zope2 packages and those without the Products namespace package.
"""
import
Products
packages
=
{}
_packages
=
{}
for
x
in
dir
(
Products
):
m
=
getattr
(
Products
,
x
)
if
isinstance
(
m
,
types
.
ModuleType
):
packages
[
x
]
=
m
_
packages
[
x
]
=
m
for
m
in
get_registered_packages
():
packages
[
m
.
__name__
]
=
m
_
packages
[
m
.
__name__
]
=
m
return
packages
return
_
packages
class
Product
(
Base
):
...
...
@@ -85,8 +86,15 @@ class ProductDispatcher(Implicit):
def
__bobo_traverse__
(
self
,
REQUEST
,
name
):
# Try to get a custom dispatcher from a Python product
global
_packages
try
:
package
=
_packages
.
get
(
name
,
None
)
except
NameError
:
_packages
=
_product_packages
()
package
=
_packages
.
get
(
name
,
None
)
dispatcher_class
=
getattr
(
_product_packages
().
get
(
name
,
None
)
,
package
,
'__FactoryDispatcher__'
,
FactoryDispatcher
)
...
...
@@ -139,7 +147,7 @@ class FactoryDispatcher(Implicit):
def
__getattr__
(
self
,
name
):
p
=
self
.
__dict__
[
'_product'
]
d
=
p
.
__dict__
if
hasattr
(
p
,
name
)
and
d
.
has_key
(
name
)
:
if
hasattr
(
p
,
name
)
and
name
in
d
:
m
=
d
[
name
]
w
=
getattr
(
m
,
'_permissionMapper'
,
None
)
if
w
is
not
None
:
...
...
@@ -149,7 +157,7 @@ class FactoryDispatcher(Implicit):
# Waaa
m
=
'Products.%s'
%
p
.
id
if
sys
.
modules
.
has_key
(
m
)
and
sys
.
modules
[
m
].
_m
.
has_key
(
name
):
if
m
in
sys
.
modules
and
sys
.
modules
[
m
].
_m
.
has_key
(
name
):
return
sys
.
modules
[
m
].
_m
[
name
]
raise
AttributeError
,
name
...
...
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