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
6b6c466a
Commit
6b6c466a
authored
Apr 15, 2002
by
Toby Dickenson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merged toby-metatype-branch
parent
104a7ae1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
27 deletions
+44
-27
lib/python/App/ProductContext.py
lib/python/App/ProductContext.py
+11
-1
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+33
-26
No files found.
lib/python/App/ProductContext.py
View file @
6b6c466a
...
...
@@ -44,7 +44,8 @@ class ProductContext:
def
registerClass
(
self
,
instance_class
=
None
,
meta_type
=
''
,
permission
=
None
,
constructors
=
(),
icon
=
None
,
permissions
=
None
,
legacy
=
(),
visibility
=
"Global"
,
interfaces
=
_marker
visibility
=
"Global"
,
interfaces
=
_marker
,
container_filter
=
None
):
"""Register a constructor
...
...
@@ -88,6 +89,13 @@ class ProductContext:
interfaces -- a list of the interfaces the object supports
container_filter -- function that is called with an ObjectManager
object as the only parameter, which should return a true object
if the object is happy to be created in that container. The
filter is called before showing ObjectManager's Add list,
and before pasting (after object copy or cut), but not
before calling an object's constructor.
"""
app
=
self
.
__app
pack
=
self
.
__pack
...
...
@@ -171,6 +179,7 @@ class ProductContext:
'visibility'
:
visibility
,
'interfaces'
:
interfaces
,
'instance'
:
instance_class
,
'container_filter'
:
container_filter
},)
m
[
name
]
=
initial
...
...
@@ -325,3 +334,4 @@ class ProductContext:
ht
=
APIHelpTopic
.
APIHelpTopic
(
file
,
''
,
os
.
path
.
join
(
path
,
file
))
self
.
registerHelpTopic
(
file
,
ht
)
lib/python/OFS/ObjectManager.py
View file @
6b6c466a
...
...
@@ -12,9 +12,9 @@
##############################################################################
__doc__
=
"""Object Manager
$Id: ObjectManager.py,v 1.1
49 2002/04/12 19:35:30 shane
Exp $"""
$Id: ObjectManager.py,v 1.1
50 2002/04/15 10:15:26 htrd
Exp $"""
__version__
=
'$Revision: 1.1
49
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
50
$'
[
11
:
-
2
]
import
App.Management
,
Acquisition
,
Globals
,
CopySupport
,
Products
import
os
,
App
.
FactoryDispatcher
,
re
,
Products
...
...
@@ -174,49 +174,56 @@ class ObjectManager(
default__class_init__
(
self
)
def
all_meta_types
(
self
,
interfaces
=
None
):
# A list of products registered elsewhere
external_candidates
=
[]
# Look at _product_meta_types, if there is one
_pmt
=
()
if
hasattr
(
self
,
'_product_meta_types'
):
_pmt
=
self
.
_product_meta_types
elif
hasattr
(
self
,
'aq_acquire'
):
try
:
_pmt
=
self
.
aq_acquire
(
'_product_meta_types'
)
except
:
pass
external_candidates
.
extend
(
list
(
_pmt
))
if
interfaces
is
None
:
pmt
=
list
(
_pmt
)
else
:
pmt
=
[]
# Look at all globally visible meta types.
for
entry
in
Products
.
meta_types
:
if
(
(
interfaces
is
not
None
)
or
(
entry
.
get
(
"visibility"
,
None
)
==
"Global"
)
):
external_candidates
.
append
(
entry
)
for
entry
in
pmt
:
# Filter the list of external candidates based on the
# specified interface constraint
if
interfaces
is
None
:
interface_constrained_meta_types
=
external_candidates
else
:
interface_constrained_meta_types
=
[]
for
entry
in
external_candidates
:
try
:
eil
=
entry
.
get
(
'interfaces'
,
None
)
if
eil
is
not
None
:
for
ei
in
eil
:
for
i
in
interfaces
:
if
ei
is
i
or
ei
.
extends
(
i
):
pmt
.
append
(
entry
)
interface_constrained_meta_types
.
append
(
entry
)
raise
BreakoutException
# only append 1ce
except
BreakoutException
:
pass
gmt
=
[]
for
entry
in
Products
.
meta_types
:
if
interfaces
is
None
:
if
entry
.
get
(
"visibility"
,
None
)
==
"Global"
:
gmt
.
append
(
entry
)
# Meta types specified by this instance are not checked against the
# interface constraint. This is as it always has been, but Im not
# sure it is correct.
interface_constrained_meta_types
.
extend
(
list
(
self
.
meta_types
))
# Filter the list based on each meta-types's container_filter
meta_types
=
[]
for
entry
in
interface_constrained_meta_types
:
container_filter
=
entry
.
get
(
'container_filter'
,
None
)
if
container_filter
is
None
:
meta_types
.
append
(
entry
)
else
:
try
:
eil
=
entry
.
get
(
"interfaces"
,
None
)
if
eil
is
not
None
:
for
ei
in
eil
:
for
i
in
interfaces
:
if
ei
is
i
or
ei
.
extends
(
i
):
gmt
.
append
(
entry
)
raise
BreakoutException
# only append 1ce
except
BreakoutException
:
pass
if
container_filter
(
self
):
meta_types
.
append
(
entry
)
return
list
(
self
.
meta_types
)
+
gmt
+
pmt
return
meta_types
def
_subobject_permissions
(
self
):
return
(
Products
.
__ac_permissions__
+
...
...
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