Show
Ignore:
Timestamp:
05/01/08 12:24:21 (7 months ago)
Author:
JensDiemer
Message:

put the plugin preferences into the plugin model.
TODO: update detect_page and set system_settings at install.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/plugins_internal/find_and_replace/find_and_replace.py

    r1544 r1548  
    2929 
    3030from django import newforms as forms 
     31from django.utils.safestring import mark_safe 
    3132from django.utils.translation import ugettext as _ 
    32 from django.utils.safestring import mark_safe 
    3333 
     34from PyLucid.system.BasePlugin import PyLucidBasePlugin 
    3435from PyLucid.models import Page, Template, Style 
    35 from PyLucid.system.BasePlugin import PyLucidBasePlugin 
     36#from PyLucid.db.preferences import get_pref_dict 
     37from PyLucid.tools.Diff import diff_lines 
    3638from PyLucid.tools.utils import escape 
    37 from PyLucid.tools.Diff import diff_lines 
    3839 
    39 # How min/max long must a search term be? 
    40 MIN_TERM_LEN = 2 
    41 MAX_TERM_LEN = 150 
    4240 
    4341class PreferencesForm(forms.Form): 
     
    5957) 
    6058 
     59 
     60# We used preferences values in a newform. We need these values here. 
     61try: 
     62    preferences = Plugin.objects.get_preferences(__file__) 
     63except Plugin.DoesNotExist, e: 
     64    # in _install section? 
     65    pass 
     66else: 
     67    min_term_len = preferences["min_term_len"] 
     68    max_term_len = preferences["max_term_len"] 
     69 
     70 
    6171class FindReplaceForm(forms.Form): 
    6272    # TODO: min und max should be saved in the prefereces. 
    6373    find_string = forms.CharField( 
    64         min_length = MIN_TERM_LEN, max_length = MAX_TERM_LEN, 
     74        min_length = min_term_len, max_length = max_term_len, 
    6575    ) 
    6676    replace_string = forms.CharField( 
    67         min_length = MIN_TERM_LEN, max_length = MAX_TERM_LEN, 
     77        min_length = min_term_len, max_length = max_term_len, 
    6878    ) 
    6979    type = forms.ChoiceField( 
     
    7989 
    8090    def find_and_replace(self): 
    81         self.page_msg("Preferences:", self.preferences) 
    82  
    8391        context = {} 
    8492        if self.request.method == 'POST':