For compatibility: use instance.pk instead of id
@@ -83,17 +83,17 @@ class SegmentPlugin(TransparentContainer, CascadePluginBase):
template_error_message = err.message
finally:
if evaluated_to:
- request._evaluated_instances[instance.id] = True
+ request._evaluated_instances[instance.pk] = True
template = self.default_template
else:
- request._evaluated_instances[instance.id] = False
+ request._evaluated_instances[instance.pk] = False
if edit_mode:
# In edit mode, hidden plugins have to be rendered nevertheless. Therefore
# we use `style="display: none"`, otherwise the plugin would be invisible
# in structure mode, while editing.
if template_error_message:
template = self.debug_error_template.format(condition=condition,
- instance_id=instance.id, message=template_error_message,
+ instance_id=instance.pk, message=template_error_message,
template_string=self.hiding_template_string)
template = engines['django'].from_string(template)
else:
@@ -113,8 +113,8 @@ class SegmentPlugin(TransparentContainer, CascadePluginBase):
if prev_inst is None:
# this can happen, if one moves an else- or elif-segment in front of an if-segment
template = edit_mode and self.hiding_template or self.empty_template
- elif request._evaluated_instances.get(prev_inst.id):
- request._evaluated_instances[instance.id] = True
+ elif request._evaluated_instances.get(prev_inst.pk):
+ request._evaluated_instances[instance.pk] = True
# in edit mode hidden plugins have to be rendered nevertheless
template = edit_mode and self.hiding_template or self.empty_template
elif open_tag == 'elif':
@@ -130,7 +130,7 @@ class SegmentPlugin(TransparentContainer, CascadePluginBase):
if LooseVersion(cms_version) > LooseVersion('3.3'):
context.update(instance.get_context_override(request))
- return super(SegmentPlugin, self).render(context, instance, placeholder)
+ return super(self.__class__, self).render(context, instance, placeholder)
def get_form(self, request, obj=None, **kwargs):
def clean_condition(value):
@@ -176,4 +176,10 @@ class SegmentPlugin(TransparentContainer, CascadePluginBase):
return (('if', _("if")), ('elif', _("elif")), ('else', _("else")),)
return (('if', _("if")),)
+ @classmethod
+ def get_data_representation(cls, instance):
+ data = super(SegmentPlugin, cls).get_data_representation(instance)
+ data.update(pk=instance.pk)
+ return data
+
plugin_pool.register_plugin(SegmentPlugin)
