Changeset 1283

Show
Ignore:
Timestamp:
10/23/07 13:12:39 (12 months ago)
Author:
JensDiemer
Message:

-"add_css_tag" for _command, too.
-rename settings.CSS_DIV_CLASS_NAME -> settings.CSS_PLUGIN_CLASS_NAME

Location:
trunk/pylucid/PyLucid
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/defaulttags/lucidTag.py

    r1264 r1283  
    2525from PyLucid.system.plugin_manager import run 
    2626from PyLucid.system.response import SimpleStringIO 
    27 from PyLucid.tools.shortcuts import makeUnique 
     27from PyLucid.system.context_processors import add_css_tag 
    2828 
    2929from django.conf import settings 
     
    6262        ) 
    6363 
    64     def _add_unique_div(self, context, content): 
    65         """ 
    66         Add a html DIV tag with a unique CSS-ID and a class name defined in 
    67         the settings.py 
    68         """ 
    69         id = self.plugin_name + "_" + self.method_name 
    70         id = makeUnique(id, context["CSS_ID_list"]) 
    71         context["CSS_ID_list"].append(id) 
    72  
    73         try: 
    74             return u'<div class="%s %s" id="%s">\n%s\n</div>\n' % ( 
    75                 settings.CSS_DIV_CLASS_NAME, self.plugin_name, id, content 
    76             ) 
    77         except UnicodeDecodeError: 
    78             # FIXME: In some case (with mysql_old) we have trouble here. 
    79             # I get this traceback on www.jensdiemer.de like this: 
    80             # 
    81             #Traceback (most recent call last): 
    82             #File ".../django/template/__init__.py" in render_node 
    83             #    750. result = node.render(context) 
    84             #File ".../PyLucid/defaulttags/lucidTag.py" in render 
    85             #    102. content = self._add_unique_div(context, content) 
    86             #File ".../PyLucid/defaulttags/lucidTag.py" in _add_unique_div 
    87             #    73. return u'<div class="%s" id="%s">\n%s\n</div>\n' % ( 
    88             # 
    89             #UnicodeDecodeError at /FH-D-sseldorf/ 
    90             #'ascii' codec can't decode byte 0xc3 in position 55: ordinal not in range(128) 
    91             # 
    92             #content += "UnicodeDecodeError hack active!" 
    93             return '<div class="%s %s" id="%s">\n%s\n</div>\n' % ( 
    94                 settings.CSS_DIV_CLASS_NAME, str(self.plugin_name), str(id), 
    95                 content 
    96             ) 
    97  
    98  
    9964    def render(self, context): 
    10065        local_response = SimpleStringIO() 
     
    12085            raise AssertionError(msg) 
    12186 
    122         content = self._add_unique_div(context, content) 
     87        content = add_css_tag( 
     88            context, content, self.plugin_name, self.method_name 
     89        ) 
    12390 
    12491        return content 
  • trunk/pylucid/PyLucid/index.py

    r1228 r1283  
    3636from PyLucid.system.URLs import URLs 
    3737from PyLucid.system.context_processors import add_dynamic_context 
     38from PyLucid.system.context_processors import add_css_tag 
    3839 
    3940from PyLucid.tools.content_processors import apply_markup, \ 
     
    274275#    print "---" 
    275276 
     277    page_content = add_css_tag( 
     278        context, page_content, module_name, method_name 
     279    ) 
     280 
    276281    return _render_cms_page(context, page_content) 
    277282 
  • trunk/pylucid/PyLucid/settings_example.py

    r1221 r1283  
    382382ALLOW_SEND_MAILS = True 
    383383 
    384 # Every Plugin output clasp around with a html DIV tag. 
    385 # Here you can defined witch CSS class name the DIV tag should used: 
    386 CSS_DIV_CLASS_NAME = "PyLucidPlugins" 
     384# Every Plugin output gets a html SPAN tag around. 
     385# Here you can defined witch CSS class name the tag should used: 
     386CSS_PLUGIN_CLASS_NAME = "PyLucidPlugins" 
  • trunk/pylucid/PyLucid/system/context_processors.py

    r1209 r1283  
    77 
    88from PyLucid import PYLUCID_VERSION_STRING 
     9from PyLucid.tools.shortcuts import makeUnique 
     10 
    911from django.conf import settings 
    1012 
     
    5557 
    5658 
     59 
     60def add_css_tag(context, content, plugin_name, method_name): 
     61    """ 
     62    Add a unique CSS-ID and a class name defined in the settings.py 
     63    """ 
     64    id = plugin_name + "_" + method_name 
     65    id = makeUnique(id, context["CSS_ID_list"]) 
     66    context["CSS_ID_list"].append(id) 
     67    class_name = getattr(settings, "CSS_PLUGIN_CLASS_NAME", "PyLucidPlugins") 
     68 
     69    try: 
     70        return u'<span class="%s %s" id="%s">\n%s\n</span>\n' % ( 
     71            class_name, plugin_name, id, content 
     72        ) 
     73    except UnicodeDecodeError: 
     74        # FIXME: In some case (with mysql_old) we have trouble here. 
     75        # I get this traceback on www.jensdiemer.de like this: 
     76        # 
     77        #Traceback (most recent call last): 
     78        #File ".../django/template/__init__.py" in render_node 
     79        #    750. result = node.render(context) 
     80        #File ".../PyLucid/defaulttags/lucidTag.py" in render 
     81        #    102. content = self._add_unique_div(context, content) 
     82        #File ".../PyLucid/defaulttags/lucidTag.py" in _add_unique_div 
     83        #    73. return u'<div class="%s" id="%s">\n%s\n</div>\n' % ( 
     84        # 
     85        #UnicodeDecodeError at /FH-D-sseldorf/ 
     86        #'ascii' codec can't decode byte 0xc3 in position 55: ordinal not in range(128) 
     87        # 
     88        #content += "UnicodeDecodeError hack active!" 
     89        return '<span class="%s %s" id="%s">\n%s\n</span>\n' % ( 
     90            class_name, str(plugin_name), str(id), 
     91            content 
     92        ) 
  • trunk/pylucid/PyLucid/tools/content_processors.py

    r1276 r1283  
    108108 
    109109 
     110 
    110111def replace_add_data(context, content): 
    111112    """