Don't use session at all for content rules, set the event in the request to be able to access comment attributes. This fixes 'InvalidObjectReference: A new object is reachable from multiple databases.' if comment contains a RichTextValue which contains a RawValueHolder (persistent object).

This commit is contained in:
Vincent Fretin
2014-09-20 14:54:02 +02:00
parent fa127ad85c
commit 42d12200a7
3 changed files with 13 additions and 31 deletions
+4 -10
View File
@@ -19,16 +19,10 @@ class DiscussionEvent(object):
for key, value in kwargs.items():
setattr(self, key, value)
# Add comment on session to easily define content-rules dynamic strings
sdm = getattr(context, 'session_data_manager', None)
session = sdm.getSessionData(create=True) if sdm else None
if session:
sessionComment = dict(
(field, getattr(comment, field, None)) for field in IComment
if not field.startswith('_')
)
session.set('comment', sessionComment)
# Add event to the request to be able to access comment attributes
# in content-rules dynamic strings
request = context.REQUEST
request.set('event', self)
class CommentAddedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is added