Show
Ignore:
Timestamp:
04/23/08 09:31:05 (23 months ago)
Author:
JensDiemer
Message:
  • page title
    • plugin_manager.handle_command() changes the page title, if it's not changes by the plugin themself.
    • remove some headlines in internal pages
    • set some title in plugins
  • add BasePlugin?.build_menu() - Used in show_internals (comes later)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/system/BasePlugin.py

    r1496 r1532  
    4040from PyLucid.tools.utils import escape 
    4141from PyLucid.system.internal_page import InternalPage, InternalPageNotFound 
     42from PyLucid.system.plugin_manager import get_plugin_config, debug_plugin_config 
     43from PyLucid.models import Plugin 
     44 
    4245 
    4346 
     
    5659 
    5760        self.current_page = self.context["PAGE"] 
     61 
     62    def build_menu(self): 
     63        """ 
     64        Build a simple menu for all plugin methods witch have a "menu_section" 
     65 
     66        Use the internal page template "admin_menu.plugin_menu" ! 
     67 
     68        In the plugin config (plugin_manager_data) must be exist some meta 
     69        information for the menu: 
     70          "menu_section"     : The upper block name 
     71          "menu_description" : Link text (optional, otherewise method name used) 
     72        """ 
     73        plugin = Plugin.objects.get(plugin_name=self.plugin_name) 
     74        plugin_config = get_plugin_config(self.request, 
     75            package_name = plugin.package_name, 
     76            plugin_name = self.plugin_name, 
     77            dissolve_version_string = True, 
     78        ) 
     79#        debug_plugin_config(self.page_msg, plugin_config) 
     80 
     81        plugin_manager_data = plugin_config.plugin_manager_data 
     82 
     83        menu_data = {} 
     84        for method_name, data in plugin_manager_data.iteritems(): 
     85            if not "menu_section" in data: 
     86                continue 
     87 
     88            menu_section = data["menu_section"] 
     89 
     90            if not menu_section in menu_data: 
     91                menu_data[menu_section] = [] 
     92 
     93            menu_data[menu_section].append( 
     94                { 
     95                    "link": self.URLs.methodLink(method_name), 
     96                    "description": data.get("menu_description", method_name), 
     97                } 
     98            ) 
     99 
     100        context = { 
     101            "plugin_name": self.plugin_name, 
     102            "version": plugin_config.__version__, 
     103            "menu_data": menu_data, 
     104        } 
     105 
     106        # Change the internal_page and use them from "admin_menu" plugin. 
     107        plugin_internal_page = self.internal_page 
     108        self.internal_page = InternalPage( 
     109            self.context, plugin_name="admin_menu" 
     110        ) 
     111 
     112        self._render_template("plugin_menu", context)#, debug=False) 
     113 
     114        # change back to the original internal pages from the current plugin. 
     115        self.internal_page = self.internal_page 
     116 
    58117 
    59118    def _debug_context(self, context, template):