Show
Ignore:
Timestamp:
06/29/07 16:05:08 (3 years ago)
Author:
JensDiemer
Message:

* new additional Stylesheet/JavaScript handling. A middleware puts the collected data into the page.
* middleware "pagestats" renamed to "additional_content".
* some code cleanup

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.8(django)/PyLucid/system/BaseModule.py

    r1111 r1127  
    33 
    44""" 
    5 Basis Modul von den andere Module erben können 
     5    PyLucid BaseModule 
     6    ~~~~~~~~~~~~~~~~~~ 
    67 
    7 Bsp.: 
     8    The base Plugin object. Every Plugin can inherit. 
    89 
    9 from PyLucid.system.BaseModule import PyLucidBaseModule 
     10    e.g.: 
    1011 
    11 class Bsp(PyLucidBaseModule): 
    12     def __init__(self, *args, **kwargs): 
    13         super(Bsp, self).__init__(*args, **kwargs) 
     12        from PyLucid.system.BaseModule import PyLucidBaseModule 
     13 
     14        class Bsp(PyLucidBaseModule): 
     15            def __init__(self, *args, **kwargs): 
     16                super(Bsp, self).__init__(*args, **kwargs) 
     17 
     18 
     19    Last commit info: 
     20    ~~~~~~~~~~~~~~~~~ 
     21    $LastChangedDate$ 
     22    $Rev$ 
     23    $Author$ 
     24 
     25    :copyright: 2007 by Jens Diemer 
     26    :license: GNU GPL, see LICENSE for more details 
     27""" 
    1428 
    1529 
    1630 
    17 Last commit info: 
    18 ---------------------------------- 
    19 $LastChangedDate$ 
    20 $Rev$ 
    21 $Author$ 
    22  
    23 Created by Jens Diemer 
    24  
    25 license: 
    26     GNU General Public License v2 or above 
    27     http://www.opensource.org/licenses/gpl-license.php 
    28 """ 
    29  
    30 from PyLucid.models import PagesInternal 
    31 from PyLucid.tools.content_processors import apply_markup, render_template 
    32  
    33  
    34 #______________________________________________________________________________ 
     31from PyLucid.db.internal_pages import get_internal_page 
     32from PyLucid.tools.content_processors import apply_markup, \ 
     33                                                        render_string_template 
    3534 
    3635 
     
    6564 
    6665    def _get_template(self, internal_page_name): 
    67         plugin_name = self.__class__.__name__ # Get the superior class name 
    68  
    69         internal_page_name = ".".join([plugin_name, internal_page_name]) 
    70  
    71         # django bug work-a-round 
    72         # http://groups.google.com/group/django-developers/browse_thread/thread/e1ed7f81e54e724a 
    73         internal_page_name = internal_page_name.replace("_", " ") 
    74  
    75         try: 
    76             return PagesInternal.objects.get(name = internal_page_name) 
    77         except PagesInternal.DoesNotExist, err: 
    78             msg = "internal page '%s' not found! (%s)" % (internal_page_name, err) 
    79             raise PagesInternal.DoesNotExist(msg) 
    80  
     66        """ 
     67        retuned the internal page object 
     68        Get the plugin name throu the superior class name 
     69        """ 
     70        plugin_name = self.__class__.__name__ 
     71        internal_page = get_internal_page(plugin_name, internal_page_name) 
     72        return internal_page 
    8173 
    8274    def _add_js_css_data(self, internal_page): 
     
    134126        """ 
    135127        html = self.__render(template, context, debug) 
    136  
    137128        self.response.write(html) 
    138129 
    139130    def __render(self, content, context, debug=False): 
    140131        """ 
    141         render the string with the given context 
     132        render the content string with the given context and returned it. 
    142133        -debug the context, if debug is on. 
    143         -prepare the context 
    144         -retunted the rendered page 
    145134        """ 
    146135        if debug: 
    147136            self._debug_context(context, content) 
    148137 
    149         html = render_template(content, self.context, context) 
     138        html = render_string_template(content, context) 
    150139        return html 
    151140