Check for principal before updating modifiers
authorThierry Florac <thierry.florac@onf.fr>
Tue, 20 Feb 2018 11:17:11 +0100
changeset 401 c004b91ebcbd
parent 400 d319362746d1
child 402 29dfa7576e16
Check for principal before updating modifiers
src/pyams_content/shared/common/__init__.py
--- a/src/pyams_content/shared/common/__init__.py	Tue Feb 20 11:08:41 2018 +0100
+++ b/src/pyams_content/shared/common/__init__.py	Tue Feb 20 11:17:11 2018 +0100
@@ -160,15 +160,19 @@
     request = query_request()
     if request is not None:
         content = event.object
-        principal_id = request.principal.id
-        modifiers = content.modifiers or set()
-        if principal_id not in modifiers:
-            modifiers.add(principal_id)
-            content.modifiers = modifiers
-            catalog = query_utility(ICatalog)
-            intids = query_utility(IIntIds)
-            catalog['modifiers'].reindex_doc(intids.register(content), content)
-        content.last_modifier = principal_id
+        try:
+            principal_id = request.principal.id
+        except AttributeError:
+            pass
+        else:
+            modifiers = content.modifiers or set()
+            if principal_id not in modifiers:
+                modifiers.add(principal_id)
+                content.modifiers = modifiers
+                catalog = query_utility(ICatalog)
+                intids = query_utility(IIntIds)
+                catalog['modifiers'].reindex_doc(intids.register(content), content)
+            content.last_modifier = principal_id
 
 
 @subscriber(IObjectClonedEvent, context_selector=IWfSharedContent)