Use named permission
authorThierry Florac <thierry.florac@onf.fr>
Thu, 08 Oct 2015 09:44:26 +0200
changeset 4 f2a4feee1ff3
parent 3 a2fb7373f0d1
child 5 e76aa6d39ce6
Use named permission
src/pyams_zodbbrowser/zmi/views.py
--- a/src/pyams_zodbbrowser/zmi/views.py	Wed Jun 17 10:03:04 2015 +0200
+++ b/src/pyams_zodbbrowser/zmi/views.py	Thu Oct 08 09:44:26 2015 +0200
@@ -9,14 +9,11 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyramid.httpexceptions import HTTPFound
-from pyramid.view import view_config
 
 __docformat__ = 'restructuredtext'
 
 
 # import standard library
-import json
 import time
 import transaction
 from html import escape
@@ -36,13 +33,16 @@
 from pyams_skin.viewlet.menu import MenuItem
 from pyams_template.template import template_config
 from pyams_utils.adapter import ContextRequestAdapter
-from pyams_utils.interfaces import PYAMS_APPLICATION_DEFAULT_NAME, PYAMS_APPLICATION_SETTINGS_KEY
+from pyams_utils.interfaces import PYAMS_APPLICATION_DEFAULT_NAME, PYAMS_APPLICATION_SETTINGS_KEY, \
+    MANAGE_SYSTEM_PERMISSION
 from pyams_utils.property import cached_property
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zodbbrowser.diff import compareDictsHTML
 from pyams_zodbbrowser.history import ZodbObjectHistory
 from pyams_zodbbrowser.state import ZodbObjectState
 from pyams_zodbbrowser.value import TRUNCATIONS, pruneTruncations
+from pyramid.httpexceptions import HTTPFound
+from pyramid.view import view_config
 from ZODB.POSException import POSKeyError
 from ZODB.utils import p64, u64, tid_repr
 from zope.exceptions.interfaces import UserError
@@ -122,7 +122,7 @@
 
 
 @viewlet_config(name='zodbbrowser.menu', layer=IAdminLayer, context=Interface, manager=IControlPanelMenu,
-                permission='system.manage', weight=9999)
+                permission=MANAGE_SYSTEM_PERMISSION, weight=9999)
 class ZODBBrowserMenu(MenuItem):
     """ZODB browser menu"""
 
@@ -160,7 +160,7 @@
         return obj
 
 
-@pagelet_config(name='zodbbrowser', context=Interface, layer=IPyAMSLayer, permission='system.manage')
+@pagelet_config(name='zodbbrowser', context=Interface, layer=IPyAMSLayer, permission=MANAGE_SYSTEM_PERMISSION)
 @template_config(template='templates/zodbinfo.pt', layer=IPyAMSLayer)
 @implementer(IInnerPage)
 class ZodbInfoView(VeryCarefulView):
@@ -445,7 +445,7 @@
 
 
 @view_config(name='zodbbrowser_path_to_oid', context=Interface, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class PathToOidView(ZodbInfoView):
 
     def __call__(self):
@@ -454,7 +454,7 @@
 
 
 @view_config(name='zodbbrowser_truncated', context=Interface, request_type=IPyAMSLayer,
-             permission='system.manage', renderer='json', xhr=True)
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
 class TruncatedView(ZodbInfoView):
 
     def __call__(self):
@@ -462,7 +462,7 @@
         return TRUNCATIONS.get(id)
 
 
-@pagelet_config(name='zodbbrowser_history', context=Interface, layer=IPyAMSLayer, permission='system.manage')
+@pagelet_config(name='zodbbrowser_history', context=Interface, layer=IPyAMSLayer, permission=MANAGE_SYSTEM_PERMISSION)
 @template_config(template='templates/zodbhistory.pt', layer=IPyAMSLayer)
 @implementer(IInnerPage)
 class ZodbHistoryView(VeryCarefulView):