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
217e0d7b
Commit
217e0d7b
authored
Aug 29, 1997
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added basic role management to package.
parent
875c81dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
177 additions
and
5 deletions
+177
-5
lib/python/AccessControl/Role.py
lib/python/AccessControl/Role.py
+114
-0
lib/python/AccessControl/RoleManager_manage_rolesForm.dtml
lib/python/AccessControl/RoleManager_manage_rolesForm.dtml
+55
-0
lib/python/AccessControl/User.py
lib/python/AccessControl/User.py
+8
-5
No files found.
lib/python/AccessControl/Role.py
0 → 100644
View file @
217e0d7b
"""Access control package"""
__version__
=
'$Revision: 1.1 $'
[
11
:
-
2
]
import
Globals
from
User
import
SafeDtml
from
Globals
import
MessageDialog
from
string
import
join
,
strip
,
split
class
RoleManager
:
"""Mixin role management support"""
manage_rolesForm
=
SafeDtml
(
'RoleManager_manage_rolesForm'
)
def
validRoles
(
self
):
return
Globals
.
Bobobase
[
'roles'
]
def
selectedRoles
(
self
):
try
:
roles
=
self
.
__roles__
except
:
roles
=
[]
if
roles
is
None
:
roles
=
[]
return
map
(
lambda
i
,
r
=
roles
:
i
in
r
and
(
'<OPTION VALUE="%s" SELECTED>%s'
%
(
i
,
i
))
\
or
(
'<OPTION VALUE="%s">%s'
%
(
i
,
i
)),
self
.
validRoles
())
def
aclAChecked
(
self
):
try
:
roles
=
self
.
__roles__
except
:
return
' CHECKED'
return
''
def
aclPChecked
(
self
):
try
:
roles
=
self
.
__roles__
except
:
return
''
if
roles
is
None
:
return
' CHECKED'
return
''
def
aclEChecked
(
self
):
try
:
roles
=
self
.
__roles__
except
:
return
0
if
roles
is
None
:
return
''
return
' CHECKED'
def
manage_editRoles
(
self
,
REQUEST
,
acl_type
=
'A'
,
acl_roles
=
[]):
""" """
try
:
del
self
.
__roles__
except
:
pass
if
acl_type
==
'A'
:
return
self
.
manage_rolesForm
(
self
,
REQUEST
)
if
acl_type
==
'P'
:
self
.
__roles__
=
None
return
self
.
manage_rolesForm
(
self
,
REQUEST
)
if
not
acl_roles
:
raise
'Bad Request'
,
'No roles specified!'
self
.
__roles__
=
acl_roles
return
self
.
manage_rolesForm
(
self
,
REQUEST
)
def
oldmanage_editRoles
(
self
,
REQUEST
,
roles
=
[]):
try
:
del
self
.
__roles__
except
:
pass
if
not
roles
:
return
self
.
manage_rolesForm
(
self
,
REQUEST
)
if
roles
==
[
'Public'
,]:
self
.
__roles__
=
None
return
self
.
manage_rolesForm
(
self
,
REQUEST
)
if
(
'Acquire'
in
roles
)
or
(
'Public'
in
roles
):
raise
'Bad Request'
,(
'<EM>Acquired</EM> and <EM>Public</EM> '
\
'cannot be combined with other roles!'
)
self
.
__roles__
=
roles
return
self
.
manage_rolesForm
(
self
,
REQUEST
)
def
manage_addRole
(
self
,
REQUEST
,
role
):
""" """
roles
=
Globals
.
Bobobase
[
'roles'
]
if
role
not
in
roles
:
Globals
.
Bobobase
[
'roles'
]
=
tuple
(
roles
)
+
(
role
,)
try
:
roles
=
self
.
__roles__
except
:
roles
=
[]
if
roles
is
None
:
roles
=
[]
roles
.
append
(
role
)
self
.
__roles__
=
roles
return
self
.
manage_rolesForm
(
self
,
REQUEST
)
def
manage_deleteRole
(
self
,
REQUEST
,
role
):
""" """
roles
=
Globals
.
Bobobase
[
'roles'
]
if
role
in
roles
:
roles
=
list
(
roles
)
del
roles
[
roles
.
index
(
role
)]
Globals
.
Bobobase
[
'roles'
]
=
tuple
(
roles
)
return
self
.
manage_main
(
self
,
REQUEST
)
def
_setRoles
(
self
,
acl_type
,
acl_roles
):
# Non-web helper to correctly set roles
try
:
del
self
.
__roles__
except
:
pass
if
acl_type
==
'A'
:
return
if
acl_type
==
'P'
:
self
.
__roles__
=
None
return
if
not
acl_roles
:
raise
'Bad Request'
,
'No roles specified!'
self
.
__roles__
=
acl_roles
# $Log: Role.py,v $
# Revision 1.1 1997/08/29 18:34:53 brian
# Added basic role management to package.
#
lib/python/AccessControl/RoleManager_manage_rolesForm.dtml
0 → 100644
View file @
217e0d7b
<HTML>
<HEAD>
<TITLE>Access Control</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2">Access Control</FONT>
<P>
You may restrict access to <EM><!--#var PARENT_URL--></EM> using the form
below. To add or remove roles, select or deselect
the desired role names and click <EM>Update</EM>.
<P>
<FORM ACTION="<!--#var PARENT_URL-->/manage_editRoles" METHOD="POST">
<TABLE>
<TR>
<TD VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="E"<!--#var aclEChecked-->>
Allow users with selected roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="A"<!--#var aclAChecked-->>
Allow based on default roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="P"<!--#var aclPChecked-->>
Allow all users
</TD>
<TD VALIGN="TOP">
<SELECT NAME="acl_roles:list" SIZE="5" MULTIPLE>
<!--#in selectedRoles-->
<!--#var sequence-item-->
<!--#/in selectedRoles-->
</SELECT>
<BR>
<INPUT TYPE="SUBMIT" VALUE="Update">
</TD>
</TR>
</TABLE>
</FORM>
<TABLE>
<TR>
<TD VALIGN="TOP">
To add a new, user-defined role to this object, enter the name of
the new role and click <EM>Add Role</EM>.
</TD>
<TD VALIGN="TOP">
<FORM ACTION="<!--#var PARENT_URL-->/manage_addRole" METHOD="POST">
<INPUT TYPE="TEXT" NAME="role" SIZE="20">
<BR>
<INPUT TYPE="SUBMIT" VALUE="Add Role">
</FORM>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
lib/python/AccessControl/User.py
View file @
217e0d7b
"""Access control package"""
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
import
Globals
from
Persistence
import
Persistent
...
...
@@ -187,7 +187,7 @@ class UserFolder(Implicit, Persistent):
class
UserFolderHandler
:
""" """
meta_types
=
({
'name'
:
'UserFolder'
,
'action'
:
'manage_addUserFolder'
},)
meta_types
=
({
'name'
:
'User
Folder'
,
'action'
:
'manage_addUserFolder'
},)
def
manage_addUserFolder
(
self
,
dtself
,
REQUEST
):
""" """
...
...
@@ -203,21 +203,21 @@ class UserFolderHandler:
def
UserFolderIds
(
self
):
t
=
[]
for
i
in
self
.
objectMap
():
if
i
[
'meta_type'
]
==
'UserFolder'
:
if
i
[
'meta_type'
]
==
'User
Folder'
:
t
.
append
(
i
[
'id'
])
return
t
def
UserFolderValues
(
self
):
t
=
[]
for
i
in
self
.
objectMap
():
if
i
[
'meta_type'
]
==
'UserFolder'
:
if
i
[
'meta_type'
]
==
'User
Folder'
:
t
.
append
(
getattr
(
self
,
i
[
'id'
]))
return
t
def
UserFolderItems
(
self
):
t
=
[]
for
i
in
self
.
objectMap
():
if
i
[
'meta_type'
]
==
'UserFolder'
:
if
i
[
'meta_type'
]
==
'User
Folder'
:
n
=
i
[
'id'
]
t
.
append
((
n
,
getattr
(
self
,
n
)))
return
t
...
...
@@ -226,6 +226,9 @@ class UserFolderHandler:
# $Log: User.py,v $
# Revision 1.8 1997/08/29 18:34:54 brian
# Added basic role management to package.
#
# Revision 1.7 1997/08/27 19:49:48 brian
# Added forgotten dtml
#
...
...
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