divio/aldryn-search

Context does not persist when rendering plugins

czpython opened this issue · 4 comments

Some plugins rely on context variables set by their parent's render() method, because of how plugins are rendered here, the context is always new instead of being shared by plugins, thus these plugins fail to render correctly.

Same with django-cms/djangocms-video#31

I had the thought that we could override the search_fields in the VideoSourcePlugin and VideoTrackPlugin. However this will not work with aldryn-search either because at the following line you are trying to access search_fields on the instance:
https://github.com/aldryn/aldryn-search/blob/master/aldryn_search/helpers.py#L48

According to your documentation search_fields is a part of CMSPluginBase and not of the instances:
http://docs.django-cms.org/en/release-3.4.x/how_to/custom_plugins.html

So I think you probably should change the above mentioned line to:
search_fields = getattr(plugin_type, 'search_fields', [])

Not sure if my thoughts on this are right. However if you agree I can propose a PR.

@czpython any chance you could pick this up at some point?

Hello @FinalAngel @czpython . Any chance to fix that?
How can I help you?

@DmytroLitvinov I sadly now not too much about this addon, we welcome PR's but I'm currently focusing on Django 2.2 support on the core addons.