Commit 7634c000 authored by Yusei Tahara's avatar Yusei Tahara

Use copy.deepcopy instead of asContext. Persistent object connected to zodb...

Use copy.deepcopy instead of asContext. Persistent object connected to zodb must not be stored in on-memory classes.
parent f5a6c842
...@@ -196,4 +196,9 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate): ...@@ -196,4 +196,9 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'applyOnAccessorHolder') 'applyOnAccessorHolder')
def applyOnAccessorHolder(self, accessor_holder, expression_context, portal): def applyOnAccessorHolder(self, accessor_holder, expression_context, portal):
accessor_holder.constraints.append(self.asContext().aq_base) # Do not use asContext. Temporary object generated by asContext may
# contain persistent object. If persistent object is stored on memory like
# this(accessor_holder is on-memory object and is kept beyond transaction)
# then ConnectionStateError occurs after a long time.
import copy
accessor_holder.constraints.append(copy.deepcopy(self.aq_base))
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