Ejemplo n.º 1
0
	def register_content_decorators(self, plugin_id, contents):
		"""
		Register the sequence of classes @contents as
		potential content decorators. Classes not conforming to
		the decoration protocol (most importantly, ``.decorates_type()``)
		will be skipped
		"""
		# Keep a mapping:
		# Decorated Leaf Type -> Set of content decorator types
		decorate_item_types = {}
		for c in contents:
			try:
				applies = c.decorates_type()
			except AttributeError:
				continue
			decorate_item_types.setdefault(applies, set()).add(c)
		if not decorate_item_types:
			return
		sc = GetSourceController()
		sc.add_content_decorators(plugin_id, decorate_item_types)
Ejemplo n.º 2
0
    def register_content_decorators(self, plugin_id, contents):
        """
		Register the sequence of classes @contents as
		potential content decorators. Classes not conforming to
		the decoration protocol (most importantly, ``.decorates_type()``)
		will be skipped
		"""
        # Keep a mapping:
        # Decorated Leaf Type -> Set of content decorator types
        decorate_item_types = {}
        for c in contents:
            try:
                applies = c.decorates_type()
            except AttributeError:
                continue
            decorate_item_types.setdefault(applies, set()).add(c)
        if not decorate_item_types:
            return
        sc = GetSourceController()
        sc.add_content_decorators(plugin_id, decorate_item_types)