preference_forms.py :  » Content-Management-Systems » PyLucid » PyLucid_standalone » pylucid_project » pylucid_plugins » lexicon » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Content Management Systems » PyLucid 
PyLucid » PyLucid_standalone » pylucid_project » pylucid_plugins » lexicon » preference_forms.py
# coding: utf-8

from django import forms
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext

# http://code.google.com/p/django-tagging/
from tagging.utils import parse_tag_input

from pylucid_project.utils.site_utils import SitePreselectPreference

from dbpreferences.forms import DBPreferencesBaseForm

TAG_INPUT_HELP_URL = \
"http://google.com/search?q=cache:django-tagging.googlecode.com/files/tagging-0.2-overview.html#tag-input"

SKIP_TAGS_CACHE = None

class LexiconPrefForm(SitePreselectPreference, DBPreferencesBaseForm):
    skip_tags = forms.CharField(
        required=False,
        initial="a input h1 h2 h3 h4 h5 h6 textarea fieldset script",
        help_text=mark_safe(
            _('Don\'t replace a word if it exist in the given html tags.'
            ' (tagging field <a href="%s" class="openinwindow"'
            ' title="Information about splitting.">format help</a>)') % TAG_INPUT_HELP_URL
        )
    )

    def clean(self, *args, **kwargs):
        """ hook into admin change validation for cleaning SKIP_TAGS_CACHE """
        global SKIP_TAGS_CACHE
        SKIP_TAGS_CACHE = None
#        print "*** Clean skip tags cache"
        return super(LexiconPrefForm, self).clean(*args, **kwargs)

    def get_skip_tags(self):
        global SKIP_TAGS_CACHE
        if SKIP_TAGS_CACHE is None:
#            print "*** Fill skip tags cache"
            self.get_preferences()
            skip_tag_string = self.data.get("skip_tags", "a input h1 h2 h3 h4 h5 h6 textarea fieldset")
            SKIP_TAGS_CACHE = parse_tag_input(skip_tag_string)

#        print "*** skip tags: %r" % SKIP_TAGS_CACHE

        return SKIP_TAGS_CACHE

    class Meta:
        app_label = 'lexicon'
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.