1- import importlib
21from collections import namedtuple
3- from typing import Callable
42
53from cms .api import add_plugin
64from cms .models import CMSPlugin
7- from django .conf import settings
85from django .core .serializers import deserialize
96from django .db import transaction
107from django .utils .encoding import force_str
@@ -68,7 +65,6 @@ def restore(self, placeholder, language, parent=None):
6865 target = parent ,
6966 ** data ,
7067 )
71- self ._call_user_site_import_processor_if_necessary (plugin , self .data )
7268
7369 field = ("target" ,) if plugin_target else ()
7470 # An empty *update_fields* iterable will skip the save
@@ -89,28 +85,6 @@ def restore(self, placeholder, language, parent=None):
8985 # customize plugin-data on import with configured function
9086 custom_process_hook (
9187 "DJANGOCMS_TRANSFER_PROCESS_IMPORT_PLUGIN_DATA" ,
92- plugin
88+ plugin , self . data
9389 )
94-
95- plugin .save ()
9690 return plugin
97-
98- def _call_user_site_import_processor_if_necessary (
99- self , plugin : CMSPlugin , plugin_data : dict
100- ):
101- # customize plugin-data on import with configured function
102- if processor_symbol := getattr (
103- settings , "DJANGOCMS_TRANSFER_PROCESS_IMPORT_PLUGIN_DATA" , None
104- ):
105- function = self ._resolve_function_from_full_path (processor_symbol )
106- function (plugin , plugin_data )
107-
108- def _resolve_function_from_full_path (
109- self , fully_qualified_path : str
110- ) -> Callable :
111- try :
112- module_name , function_name = fully_qualified_path .rsplit ("." , 1 )
113- module = importlib .import_module (module_name )
114- return getattr (module , function_name )
115- except (AttributeError , ImportError ):
116- raise ImportError (f"could not resolve { fully_qualified_path } " )
0 commit comments