def project_initialization(self, instances, app=None): """ Custom initialization of your project Please define your class Initializer in project/YOURPROJECT/backend/initialization/initialization.py """ try: # NOTE: this might be a pattern # see in meta.py:get_customizer_class module_path = "{}.{}.{}".format( CUSTOM_PACKAGE, 'initialization', 'initialization', ) module = Meta.get_module_from_string(module_path) meta = Meta() Initializer = meta.get_class_from_string( 'Initializer', module, skip_error=True ) if Initializer is None: log.debug("No custom init available") else: try: Initializer(instances, app=app) except BaseException as e: log.error("Errors during custom initialization: {}", e) else: log.info("Vanilla project has been initialized") except BaseException: log.debug("No custom init available")
def custom_post_handle_user_input(self, user_node, input_data): module_path = "{}.initialization.initialization".format(CUSTOM_PACKAGE) module = Meta.get_module_from_string(module_path) meta = Meta() Customizer = meta.get_class_from_string('Customizer', module, skip_error=True) if Customizer is None: log.debug("No user properties customizer available") else: try: Customizer().custom_post_handle_user_input( self, user_node, input_data) except BaseException as e: log.error("Unable to customize user properties: {}", e)
def custom_user_properties(self, userdata): module_path = "{}.initialization.initialization".format(CUSTOM_PACKAGE) module = Meta.get_module_from_string(module_path) meta = Meta() Customizer = meta.get_class_from_string('Customizer', module, skip_error=True) if Customizer is None: log.debug("No user properties customizer available") else: try: userdata = Customizer().custom_user_properties(userdata) except BaseException as e: log.error("Unable to customize user properties: {}", e) if "email" in userdata: userdata["email"] = userdata["email"].lower() return userdata