def get_scheduled_interface(self): """ Return the registration interface of the selected scheduled_contenttype. """ portal_type, interface_tuple = self.scheduled_contenttype interface_class = tuple_to_interface(interface_tuple) return interface_class
def get_scheduled_interfaces(self): """ Return the registration interface of the selected scheduled_contenttype. """ portal_type, interface_tuples = self.scheduled_contenttype if type(interface_tuples[0]) not in [list, tuple]: interface_tuples = (interface_tuples, ) interfaces = tuple([tuple_to_interface(i) for i in interface_tuples]) return interfaces
def test_tuple_to_interface(self): """ Should turn a tuple ('interface.module.path', 'Interface') into Interface class. """ from imio.schedule.utils import tuple_to_interface expected_interface = IATFolder interface_tuple = ('Products.ATContentTypes.interfaces.folder', 'IATFolder') interface = tuple_to_interface(interface_tuple) self.assertEqual(interface, expected_interface)
def unsubscribe_task_configs_for_content_type(task_config, event): """ Unregister adapter returning 'task_config' to the interface of the content_type selected in the field 'task_container'. """ gsm = getGlobalSiteManager() schedule_config = task_config.get_schedule_config() previous_interface = getattr(schedule_config, '_scheduled_interface_', None) previous_interface = tuple_to_interface(previous_interface) removed = gsm.unregisterAdapter( required=(previous_interface,), provided=IToTaskConfig, name=task_config.UID() ) if removed: msg = "Unregistered IToTaskConfig adapter '{}' for {}".format( task_config.Title(), previous_interface ) logger.info(msg)
def unsubscribe_task_configs_for_content_type(task_config, event): """ Unregister adapter returning 'task_config' to the interface of the content_type selected in the field 'task_container'. """ gsm = getGlobalSiteManager() schedule_config = task_config.get_schedule_config() previous_interfaces = getattr(schedule_config, '_scheduled_interface_', None) if previous_interfaces and type( previous_interfaces[0]) not in [list, tuple]: previous_interfaces = (previous_interfaces, ) previous_interfaces = [tuple_to_interface(i) for i in previous_interfaces] for previous_interface in previous_interfaces: removed = gsm.unregisterAdapter(required=(previous_interface, ), provided=IToTaskConfig, name=task_config.UID()) if removed: msg = "Unregistered IToTaskConfig adapter '{}' for {}".format( task_config.Title(), previous_interface) logger.info(msg)