--- a/src/pyams_form/security.py Wed Apr 11 11:02:00 2018 +0200
+++ b/src/pyams_form/security.py Wed Apr 11 11:02:32 2018 +0200
@@ -22,6 +22,18 @@
from pyramid.decorator import reify
+def get_edit_permission(request, context=None):
+ """Get required edit permission"""
+ if context is None:
+ context = request.context
+ registry = request.registry
+ checker = registry.queryMultiAdapter((context, request), IFormContextPermissionChecker)
+ if checker is None:
+ checker = registry.queryAdapter(context, IFormContextPermissionChecker)
+ if checker is not None:
+ return checker.edit_permission
+
+
class ProtectedFormObjectMixin(object):
"""Form object protected by a permission"""