Changeset 1551

Show
Ignore:
Timestamp:
05/02/08 16:47:16 (14 months ago)
Author:
JensDiemer
Message:

update preferences:

  • move the preferences form from the plugin module into the plugin config modul
  • a plugin must not use try...except to get the preferences
  • update all modules around the plugin install/deinstall etc.
  • detect_page used the system_settings "index_page" value (setup a other default index page works!)
Location:
trunk/pylucid
Files:
16 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/media/PyLucid/internal_page/plugin_admin/administation_menu.html

    r1532 r1551  
    5050                <a class="author" href="{{ plugin.url }}" title="{{ plugin.author }}"></a> 
    5151            </td> 
    52             <td class="version">{{ plugin.version }}</td> 
     52            <td class="version">{{ plugin.get_version_string }}</td> 
    5353            <td> 
    5454                {% if plugin.builtin %} 
     
    9191                <a class="author" href="{{ plugin.url }}" title="{{ plugin.author }}">{{ plugin.author }}</a> 
    9292            </td> 
    93             <td class="version">{{ plugin.version }}</td> 
     93            <td class="version">{{ plugin.get_version_string }}</td> 
    9494            <td> 
    9595                {% if not plugin.can_deinstall %} 
     
    116116<h4>Info:</h4> 
    117117<ul> 
    118   <li><strong>install</strong> - register a plugin/Plugin in the Database</li> 
    119   <li><strong>deinstall</strong> - All tables, stylesheets and internal pages where delete in the DB.</li> 
    120   <li><strong>activate</strong> - enable the plugin/Plugin for the CMS</li> 
    121   <li><strong>deactivate</strong> - disable the plugin/Plugin</li> 
     118  <li><strong>install</strong> - register a plugin/Plugin in the database</li> 
     119  <li><strong>deinstall</strong> - Complete remove the plugin from the database (incl. preferences)</li> 
     120  <li><strong>activate</strong> - enable the plugin (set active flag)</li> 
     121  <li><strong>deactivate</strong> - disable the plugin</li> 
    122122</ul> 
  • trunk/pylucid/media/PyLucid/internal_page/preference_editor/select.html

    r1544 r1551  
    11<fieldset><legend>select for edit</legend> 
    22<ul> 
    3 {% for item in preferences %} 
    4   <li><a href="{{ item.edit_link }}">{{ item.plugin_name }}</a> - {{ item.plugin_description }}</li> 
     3{% for plugin in plugins %} 
     4  <li><a href="{{ plugin.edit_link }}">{{ plugin.plugin_name }}</a> - {{ plugin.description }}</li> 
    55{% endfor %} 
    66</ul> 
  • trunk/pylucid/PyLucid/db/page.py

    r1390 r1551  
    2020#      page-ID  <-> parant-ID relation? 
    2121#      url data for every page? 
     22 
     23from django import newforms as forms 
     24from django.newforms.util import ValidationError 
     25from django.utils.translation import ugettext as _ 
    2226 
    2327from PyLucid.models import User, Page 
     
    129133    return sub_pages 
    130134 
     135#______________________________________________________________________________ 
     136# newforms Page choice 
     137""" 
     138# usage: 
    131139 
     140from PyLucid.db.page import PageChoiceField, get_page_choices 
     141class MyForm(forms.Form): 
     142    ... 
     143    page = PageChoiceField(widget=forms.Select(choices=get_page_choices())) 
     144    ... 
     145""" 
     146 
     147class PageChoiceField(forms.IntegerField): 
     148    def clean(self, page_id): 
     149        """ 
     150        returns the parent page instance. 
     151        Note: 
     152            In PyLucid.models.Page.save() it would be checkt if the selected 
     153            parent page is logical valid. Here we check only, if the page with 
     154            the given ID exists. 
     155        """ 
     156        # let convert the string into a integer: 
     157        page_id = super(PageChoiceField, self).clean(page_id) 
     158 
     159        if page_id == 0: 
     160            # assigned to the tree root. 
     161            return None 
     162 
     163        try: 
     164            #page_id = 999999999 # Not exists test 
     165            page = Page.objects.get(id=page_id) 
     166        except Exception, msg: 
     167            raise ValidationError(_(u"Wrong parent POST data: %s" % msg)) 
     168        else: 
     169            return page_id 
     170 
     171 
     172def get_page_choices(): 
     173    """ 
     174    generate a verbose page name tree for the parent choice field. 
     175    """ 
     176    page_list = flat_tree_list() 
     177    choices = [(0, "---[root]---")] 
     178    for page in page_list: 
     179        choices.append((page["id"], page["level_name"])) 
     180    return choices 
  • trunk/pylucid/PyLucid/models.py

    r1548 r1551  
    3232from PyLucid.tools import crypt 
    3333from PyLucid.system.utils import get_uri_base 
    34 from PyLucid.system.plugin_import import get_plugin_module 
     34from PyLucid.system.plugin_import import get_plugin_config, get_plugin_version 
    3535 
    3636#from PyLucid.db.cache import delete_page_cache 
     
    234234            auto_shortcuts = True 
    235235        else: 
    236             print ">>>", preferences 
    237236            auto_shortcuts = preferences["auto_shortcuts"] 
    238237 
     
    508507        # Get the name of the plugin, if __file__ used 
    509508        plugin_name = os.path.splitext(os.path.basename(plugin_name))[0] 
    510         print "plugin name: '%s'" % plugin_name 
     509        #print "plugin name: '%s'" % plugin_name 
    511510 
    512511        if plugin_name in preference_cache: 
     
    541540    ) 
    542541 
     542    #__________________________________________________________________________ 
     543    # spezial methods 
     544 
    543545    def init_pref_form(self, pref_form): 
    544546        """ 
     
    550552        self.set_pref_data_string(init_dict) 
    551553 
     554    #__________________________________________________________________________ 
     555    # spezial set methods 
     556 
    552557    def set_pref_data_string(self, data_dict): 
    553558        """ 
     
    556561        preference_cache[self.plugin_name] = data_dict 
    557562        self.pref_data_string = pformat(data_dict) 
     563 
     564    #__________________________________________________________________________ 
     565    # spezial get methods 
    558566 
    559567    def get_preferences(self): 
     
    570578        initial information into the help text and return the form. 
    571579        """ 
    572         plugin_module = get_plugin_module( 
     580        plugin_config = get_plugin_config( 
    573581            self.package_name, self.plugin_name, debug 
    574582        ) 
    575         form = getattr(plugin_module, "PreferencesForm") 
     583        form = getattr(plugin_config, "PreferencesForm") 
    576584        setup_help_text(form) 
    577585        return form 
     586 
     587    def get_version_string(self, debug=False): 
     588        """ 
     589        Returned the version string from the plugin module 
     590        """ 
     591        return get_plugin_version(self.package_name, self.plugin_name, debug) 
     592 
     593    #-------------------------------------------------------------------------- 
    578594 
    579595    def save(self): 
  • trunk/pylucid/PyLucid/plugins_internal/find_and_replace/find_and_replace.py

    r1548 r1551  
    3333 
    3434from PyLucid.system.BasePlugin import PyLucidBasePlugin 
    35 from PyLucid.models import Page, Template, Style 
    36 #from PyLucid.db.preferences import get_pref_dict 
     35from PyLucid.models import Page, Plugin, Template, Style 
    3736from PyLucid.tools.Diff import diff_lines 
    3837from PyLucid.tools.utils import escape 
    39  
    40  
    41 class PreferencesForm(forms.Form): 
    42     min_term_len = forms.IntegerField( 
    43         help_text="Min length of a search term", 
    44         initial=2, min_value=1 
    45     ) 
    46     max_term_len = forms.IntegerField( 
    47         help_text="Max length of a search term", 
    48         initial=150, min_value=1, max_value=500 
    49     ) 
    5038 
    5139 
     
    5947 
    6048# We used preferences values in a newform. We need these values here. 
    61 try: 
    62     preferences = Plugin.objects.get_preferences(__file__) 
    63 except Plugin.DoesNotExist, e: 
    64     # in _install section? 
    65     pass 
    66 else: 
    67     min_term_len = preferences["min_term_len"] 
    68     max_term_len = preferences["max_term_len"] 
     49preferences = Plugin.objects.get_preferences(__file__) 
     50 
     51min_term_len = preferences["min_term_len"] 
     52max_term_len = preferences["max_term_len"] 
    6953 
    7054 
  • trunk/pylucid/PyLucid/plugins_internal/find_and_replace/find_and_replace_cfg.py

    r1548 r1551  
    1616submenu. 
    1717""" 
     18 
     19#_____________________________________________________________________________ 
     20# preferences 
     21 
     22from django import newforms as forms 
     23from django.utils.translation import ugettext as _ 
     24 
     25class PreferencesForm(forms.Form): 
     26    min_term_len = forms.IntegerField( 
     27        help_text=_("Min length of a search term"), 
     28        initial=2, min_value=1 
     29    ) 
     30    max_term_len = forms.IntegerField( 
     31        help_text=_("Max length of a search term"), 
     32        initial=150, min_value=1, max_value=500 
     33    ) 
    1834 
    1935#_____________________________________________________________________________ 
  • trunk/pylucid/PyLucid/plugins_internal/page_admin/page_admin.py

    r1547 r1551  
    4545from PyLucid.plugins_internal.page_style.page_style import replace_add_data 
    4646 
    47  
    48 class ParentChoiceField(forms.IntegerField): 
    49     def clean(self, parent_id): 
    50         """ 
    51         returns the parent page instance. 
    52         Note: 
    53             In PyLucid.models.Page.save() it would be checkt if the selected 
    54             parent page is logical valid. Here we check only, if the page with 
    55             the given ID exists. 
    56         """ 
    57         # let convert the string into a integer: 
    58         parent_id = super(ParentChoiceField, self).clean(parent_id) 
    59         assert isinstance(parent_id, int) 
    60  
    61         if parent_id == 0: 
    62             # assigned to the tree root. 
    63             return None 
    64  
    65         try: 
    66             #parent_id = 999999999 # Not exists test 
    67             page = Page.objects.get(id=parent_id) 
    68             return page 
    69         except Exception, msg: 
    70             raise ValidationError(_(u"Wrong parent POST data: %s" % msg)) 
    71  
    72  
    73 def get_parent_choices(): 
    74     """ 
    75     generate a verbose page name tree for the parent choice field. 
    76     """ 
    77     page_list = flat_tree_list() 
    78     choices = [(0, "---[root]---")] 
    79     for page in page_list: 
    80         choices.append((page["id"], page["level_name"])) 
    81     return choices 
     47from PyLucid.db.page import PageChoiceField, get_page_choices 
     48 
    8249 
    8350class EditPageForm(forms.Form): 
     
    9562    ) 
    9663 
    97     parent = ParentChoiceField( 
    98         widget=forms.Select(choices=get_parent_choices()), 
     64    parent = PageChoiceField( 
     65        widget=forms.Select(choices=get_page_choices()), 
    9966        # FIXME: How to set invalid_choice here? 
    10067        help_text="the higher-ranking father page", 
  • trunk/pylucid/PyLucid/plugins_internal/plugin_admin/plugin_admin.py

    r1544 r1551  
    3030 
    3131from PyLucid.system.plugin_manager import get_plugin_list, install_plugin 
    32 from PyLucid.system.plugin_import import get_plugin_config 
     32from PyLucid.system.plugin_import import get_plugin_config, get_plugin_version 
    3333from PyLucid.system.BasePlugin import PyLucidBasePlugin 
    3434from PyLucid.models import Plugin 
     
    134134                    continue 
    135135                try: 
    136                     plugin_cfg = get_plugin_config(self.request, 
    137                         package_name, plugin_name, dissolve_version_string=True 
     136                    plugin_cfg = get_plugin_config( 
     137                        package_name, plugin_name, self.request.debug 
    138138                    ) 
    139139                except Exception, e: 
     
    142142                    self.page_msg("Error: %s" % e) 
    143143                else: 
     144                    plugin_version = get_plugin_version( 
     145                        package_name, plugin_name, self.request.debug 
     146                    ) 
    144147                    uninstalled_plugins.append({ 
    145148                        "plugin_name": plugin_name, 
     
    148151                        "url": plugin_cfg.__url__, 
    149152                        "author": plugin_cfg.__author__, 
    150                         "version": plugin_cfg.__version__, 
     153                        "version": plugin_version, 
    151154                    }) 
    152155 
     
    165168        try: 
    166169            install_plugin( 
    167                 self.request, package_name, plugin_name, active, 
     170                package_name, plugin_name, self.request.debug, active, 
    168171                extra_verbose=False 
    169172            ) 
  • trunk/pylucid/PyLucid/plugins_internal/preference_editor/preference_editor.py

    r1549 r1551  
    1111    ~~~~~~~~~~~~~~~~~ 
    1212    $LastChangedDate$ 
    13     $Rev$ 
    14     $Author$ 
     13    $Rev:1549 $ 
     14    $Author:JensDiemer $ 
    1515 
    1616    :copyleft: 2008 by the PyLucid team. 
     
    4040        Display the sub menu 
    4141        """ 
    42 #        self.context["PAGE"].title = _("Preferences editor") 
     42        plugins = Plugin.objects.exclude(pref_data_string__isnull=True) 
    4343 
    44         items = [] 
    45         plugins = Plugin.objects.all() 
     44        # Add edit link 
    4645        for plugin in plugins: 
    47             if plugin.pref_data_string == None: 
    48                 continue 
    49  
    5046            edit_link = self.URLs.methodLink("edit", args=plugin.id) 
    51  
    52             items.append({ 
    53                 "plugin_name": unicode(plugin), 
    54                 "plugin_description": plugin.description, 
    55                 "edit_link": edit_link, 
    56             }) 
     47            plugin.edit_link = edit_link 
    5748 
    5849        context = { 
    59             "preferences": items, 
    60             "admin_link": self.URLs.adminLink("PyLucid/preference"), 
     50            "plugins": plugins, 
     51            "admin_link": self.URLs.adminLink("PyLucid/Plugin"), 
    6152        } 
    6253        self._render_template("select", context)#, debug=True) 
  • trunk/pylucid/PyLucid/plugins_internal/search/search.py

    r1548 r1551  
    3535 
    3636 
    37 class PreferencesForm(forms.Form): 
    38     min_term_len = forms.IntegerField( 
    39         help_text="Min length of a search term", 
    40         initial=3, min_value=1 
     37# We used preferences values in a newform. We need these values here. 
     38preferences = Plugin.objects.get_preferences(__file__) 
     39 
     40class SearchForm(forms.Form): 
     41    search_string = forms.CharField( 
     42        min_length = preferences["min_term_len"], 
     43        max_length = preferences["max_term_len"], 
    4144    ) 
    42     max_term_len = forms.IntegerField( 
    43         help_text="Max length of a search term", 
    44         initial=50, min_value=1, max_value=200 
    45     ) 
    46     max_results = forms.IntegerField( 
    47         help_text="Number of the paged for the result page", 
    48         initial=20, min_value=1, max_value=200 
    49     ) 
    50     text_cutout_len = forms.IntegerField( 
    51         help_text="The length of the text-hit-cutouts", 
    52         initial=50, min_value=1, max_value=200 
    53     ) 
    54     text_cutout_lines = forms.IntegerField( 
    55         help_text="Max. cutout lines for every search term", 
    56         initial=5, min_value=1, max_value=20 
    57     ) 
    58  
    59 # We used preferences values in a newform. We need these values here. 
    60 try: 
    61     preferences = Plugin.objects.get_preferences(__file__) 
    62 except Plugin.DoesNotExist, e: 
    63     # in _install section? 
    64     pass 
    65 else: 
    66     class SearchForm(forms.Form): 
    67         search_string = forms.CharField( 
    68             min_length = preferences["min_term_len"], 
    69             max_length = preferences["max_term_len"], 
    70         ) 
    7145 
    7246 
  • trunk/pylucid/PyLucid/plugins_internal/search/search_cfg.py

    r1479 r1551  
    1313 
    1414#_____________________________________________________________________________ 
     15# preferences 
     16 
     17from django import newforms as forms 
     18from django.utils.translation import ugettext as _ 
     19 
     20class PreferencesForm(forms.Form): 
     21    min_term_len = forms.IntegerField( 
     22        help_text=_("Min length of a search term"), 
     23        initial=3, min_value=1 
     24    ) 
     25    max_term_len = forms.IntegerField( 
     26        help_text=_("Max length of a search term"), 
     27        initial=50, min_value=1, max_value=200 
     28    ) 
     29    max_results = forms.IntegerField( 
     30        help_text=_("Number of the paged for the result page"), 
     31        initial=20, min_value=1, max_value=200 
     32    ) 
     33    text_cutout_len = forms.IntegerField( 
     34        help_text=_("The length of the text-hit-cutouts"), 
     35        initial=50, min_value=1, max_value=200 
     36    ) 
     37    text_cutout_lines = forms.IntegerField( 
     38        help_text=_("Max. cutout lines for every search term"), 
     39        initial=5, min_value=1, max_value=20 
     40    ) 
     41 
     42#_____________________________________________________________________________ 
    1543# plugin administration data 
    1644 
  • trunk/pylucid/PyLucid/plugins_internal/system_settings/system_settings.py

    r1548 r1551  
    77 
    88    A pseudo plugin for holding the system settings via the plugin preferences. 
    9  
    10     TODO: merge with page_admin ChoiceField -> move it into PyLucid.db.page? 
    119 
    1210    Last commit info: 
     
    2220__version__= "$Rev$" 
    2321 
    24 from django import newforms as forms 
     22#from django import newforms as forms 
    2523#from django.utils.translation import ugettext as _ 
    2624#from django.utils.safestring import mark_safe 
     
    2826from PyLucid.system.BasePlugin import PyLucidBasePlugin 
    2927from PyLucid.models import Page 
    30 from PyLucid.db.page import flat_tree_list 
    31  
    32 def get_parent_choices(): 
    33     """ 
    34     generate a verbose page name tree for the parent choice field. 
    35     """ 
    36     page_list = flat_tree_list() 
    37     choices = [(0, "---[root]---")] 
    38     for page in page_list: 
    39         choices.append((page["id"], page["level_name"])) 
    40     return choices 
    41  
    42 class PreferencesForm(forms.Form): 
    43 #    index_page = forms.IntegerField( 
    44     index_page = forms.ChoiceField( 
    45         choices=get_parent_choices(), 
    46         help_text="The page ID of the index page", 
    47         initial=0 
    48     ) 
    49     auto_shortcuts = forms.BooleanField( 
    50         help_text="Should the shortcut of a page rebuild on every edit?", 
    51         initial=True 
    52     ) 
    53  
    5428 
    5529 
    5630class system_settings(PyLucidBasePlugin): 
    57  
    5831    def lucidTag(self): 
    5932        """ 
    60         Insert a empty search form into the page. 
     33        TODO! 
    6134        """ 
    6235        self.page_msg("Preferences:", preferences) 
  • trunk/pylucid/PyLucid/plugins_internal/system_settings/system_settings_cfg.py

    r1544 r1551  
    1313 
    1414#_____________________________________________________________________________ 
     15# preferences 
     16 
     17from django import newforms as forms 
     18from django.utils.translation import ugettext as _ 
     19 
     20from PyLucid.db.page import PageChoiceField, get_page_choices 
     21 
     22 
     23class PreferencesForm(forms.Form): 
     24    index_page = PageChoiceField( 
     25        widget=forms.Select(choices=get_page_choices()), 
     26        help_text=_("The page ID of the index page"), 
     27        initial=0 
     28    ) 
     29    auto_shortcuts = forms.BooleanField( 
     30        help_text=_("Should the shortcut of a page rebuild on every edit?"), 
     31        initial=True 
     32    ) 
     33 
     34#_____________________________________________________________________________ 
    1535# plugin administration data 
    1636 
  • trunk/pylucid/PyLucid/system/detect_page.py

    r1548 r1551  
    1717""" 
    1818 
    19 from PyLucid.models import Page 
    20 from PyLucid.system.exceptions import AccessDenied, LowLevelError 
    21  
    2219from django.utils.translation import ugettext as _ 
    2320from django.http import Http404, HttpResponseRedirect 
     21 
     22from PyLucid.system.exceptions import AccessDenied, LowLevelError 
     23from PyLucid.models import Page, Plugin 
     24 
    2425 
    2526def get_a_page(): 
    2627    """ 
    2728    Try to get and return a existing page. 
    28     Create a first page, if no page exists. 
    2929    """ 
    3030    try: 
     
    3737 
    3838 
    39 def get_default_page_id(): 
     39def get_default_page_id(request): 
    4040    """ 
    4141    returns the default page id 
    4242    """ 
    4343    try: 
    44         default_page = Preference.objects.get(name__exact="index page") 
    45 #        default_page = "raise!" 
    46         return int(default_page.value) 
     44        preferences = Plugin.objects.get_preferences("system_settings") 
     45        default_page_id = preferences["index_page"] 
     46        return default_page_id 
    4747    except Exception, e: 
    4848        # TODO: make a page message for the admin 
     
    5353 
    5454 
    55 def get_default_page(): 
    56     page_id = get_default_page_id() 
     55def get_default_page(request): 
     56    page_id = get_default_page_id(request) 
    5757    try: 
    5858#        page_id = "wrong test" 
     
    7676    if page_name == "": 
    7777        # Index Seite wurde aufgerufen. Zumindest bei poor-modrewrite 
    78         return get_default_page() 
     78        return get_default_page(request) 
    7979 
    8080    # bsp/und%2Foder -> ['bsp', 'und%2Foder'] 
  • trunk/pylucid/PyLucid/system/plugin_import.py

    r1548 r1551  
    11# -*- coding: utf-8 -*- 
    2  
    32""" 
    43    PyLucid Plugin Manager 
     
    5251        page_msg(getattr(plugin_config, item)) 
    5352 
    54 def get_plugin_config(request, package_name, plugin_name, 
    55                             dissolve_version_string=False, extra_verbose=False): 
     53def get_plugin_config(package_name, plugin_name, debug, extra_verbose=False): 
    5654    """ 
    5755    imports the plugin and the config plugin and returns a merge config-object 
     
    6159    """ 
    6260    config_name = "%s_cfg" % plugin_name 
    63     debug = request.user.is_superuser or request.debug 
     61    from_name = ".".join([package_name, plugin_name, config_name]) 
     62    if extra_verbose: 
     63        print "from %s import %s" % (from_name, config_name) 
    6464 
    65     def get_plugin(object_name): 
    66         from_name = ".".join([package_name, plugin_name, object_name]) 
    67         if extra_verbose: 
    68             print "from %s import %s" % (from_name, object_name) 
    69         return _import(from_name, object_name, debug) 
    70  
    71     config_plugin = get_plugin(config_name) 
    72  
    73     if dissolve_version_string: 
    74         plugin_plugin = get_plugin(plugin_name) 
    75  
    76         plugin_version = getattr(plugin_plugin, "__version__", None) 
    77         if plugin_version: 
    78             # Cleanup a SVN Revision Number 
    79             plugin_version = plugin_version.strip("$ ") 
    80         config_plugin.__version__ = plugin_version 
     65    config_plugin = _import(from_name, config_name, debug) 
    8166 
    8267    return config_plugin 
     68 
     69def get_plugin_version(package_name, plugin_name, debug): 
     70    plugin_plugin = get_plugin_module(package_name, plugin_name, debug) 
     71 
     72    plugin_version = getattr(plugin_plugin, "__version__", "") 
     73 
     74    # Cleanup a SVN Revision Number 
     75    plugin_version = plugin_version.strip("$ ") 
     76 
     77    return plugin_version 
    8378 
    8479 
     
    8782 
    8883 
    89  
    90  
  • trunk/pylucid/PyLucid/system/plugin_manager.py

    r1548 r1551  
    11# -*- coding: utf-8 -*- 
    2  
    32""" 
    43    PyLucid Plugin Manager 
     
    3534 
    3635#from PyLucid.db.preferences import Preferences, preference_cache, PreferenceDoesntExist 
    37 from PyLucid.system.plugin_import import get_plugin_module, get_plugin_config 
     36from PyLucid.system.plugin_import import get_plugin_module, get_plugin_config, \ 
     37                                                            get_plugin_version 
    3838from PyLucid.system.exceptions import * 
    3939from PyLucid.models import Plugin 
     
    6868        return 
    6969 
    70     plugin_config = get_plugin_config(request, 
     70    plugin_config = get_plugin_config( 
    7171        package_name = plugin.package_name, 
    7272        plugin_name = plugin.plugin_name, 
    73         dissolve_version_string=False 
     73        debug = request.debug, 
    7474    ) 
    7575#    context["page_msg"](plugin_config.plugin_manager_data) 
     
    200200 
    201201 
    202 def _install_plugin(request, package_name, plugin_name, plugin_config, active, 
     202def _install_plugin(package_name, plugin_name, plugin_config, active, 
    203203                                                                extra_verbose): 
    204204    """ 
     
    217217        active = active, 
    218218    ) 
    219     debug = request.user.is_superuser or request.debug 
    220     plugin_module = get_plugin_module(package_name, plugin_name, debug) 
    221     pref_form = getattr(plugin_module, "PreferencesForm", None) 
     219 
     220    pref_form = getattr(plugin_config, "PreferencesForm", None) 
    222221    if pref_form: 
    223222        # plugin module has a preferences newform class 
    224223        plugin.init_pref_form(pref_form) 
    225  
    226224 
    227225    plugin.save() 
     
    232230 
    233231 
    234 def install_plugin(request, package_name, plugin_name, active, 
     232def install_plugin(package_name, plugin_name, debug, active, 
    235233                                                        extra_verbose=False): 
    236234    """ 
    237235    Get the config object from disk and insert the plugin into the database 
    238236    """ 
    239     plugin_config = get_plugin_config(request, 
    240         package_name, plugin_name, 
    241         dissolve_version_string=True, extra_verbose=extra_verbose 
     237    plugin_config = get_plugin_config( 
     238        package_name, plugin_name, debug, extra_verbose=extra_verbose 
    242239    ) 
    243240    if extra_verbose: 
     
    255252 
    256253    plugin = _install_plugin( 
    257         request, package_name, plugin_name, 
    258         plugin_config, active, extra_verbose 
     254        package_name, plugin_name, plugin_config, active, extra_verbose 
    259255    ) 
    260256 
     
    284280 
    285281        try: 
    286             install_plugin(request, 
    287                 package_name, plugin_name, 
     282            install_plugin( 
     283                package_name, plugin_name, request.debug, 
    288284                active=True, extra_verbose=extra_verbose 
    289285            ) 
    290286        except Exception, e: 
     287            # FIXME 
    291288            print "Error:" 
    292289            import traceback