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
3c7c83e9
Commit
3c7c83e9
authored
Aug 15, 2000
by
Shane Hathaway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turned __replaceable__ property into bit flags, allowing an object to be
both unique and replaceable.
parent
b738a136
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+11
-9
No files found.
lib/python/OFS/ObjectManager.py
View file @
3c7c83e9
...
...
@@ -84,9 +84,9 @@
##############################################################################
__doc__
=
"""Object Manager
$Id: ObjectManager.py,v 1.10
6 2000/08/08 17:15:10 chrism
Exp $"""
$Id: ObjectManager.py,v 1.10
7 2000/08/15 21:19:56 shane
Exp $"""
__version__
=
'$Revision: 1.10
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.10
7
$'
[
11
:
-
2
]
import
App.Management
,
Acquisition
,
Globals
,
CopySupport
,
Products
import
os
,
App
.
FactoryDispatcher
,
ts_regex
,
Products
...
...
@@ -111,10 +111,10 @@ customImporters={
bad_id
=
ts_regex
.
compile
(
'[^a-zA-Z0-9-_~
\
,
\
. ]'
).
search
#TS
# Global constants: __replaceable__
state
s (see ObjectManager._checkId):
# Global constants: __replaceable__
flag
s (see ObjectManager._checkId):
NOT_REPLACEABLE
=
0
REPLACEABLE
=
1
UNIQUE
=
-
1
UNIQUE
=
2
class
BeforeDeleteException
(
Exception
):
pass
# raise to veto deletion
...
...
@@ -229,15 +229,17 @@ class ObjectManager(
if
obj
is
not
None
:
# An object by the given id exists either in this
# ObjectManager or in the acquisition path.
flag
=
getattr
(
obj
,
'__replaceable__'
,
NOT_REPLACEABLE
)
if
flag
==
UNIQUE
:
raise
'Bad Request'
,
\
(
'The id "%s" is reserved by another object.'
%
id
)
flags
=
getattr
(
obj
,
'__replaceable__'
,
NOT_REPLACEABLE
)
if
hasattr
(
aq_base
(
self
),
id
):
# The object is located in this ObjectManager.
if
flag
!=
REPLACEABLE
:
if
not
flags
&
REPLACEABLE
:
raise
'Bad Request'
,
(
'The id "%s" is invalid - '
\
'it is already in use.'
%
id
)
# else the object is replaceable even if the UNIQUE
# flag is set.
elif
flags
&
UNIQUE
:
raise
'Bad Request'
,
\
(
'The id "%s" is reserved.'
%
id
)
if
id
==
'REQUEST'
:
raise
'Bad Request'
,
'REQUEST is a reserved name.'
if
'/'
in
id
:
...
...
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