Commit 85c9193b authored by Hanno Schlichting's avatar Hanno Schlichting

Remove remaining support classes for defining permissions TTW.

parent 91a1052f
...@@ -11,6 +11,8 @@ Trunk (unreleased) ...@@ -11,6 +11,8 @@ Trunk (unreleased)
Restructuring Restructuring
+++++++++++++ +++++++++++++
- Remove remaining support classes for defining permissions TTW.
- Moved ``TaintedString`` into the new AccessControl.tainted module. - Moved ``TaintedString`` into the new AccessControl.tainted module.
- Moved the ``zExceptions`` package into its own distribution. - Moved the ``zExceptions`` package into its own distribution.
......
...@@ -594,9 +594,6 @@ class RoleManager(Base, RoleManager): ...@@ -594,9 +594,6 @@ class RoleManager(Base, RoleManager):
Products_permissions = getattr(Products, '__ac_permissions__', ()) Products_permissions = getattr(Products, '__ac_permissions__', ())
for p in Products_permissions: for p in Products_permissions:
d[p[0]]=1 d[p[0]]=1
for p in self.aq_acquire('_getProductRegistryData')('ac_permissions'):
d[p[0]]=1
for p in self.ac_inherited_permissions(1): for p in self.ac_inherited_permissions(1):
d[p[0]]=1 d[p[0]]=1
......
...@@ -10,19 +10,14 @@ ...@@ -10,19 +10,14 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__='''Zope registerable permissions '''Zope registerable permissions
'''
$Id$'''
__version__='$Revision: 1.9 $'[11:-2]
from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import define_permissions
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
from AccessControl.SecurityInfo import ClassSecurityInfo from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import Implicit from Acquisition import Implicit
from App.class_init import InitializeClass from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
from ExtensionClass import Base
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Persistence import Persistent from Persistence import Persistent
...@@ -35,14 +30,11 @@ class Permission(RoleManager, ...@@ -35,14 +30,11 @@ class Permission(RoleManager,
""" """
meta_type = 'Zope Permission' meta_type = 'Zope Permission'
icon = 'p_/Permission_icon' icon = 'p_/Permission_icon'
index_html = None
security = ClassSecurityInfo() security = ClassSecurityInfo()
manage_options=( manage_options=(
( RoleManager.manage_options
{'label':'Edit', 'action':'manage_main',
'help':('OFSP', 'Zope-Permission_Edit.stx')},
)
+ RoleManager.manage_options
+ Item.manage_options + Item.manage_options
) )
...@@ -51,63 +43,4 @@ class Permission(RoleManager, ...@@ -51,63 +43,4 @@ class Permission(RoleManager,
self.title=title self.title=title
self.name=name self.name=name
security.declareProtected(define_permissions, 'manage_edit')
def manage_edit(self, title, name, REQUEST=None):
"Modify Permission properties."
if title != self.title: self.title=title
if name != self.name:
self._unregister()
self.name=name
self._register()
if REQUEST is not None: return self.manage_main(self, REQUEST)
security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container):
self._register()
security.declarePrivate('manage_beforeDelete')
def manage_beforeDelete(self, item, container):
self._unregister()
def _register(self):
# Register with the product folder
product = self.aq_parent
product.aq_acquire('_manage_add_product_permission')(
product, self.name)
def _unregister(self):
# Unregister with the product folder
product = self.aq_parent
product.aq_acquire('_manage_remove_product_permission')(
product, self.name)
security.declareProtected(view_management_screens, 'manage_main')
manage_main = DTMLFile('dtml/editPermission', globals())
index_html = None
InitializeClass(Permission) InitializeClass(Permission)
class PermissionManager(Base):
security = ClassSecurityInfo()
meta_types={
'name': Permission.meta_type, 'action': 'manage_addPermissionForm'
},
security.declareProtected(define_permissions, 'manage_addPermissionForm')
manage_addPermissionForm = DTMLFile('dtml/addPermission', globals())
security.declareProtected(define_permissions, 'manage_addPermission')
def manage_addPermission(
self, id, title, permission, REQUEST=None):
""" Add a TTW permission.
"""
i=Permission(id, title, permission)
self._setObject(id, i)
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
InitializeClass(PermissionManager)
...@@ -45,8 +45,6 @@ from App.class_init import InitializeClass ...@@ -45,8 +45,6 @@ from App.class_init import InitializeClass
from App.special_dtml import DTMLFile from App.special_dtml import DTMLFile
from OFS.Folder import Folder from OFS.Folder import Folder
from App.Permission import PermissionManager
class ProductFolder(Folder): class ProductFolder(Folder):
"Manage a collection of Products" "Manage a collection of Products"
...@@ -71,7 +69,7 @@ class ProductFolder(Folder): ...@@ -71,7 +69,7 @@ class ProductFolder(Folder):
InitializeClass(ProductFolder) InitializeClass(ProductFolder)
class Product(Folder, PermissionManager): class Product(Folder):
"""Model a product that can be created through the web. """Model a product that can be created through the web.
""" """
...@@ -83,10 +81,6 @@ class Product(Folder, PermissionManager): ...@@ -83,10 +81,6 @@ class Product(Folder, PermissionManager):
configurable_objects_=() configurable_objects_=()
import_error_=None import_error_=None
meta_types=(
PermissionManager.meta_types
)
manage_options = ( manage_options = (
(Folder.manage_options[0],) + (Folder.manage_options[0],) +
tuple(Folder.manage_options[2:]) tuple(Folder.manage_options[2:])
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
# will return: # will return:
# ....what? # ....what?
from OFS.Folder import Folder
class ProductRegistryMixin: class ProductRegistryMixin:
# This class implements a protocol for registering products that # This class implements a protocol for registering products that
# are defined through the web. # are defined through the web.
...@@ -73,44 +71,6 @@ class ProductRegistryMixin: ...@@ -73,44 +71,6 @@ class ProductRegistryMixin:
self._setProductRegistryMetaTypes(meta_types+(mt,)) self._setProductRegistryMetaTypes(meta_types+(mt,))
def _manage_remove_product_permission(self, product, permission=None):
r=[]
r2=[]
pid=product.id
for d in self._getProductRegistryData('permissions'):
if d.has_key('product'):
if d['product']==pid and (
permission is None or permission==d['name']):
continue
elif permission==d['name']: continue
r.append(d)
r2.append((d['name'], d['methods'], d['default']))
self._setProductRegistryData('permissions', tuple(r))
self._setProductRegistryData('ac_permissions', tuple(r2))
def _manage_add_product_permission(
self, product, permission, methods=(), default=('Manager',)
):
permissions=self._getProductRegistryData('permissions')
for d in permissions:
if d['name']==permission:
raise ValueError, (
'The permission <em>%s</em> is already defined.'
% permission)
d={'name': permission, 'methods': methods, 'permission': permission,
'default': default, 'product': product.id}
self._setProductRegistryData('permissions', permissions + (d,))
self._setProductRegistryData(
'ac_permissions',
self._getProductRegistryData('ac_permissions')
+((d['name'], d['methods'], d['default']),)
)
# HACK - sometimes an unwrapped App object seems to be passed as # HACK - sometimes an unwrapped App object seems to be passed as
# self to these methods, which means that they dont have an aq_aquire # self to these methods, which means that they dont have an aq_aquire
# method. Until Jim has time to look into this, this aq_maybe method # method. Until Jim has time to look into this, this aq_maybe method
...@@ -143,7 +103,6 @@ class ProductRegistryMixin: ...@@ -143,7 +103,6 @@ class ProductRegistryMixin:
self.aq_maybe('_setProductRegistryData')(type, tuple(values)) self.aq_maybe('_setProductRegistryData')(type, tuple(values))
class ProductRegistry(ProductRegistryMixin): class ProductRegistry(ProductRegistryMixin):
# This class implements a protocol for registering products that # This class implements a protocol for registering products that
# are defined through the web. It also provides methods for # are defined through the web. It also provides methods for
...@@ -154,11 +113,12 @@ class ProductRegistry(ProductRegistryMixin): ...@@ -154,11 +113,12 @@ class ProductRegistry(ProductRegistryMixin):
def _getProducts(self): return self.Control_Panel.Products def _getProducts(self): return self.Control_Panel.Products
_product_meta_types=() _product_meta_types=()
_product_permissions=()
_product_ac_permissions=()
def _getProductRegistryMetaTypes(self): return self._product_meta_types def _getProductRegistryMetaTypes(self):
def _setProductRegistryMetaTypes(self, v): self._product_meta_types=v return self._product_meta_types
def _setProductRegistryMetaTypes(self, v):
self._product_meta_types=v
def _getProductRegistryData(self, name): def _getProductRegistryData(self, name):
return getattr(self, '_product_%s' % name) return getattr(self, '_product_%s' % name)
......
<dtml-var manage_page_header>
<dtml-var "manage_form_title(this(), _,
form_title='Add Permission',
help_product='OFSP',
help_topic='Zope-Permission_Add.stx'
)">
<form action="manage_addPermission" method="POST">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-optional">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Name
</div>
</td>
<td align="left" valign="top">
<input type="text" name="permission" size="40" />
</td>
</tr>
<tr>
<td></td>
<td align="left" valign="top">
<div class="form-element">
<br />
<input type="submit" name="submit" value="Generate" />
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<form action="manage_edit" method="POST">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
</div>
</td>
<td align="left" valign="top">
<div class="form-text">
&dtml-id;
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-optional">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title"size="40" value="&dtml-title;" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Name
</div>
</td>
<td align="left" valign="top">
<input type="text" name="name" size="40" value="&dtml-name;" />
</td>
</tr>
<tr>
<td></td>
<td>
<div class="form-element">
<input type="submit" name="submit" value="Save Changes">
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
...@@ -265,9 +265,7 @@ class ObjectManager(CopyContainer, ...@@ -265,9 +265,7 @@ class ObjectManager(CopyContainer,
def _subobject_permissions(self): def _subobject_permissions(self):
import Products import Products
Products_permissions = getattr(Products, '__ac_permissions__', ()) Products_permissions = getattr(Products, '__ac_permissions__', ())
return (Products_permissions + return Products_permissions
self.aq_acquire('_getProductRegistryData')('ac_permissions')
)
def filtered_meta_types(self, user=None): def filtered_meta_types(self, user=None):
# Return a list of the types for which the user has # Return a list of the types for which the user has
......
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
<five:deprecatedManageAddDelete <five:deprecatedManageAddDelete
class="AccessControl.User.BasicUserFolder"/> class="AccessControl.User.BasicUserFolder"/>
<five:deprecatedManageAddDelete
class="App.Permission.Permission"/>
<five:deprecatedManageAddDelete <five:deprecatedManageAddDelete
class="HelpSys.HelpTopic.HelpTopicBase"/> class="HelpSys.HelpTopic.HelpTopicBase"/>
......
Zope Permission: Define new Permissions.
Description
Zope Permissions allow you to define new permissions.
Zope Permission - Add: Create a new Permission.
Description
This view allows you to create a new Permission.
Controls
'Id' -- The id of the Zope Permission.
'Title' -- The optional title of the Zope Permission.
'Name' -- Allows you to specify the name of the permission.
**Note: A permission's name must be unique.**
'Add' -- Create a Permission.
Zope Permission - Edit: Edit Permission.
Description
This view allows you to edit Zope Permission settings.
Controls
'Title' -- The optional title of the Zope Permission.
'Name' -- The name of the permission.
**Note: A permission's name must be unique.**
'Change' -- Change the Permission.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment