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
f01ca899
Commit
f01ca899
authored
Mar 23, 2004
by
Stuart Bishop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ObjectManager no longer raises string exceptions
parent
ba695b92
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
doc/CHANGES.txt
doc/CHANGES.txt
+2
-0
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+14
-16
No files found.
doc/CHANGES.txt
View file @
f01ca899
...
...
@@ -103,6 +103,8 @@ Zope Changes
Bugs fixed
- ObjectManager no longer raises string exceptions
- Collector #1260: Testing/__init__.py no longer changes the
INSTANCE_HOME.
...
...
lib/python/OFS/ObjectManager.py
View file @
f01ca899
...
...
@@ -12,9 +12,9 @@
##############################################################################
__doc__
=
"""Object Manager
$Id: ObjectManager.py,v 1.17
2 2004/03/17 23:51:23 urbanape
Exp $"""
$Id: ObjectManager.py,v 1.17
3 2004/03/23 06:51:13 Zen
Exp $"""
__version__
=
'$Revision: 1.17
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.17
3
$'
[
11
:
-
2
]
import
App.Management
,
Acquisition
,
Globals
,
CopySupport
,
Products
import
os
,
App
.
FactoryDispatcher
,
re
,
Products
...
...
@@ -49,8 +49,6 @@ customImporters={
bad_id
=
re
.
compile
(
r'[^a-zA-Z0-9-_~,.$\
(
\)# ]'
).
search
#TS
BadRequestException
=
'Bad Request'
def
checkValidId
(
self
,
id
,
allow_dup
=
0
):
# If allow_dup is false, an error will be raised if an object
# with the given id already exists. If allow_dup is true,
...
...
@@ -60,17 +58,17 @@ def checkValidId(self, id, allow_dup=0):
if
not
id
or
not
isinstance
(
id
,
StringType
):
if
isinstance
(
id
,
UnicodeType
):
id
=
escape
(
id
)
raise
BadRequest
Exception
,
(
'Empty or invalid id specified'
,
id
)
raise
BadRequest
,
(
'Empty or invalid id specified'
,
id
)
if
bad_id
(
id
)
is
not
None
:
raise
BadRequest
Exception
,
(
raise
BadRequest
,
(
'The id "%s" contains characters illegal in URLs.'
%
escape
(
id
))
if
id
in
(
'.'
,
'..'
):
raise
BadRequest
Exception
,
(
if
id
in
(
'.'
,
'..'
):
raise
BadRequest
,
(
'The id "%s" is invalid because it is not traversable.'
%
id
)
if
id
.
startswith
(
'_'
):
raise
BadRequest
Exception
,
(
if
id
.
startswith
(
'_'
):
raise
BadRequest
,
(
'The id "%s" is invalid because it begins with an underscore.'
%
id
)
if
id
.
startswith
(
'aq_'
):
raise
BadRequest
Exception
,
(
if
id
.
startswith
(
'aq_'
):
raise
BadRequest
,
(
'The id "%s" is invalid because it begins with "aq_".'
%
id
)
if
id
.
endswith
(
'__'
):
raise
BadRequest
Exception
,
(
if
id
.
endswith
(
'__'
):
raise
BadRequest
,
(
'The id "%s" is invalid because it ends with two underscores.'
%
id
)
if
not
allow_dup
:
obj
=
getattr
(
self
,
id
,
None
)
...
...
@@ -81,16 +79,16 @@ def checkValidId(self, id, allow_dup=0):
if
hasattr
(
aq_base
(
self
),
id
):
# The object is located in this ObjectManager.
if
not
flags
&
REPLACEABLE
:
raise
BadRequest
Exception
,
(
raise
BadRequest
,
(
'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
BadRequest
Exception
,
(
'The id "%s" is reserved.'
%
id
)
raise
BadRequest
,
(
'The id "%s" is reserved.'
%
id
)
if
id
==
'REQUEST'
:
raise
BadRequest
Exception
,
'REQUEST is a reserved name.'
raise
BadRequest
,
'REQUEST is a reserved name.'
if
'/'
in
id
:
raise
BadRequest
Exception
,
(
raise
BadRequest
,
(
'The id "%s" contains characters illegal in URLs.'
%
id
)
class
BeforeDeleteException
(
Exception
):
pass
# raise to veto deletion
...
...
@@ -528,7 +526,7 @@ class ObjectManager(
"""Import an object from a file"""
dirname
,
file
=
os
.
path
.
split
(
file
)
if
dirname
:
raise
BadRequest
Exception
,
'Invalid file name %s'
%
escape
(
file
)
raise
BadRequest
,
'Invalid file name %s'
%
escape
(
file
)
cfg
=
getConfiguration
()
for
impath
in
(
cfg
.
instancehome
,
cfg
.
zopehome
):
...
...
@@ -536,7 +534,7 @@ class ObjectManager(
if
os
.
path
.
exists
(
filepath
):
break
else
:
raise
BadRequest
Exception
,
'File does not exist: %s'
%
escape
(
file
)
raise
BadRequest
,
'File does not exist: %s'
%
escape
(
file
)
self
.
_importObjectFromFile
(
filepath
,
verify
=
not
not
REQUEST
,
set_owner
=
set_owner
)
...
...
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