コード例 #1
0
    def build_menu(self):
        """
        Build a simple menu for all plugin methods witch have a "menu_section"

        Use the internal page template "admin_menu.plugin_menu" !

        In the plugin config (plugin_manager_data) must be exist some meta
        information for the menu:
          "menu_section"     : The upper block name
          "menu_description" : Link text (optional, otherwise method name used)

        More info: http://pylucid.org/_goto/148/self-build_menu/
        """
        plugin = Plugin.objects.get(plugin_name=self.plugin_name)
        plugin_config = get_plugin_config(
            package_name = plugin.package_name,
            plugin_name = self.plugin_name,
        )
        plugin_version = get_plugin_version(
            package_name = plugin.package_name,
            plugin_name = self.plugin_name,
        )
#        debug_plugin_config(self.page_msg, plugin_config)

        plugin_manager_data = plugin_config.plugin_manager_data

        menu_data = {}
        for method_name, data in plugin_manager_data.iteritems():
            if not "menu_section" in data:
                continue

            menu_section = data["menu_section"]

            if not menu_section in menu_data:
                menu_data[menu_section] = []

            menu_data[menu_section].append(
                {
                    "link": self.URLs.methodLink(method_name),
                    "description": data.get("menu_description", method_name),
                }
            )

        self.context["PAGE"].title = "%s (%s)" % (
            self.plugin_name.replace("_", " "), plugin_version
        )

        context = {"menu_data": menu_data,}

        # Change the internal_page and use them from "admin_menu" plugin.
        plugin_internal_page = self.internal_page
        self.internal_page = InternalPage(
            self.context, plugin_name="admin_menu"
        )

        self._render_template("plugin_menu", context)#, debug=False)

        # change back to the original internal pages from the current plugin.
        self.internal_page = plugin_internal_page
コード例 #2
0
    def _get_uninstalled_plugins(self, installed_names):
        """
        Read all Plugin names from the disk and crop it with the given list.
        """
        uninstalled_plugins = []

        for path_cfg in settings.PLUGIN_PATH:
            package_name = ".".join(path_cfg["path"])

            plugin_path = os.path.join(settings.MAIN_APP_PATH, path_cfg["path"][1])
            plugin_list = get_plugin_list(plugin_path)

            for plugin_name in plugin_list:
                if plugin_name in installed_names:
                    continue

                try:
                    plugin_cfg = get_plugin_config(package_name, plugin_name)
                except Exception, err:
                    if self.request.debug:
                        raise
                    msg = "Can't get plugin config for %s.%s, Error: %s" % (
                        package_name, plugin_name, err
                    )
                    self.page_msg(msg)
                    continue

                try:
                    plugin_version = get_plugin_version(
                        package_name, plugin_name
                    )
                except Exception, err:
                    plugin_version = (
                        "Can't get plugin version for %s.%s, Error: %s"
                    ) % (package_name, plugin_name, err)

                uninstalled_plugins.append({
                    "plugin_name": plugin_name,
                    "package_name": package_name,
                    "description": plugin_cfg.__description__,
                    "url": plugin_cfg.__url__,
                    "author": plugin_cfg.__author__,
                    "version": plugin_version,
                })
コード例 #3
0
 def get_version_string(self):
     """
     Returned the version string from the plugin module
     """
     return get_plugin_version(self.package_name, self.plugin_name)