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
39033d38
Commit
39033d38
authored
Aug 28, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise BadRequest instead of returning MessageDialog.
parent
0947e7fd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
97 deletions
+30
-97
CHANGES.rst
CHANGES.rst
+2
-0
src/OFS/ObjectManager.py
src/OFS/ObjectManager.py
+2
-9
src/OFS/role.py
src/OFS/role.py
+8
-22
src/OFS/userfolder.py
src/OFS/userfolder.py
+17
-59
src/Products/SiteAccess/VirtualHostMonster.py
src/Products/SiteAccess/VirtualHostMonster.py
+1
-7
No files found.
CHANGES.rst
View file @
39033d38
...
...
@@ -30,6 +30,8 @@ Features Added
Restructuring
+++++++++++++
- Raise BadRequest instead of returning MessageDialog.
- Remove property management ZMI screens.
- Remove ZMI copy/cut/paste/rename and re-ordering features.
...
...
src/OFS/ObjectManager.py
View file @
39033d38
...
...
@@ -37,7 +37,6 @@ from Acquisition import aq_base, aq_parent
from
Acquisition
import
Implicit
from
App.Common
import
is_acquired
from
App.config
import
getConfiguration
from
App.Dialogs
import
MessageDialog
from
App.FactoryDispatcher
import
ProductDispatcher
from
App.Management
import
Navigation
from
App.Management
import
Tabs
...
...
@@ -522,20 +521,14 @@ class ObjectManager(CopyContainer,
if
isinstance
(
ids
,
basestring
):
ids
=
[
ids
]
if
not
ids
:
return
MessageDialog
(
title
=
'No items specified'
,
message
=
'No items were specified!'
,
action
=
'./manage_main'
,)
raise
BadRequest
(
'No items specified'
)
try
:
p
=
self
.
_reserved_names
except
:
p
=
()
for
n
in
ids
:
if
n
in
p
:
return
MessageDialog
(
title
=
'Not Deletable'
,
message
=
'<EM>%s</EM> cannot be deleted.'
%
escape
(
n
),
action
=
'./manage_main'
,)
raise
BadRequest
(
'Not Deletable'
)
while
ids
:
id
=
ids
[
-
1
]
v
=
self
.
_getOb
(
id
,
self
)
...
...
src/OFS/role.py
View file @
39033d38
...
...
@@ -15,7 +15,6 @@
from
cgi
import
escape
from
App.Dialogs
import
MessageDialog
from
App.special_dtml
import
DTMLFile
from
AccessControl
import
ClassSecurityInfo
...
...
@@ -26,6 +25,7 @@ from AccessControl.Permission import Permission
from
AccessControl.Permissions
import
change_permissions
from
AccessControl.requestmethod
import
requestmethod
from
AccessControl.rolemanager
import
_string_hash
from
zExceptions
import
BadRequest
class
RoleManager
(
BaseRoleManager
):
...
...
@@ -122,15 +122,10 @@ class RoleManager(BaseRoleManager):
fails
.
append
(
name
)
if
fails
:
return
MessageDialog
(
title
=
"Warning!"
,
message
=
"Some permissions had errors: "
+
escape
(
', '
.
join
(
fails
)),
action
=
'manage_access'
)
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
action
=
'manage_access'
)
raise
BadRequest
(
'Some permissions had errors: '
+
escape
(
', '
.
join
(
fails
)))
if
REQUEST
is
not
None
:
return
self
.
manage_access
(
REQUEST
)
security
.
declareProtected
(
change_permissions
,
'manage_listLocalRoles'
)
manage_listLocalRoles
=
DTMLFile
(
'dtml/listLocalRoles'
,
globals
(),
...
...
@@ -184,15 +179,9 @@ class RoleManager(BaseRoleManager):
@
requestmethod
(
'POST'
)
def
_addRole
(
self
,
role
,
REQUEST
=
None
):
if
not
role
:
return
MessageDialog
(
title
=
'Incomplete'
,
message
=
'You must specify a role name'
,
action
=
'manage_access'
)
raise
BadRequest
(
'You must specify a role name'
)
if
role
in
self
.
__ac_roles__
:
return
MessageDialog
(
title
=
'Role Exists'
,
message
=
'The given role is already defined'
,
action
=
'manage_access'
)
raise
BadRequest
(
'The given role is already defined'
)
data
=
list
(
self
.
__ac_roles__
)
data
.
append
(
role
)
self
.
__ac_roles__
=
tuple
(
data
)
...
...
@@ -202,10 +191,7 @@ class RoleManager(BaseRoleManager):
@
requestmethod
(
'POST'
)
def
_delRoles
(
self
,
roles
,
REQUEST
=
None
):
if
not
roles
:
return
MessageDialog
(
title
=
'Incomplete'
,
message
=
'You must specify a role name'
,
action
=
'manage_access'
)
raise
BadRequest
(
'You must specify a role name'
)
data
=
list
(
self
.
__ac_roles__
)
for
role
in
roles
:
try
:
...
...
src/OFS/userfolder.py
View file @
39033d38
...
...
@@ -20,9 +20,9 @@ from Acquisition import aq_base
from
App.Management
import
Navigation
from
App.Management
import
Tabs
from
App.special_dtml
import
DTMLFile
from
App.Dialogs
import
MessageDialog
from
OFS.role
import
RoleManager
from
OFS.SimpleItem
import
Item
from
zExceptions
import
BadRequest
from
AccessControl
import
ClassSecurityInfo
from
AccessControl.class_init
import
InitializeClass
...
...
@@ -141,27 +141,15 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
@
requestmethod
(
'POST'
)
def
_addUser
(
self
,
name
,
password
,
confirm
,
roles
,
domains
,
REQUEST
=
None
):
if
not
name
:
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'A username must be specified'
,
action
=
'manage_main'
)
raise
BadRequest
(
'A username must be specified'
)
if
not
password
or
not
confirm
:
if
not
domains
:
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'Password and confirmation must be specified'
,
action
=
'manage_main'
)
raise
BadRequest
(
'Password and confirmation must be specified'
)
if
self
.
getUser
(
name
)
or
(
self
.
_emergency_user
and
name
==
self
.
_emergency_user
.
getUserName
()):
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'A user with the specified name already exists'
,
action
=
'manage_main'
)
raise
BadRequest
(
'A user with the specified name already exists'
)
if
(
password
or
confirm
)
and
(
password
!=
confirm
):
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'Password and confirmation do not match'
,
action
=
'manage_main'
)
raise
BadRequest
(
'Password and confirmation do not match'
)
if
not
roles
:
roles
=
[]
...
...
@@ -169,10 +157,7 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
domains
=
[]
if
domains
and
not
self
.
domainSpecValidate
(
domains
):
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'Illegal domain specification'
,
action
=
'manage_main'
)
raise
BadRequest
(
'Illegal domain specification'
)
self
.
_doAddUser
(
name
,
password
,
roles
,
domains
)
if
REQUEST
:
return
self
.
_mainUser
(
self
,
REQUEST
)
...
...
@@ -184,26 +169,14 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
# Protocol for editUser.dtml to indicate unchanged password
password
=
confirm
=
None
if
not
name
:
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'A username must be specified'
,
action
=
'manage_main'
)
raise
BadRequest
(
'A username must be specified'
)
if
password
==
confirm
==
''
:
if
not
domains
:
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'Password and confirmation must be specified'
,
action
=
'manage_main'
)
raise
BadRequest
(
'Password and confirmation must be specified'
)
if
not
self
.
getUser
(
name
):
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'Unknown user'
,
action
=
'manage_main'
)
raise
BadRequest
(
'Unknown user'
)
if
(
password
or
confirm
)
and
(
password
!=
confirm
):
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'Password and confirmation do not match'
,
action
=
'manage_main'
)
raise
BadRequest
(
'Password and confirmation do not match'
)
if
not
roles
:
roles
=
[]
...
...
@@ -211,10 +184,7 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
domains
=
[]
if
domains
and
not
self
.
domainSpecValidate
(
domains
):
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'Illegal domain specification'
,
action
=
'manage_main'
)
raise
BadRequest
(
'Illegal domain specification'
)
self
.
_doChangeUser
(
name
,
password
,
roles
,
domains
)
if
REQUEST
:
return
self
.
_mainUser
(
self
,
REQUEST
)
...
...
@@ -222,10 +192,7 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
@
requestmethod
(
'POST'
)
def
_delUsers
(
self
,
names
,
REQUEST
=
None
):
if
not
names
:
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'No users specified'
,
action
=
'manage_main'
)
raise
BadRequest
(
'No users specified'
)
self
.
_doDelUsers
(
names
)
if
REQUEST
:
return
self
.
_mainUser
(
self
,
REQUEST
)
...
...
@@ -242,11 +209,8 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
if
submit
==
'Edit'
:
try
:
user
=
self
.
getUser
(
reqattr
(
REQUEST
,
'name'
))
except
:
return
MessageDialog
(
title
=
'Illegal value'
,
message
=
'The specified user does not exist'
,
action
=
'manage_main'
)
except
Exception
:
raise
BadRequest
(
'The specified user does not exist'
)
return
self
.
_editUser
(
self
,
REQUEST
,
user
=
user
,
password
=
user
.
__
)
if
submit
==
'Add'
:
...
...
@@ -287,10 +251,7 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
def
_setId
(
self
,
id
):
if
id
!=
self
.
id
:
raise
ValueError
(
MessageDialog
(
title
=
'Invalid Id'
,
message
=
'Cannot change the id of a UserFolder'
,
action
=
'./manage_main'
))
raise
ValueError
(
'Cannot change the id of a UserFolder'
)
InitializeClass
(
BasicUserFolder
)
...
...
@@ -341,11 +302,8 @@ def manage_addUserFolder(self, dtself=None, REQUEST=None, **ignored):
self
=
self
.
this
()
try
:
self
.
_setObject
(
'acl_users'
,
f
)
except
:
return
MessageDialog
(
title
=
'Item Exists'
,
message
=
'This object already contains a User Folder'
,
action
=
'%s/manage_main'
%
REQUEST
[
'URL1'
])
except
Exception
:
raise
BadRequest
(
'This object already contains a User Folder'
)
self
.
__allow_groups__
=
f
if
REQUEST
is
not
None
:
REQUEST
[
'RESPONSE'
].
redirect
(
self
.
absolute_url
()
+
'/manage_main'
)
src/Products/SiteAccess/VirtualHostMonster.py
View file @
39033d38
...
...
@@ -3,10 +3,9 @@
Defines the VirtualHostMonster class
"""
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.Permissions
import
view
as
View
from
AccessControl.Permissions
import
view
as
View
# NOQA
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
Acquisition
import
Implicit
from
App.Dialogs
import
MessageDialog
from
App.special_dtml
import
DTMLFile
from
OFS.SimpleItem
import
Item
from
Persistence
import
Persistent
...
...
@@ -116,11 +115,6 @@ class VirtualHostMonster(Persistent, Item, Implicit):
def
manage_addToContainer
(
self
,
container
,
nextURL
=
''
):
self
.
addToContainer
(
container
)
if
nextURL
:
return
MessageDialog
(
title
=
'Item Added'
,
message
=
'This object now has a %s'
%
self
.
meta_type
,
action
=
nextURL
)
def
manage_beforeDelete
(
self
,
item
,
container
):
if
item
is
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