Changeset 2022

Show
Ignore:
Timestamp:
06/09/09 16:15:25 (9 months ago)
Author:
JensDiemer
Message:

* rewrite headfile stuff.
* add own jQuery.js
* Use the jQuery part of the superfish menu, too.
*

Location:
branches/0.9/pylucid_project
Files:
5 added
1 removed
21 modified
3 moved

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/apps/pylucid/admin.py

    r2000 r2022  
    115115 
    116116class EditableHtmlHeadFileAdmin(UpdateInfoBaseAdmin, VersionAdmin): 
    117     list_display = ("filename", "description", "lastupdatetime", "lastupdateby") 
    118     list_display_links = ("filename", "description") 
     117    list_display = ("filepath", "description", "lastupdatetime", "lastupdateby") 
     118    list_display_links = ("filepath", "description") 
    119119    list_filter = ("site",) 
    120120 
  • branches/0.9/pylucid_project/apps/pylucid/app_settings.py

    r2002 r2022  
    1111CSS_PLUGIN_CLASS_NAME = "PyLucidPlugins" 
    1212 
    13 EDITABLE_HEAD_LINK_TEMPLATE = "pylucid/headlink_%s_file.html" 
     13HEADFILE_INLINE_TEMPLATES = "pylucid/headfile_%s_inline.html" 
     14HEADFILE_LINK_TEMPLATES = "pylucid/headfile_%s_link.html" 
    1415HEAD_FILES_URL_PREFIX = "headfile" 
     16 
     17# File cache directory used for EditableHtmlHeadFile 
     18# filesystem path is: MEDIA_ROOT + PYLUCID_MEDIA_DIR + CACHE_DIR 
     19# URL if not cacheable in filesystem: /HEAD_FILES_URL_PREFIX/filepath 
     20# URL if written into filesystem path: MEDIA_URL + PYLUCID_MEDIA_DIR + CACHE_DIR + filepath 
     21CACHE_DIR = "headfile_cache" # store path:  
    1522 
    1623# i18n stuff: 
     
    2128# All PyLucid media files stored in a sub directory under the django media 
    2229# path. Used for building filesystem path and URLs. 
    23 # filesystem path: MEDIA_ROOT + PYLUCID_MEDIA_SUBDIR 
    24 # URLs: MEDIA_URL + PYLUCID_MEDIA_SUBDIR 
     30# filesystem path: MEDIA_ROOT + PYLUCID_MEDIA_DIR 
     31# URLs: MEDIA_URL + PYLUCID_MEDIA_DIR 
    2532PYLUCID_MEDIA_DIR = "PyLucid" # Without slashes at begin/end! 
  • branches/0.9/pylucid_project/apps/pylucid/defaulttags/lucidTag.py

    r1951 r2022  
    138138        if response==None: 
    139139            return u"" 
    140         assert(isinstance(response, HttpResponse), "pylucid plugins must return a HttpResponse instance!") 
    141         assert(response.status_code == 200, "Response status code != 200 ???") 
    142          
    143         return response.content 
     140        elif isinstance(response, basestring): 
     141            return response 
     142        elif isinstance(response, HttpResponse): 
     143            assert(response.status_code == 200, "Response status code != 200 ???") 
     144            return response.content 
     145         
     146        raise RuntimeError("pylucid plugins must return None, a basestring or a HttpResponse instance!") 
    144147#         
    145148#        # callback is either a string like 'foo.views.news.stories.story_detail' 
  • branches/0.9/pylucid_project/apps/pylucid/defaulttags/__init__.py

    r1889 r2022  
    2626from django.templatetags.i18n import do_translate, do_block_translate 
    2727 
    28 from pylucid_project.apps.pylucid.defaulttags.lucidTag import lucidTag 
     28from pylucid_project.apps.pylucid.defaulttags import lucidTag 
     29from pylucid_project.apps.pylucid.defaulttags import extraheadBlock 
    2930#from PyLucid.template_addons.lucidTag import lucidTag 
    3031#from PyLucid.template_addons.blocktag_pygments import sourcecode 
     
    3435register = Library() 
    3536 
    36 register.tag(lucidTag) 
     37register.tag(lucidTag.lucidTag) 
     38register.tag("extrahead", extraheadBlock.do_extrahead) 
     39#register.tag(extraheadBlock.ExtraheadNode) 
    3740#register.tag(sourcecode) 
    3841#register.filter(chmod_symbol) 
  • branches/0.9/pylucid_project/apps/pylucid/models.py

    r2002 r2022  
    2121 
    2222import os 
     23import warnings 
     24import posixpath 
     25import mimetypes 
    2326from xml.sax.saxutils import escape 
    2427 
     
    3336 
    3437from pylucid.system.auto_model_info import UpdateInfoBaseModel, UpdateInfoBaseModelManager 
    35  
     38from pylucid.system import headfile 
    3639 
    3740 
     
    426429#------------------------------------------------------------------------------ 
    427430 
    428  
    429431class Design(UpdateInfoBaseModel): 
    430432    """ 
     
    461463#------------------------------------------------------------------------------ 
    462464 
     465class EditableHtmlHeadFileManager(UpdateInfoBaseModelManager): 
     466    def get_HeadfileLink(self, filename): 
     467        """ 
     468        returns a pylucid.system.headfile.Headfile instance 
     469        """ 
     470        db_instance = self.get(filename=filename) 
     471        return headfile.HeadfileLink(filename=db_instance.filename)#, content=db_instance.content) 
     472         
    463473 
    464474class EditableHtmlHeadFile(UpdateInfoBaseModel): 
     
    471481        createby       -> ForeignKey to user who creaded this entry 
    472482        lastupdateby   -> ForeignKey to user who has edited this entry 
    473      
    474     TODO: the save() method should be try to store the file into media path! 
    475     """    
     483    """ 
     484    objects = EditableHtmlHeadFileManager() 
     485     
    476486    site = models.ManyToManyField(Site, default=[settings.SITE_ID]) 
    477487    on_site = CurrentSiteManager() 
    478488     
    479     filename = models.CharField(max_length=150) 
     489    filepath = models.CharField(max_length=256) 
     490    mimetype = models.CharField(max_length=64) 
     491    html_attributes = models.CharField(max_length=256, null=False, blank=True, 
     492        help_text='Additional html tag attributes (CSS example: media="screen")' 
     493    ) 
    480494    description = models.TextField(null=True, blank=True) 
    481495    content = models.TextField() 
    482  
    483     def get_mimetype(self): 
    484         if self.filename.endswith(".css"): 
     496     
     497    def get_cachepath(self): 
     498        """ 
     499        filesystem path with filename. 
     500        TODO: Install section sould create the directories! 
     501        """ 
     502        return os.path.join( 
     503            settings.MEDIA_ROOT, settings.PYLUCID.PYLUCID_MEDIA_DIR, settings.PYLUCID.CACHE_DIR, 
     504            self.filepath 
     505        ) 
     506         
     507    def save_cache_file(self): 
     508        """ Try to cache the head file into filesystem (Only worked, if python process has write rights) """ 
     509        cachepath = self.get_cachepath() 
     510        try: 
     511            f = file(cachepath, "w") 
     512            f.write(self.content) 
     513            f.close() 
     514        except Exception, err: 
     515            warnings.warn("Can't cache EditableHtmlHeadFile into %r: %s" % (cachepath, err)) 
     516        else: 
     517            if settings.DEBUG: 
     518                warnings.warn("EditableHtmlHeadFile cached successful into: %r" % cachepath) 
     519                 
     520    def get_headfilelink(self): 
     521        """ Get the link url to this head file. """ 
     522        cachepath = self.get_cachepath() 
     523        if os.path.isfile(cachepath): 
     524            # The file exist in media path -> Let the webserver send this file ;) 
     525            url = posixpath.join( 
     526                settings.MEDIA_URL, settings.PYLUCID.PYLUCID_MEDIA_DIR, settings.PYLUCID.CACHE_DIR, 
     527                self.filepath 
     528            ) 
     529        else: 
     530            # not cached into filesystem -> use pylucid.views.send_head_file for it 
     531            url = reverse('PyLucid-send_head_file', kwargs={"filepath":self.filepath}) 
     532        return headfile.HeadfileLink(url) 
     533 
     534    def auto_mimetype(self): 
     535        """ returns the mimetype for the current filename """ 
     536        fileext = os.path.splitext(self.filepath)[1].lower() 
     537        if fileext == ".css": 
    485538            return u"text/css" 
    486         elif self.filename.endswith(".js"): 
     539        elif fileext == ".js": 
    487540            return u"text/javascript" 
    488541        else: 
    489             from mimetypes import guess_type 
    490             returnguess_type(self.filename)[0] or u"application/octet-stream"             
    491  
    492     def get_head_template(self): 
    493         """ returns the template name for building the html head link. """ 
    494         ext = os.path.splitext(self.filename)[1].strip(".") 
    495         return settings.PYLUCID.EDITABLE_HEAD_LINK_TEMPLATE % ext 
    496  
    497     def get_head_link(self): 
    498         """ 
    499         TODO: Should check if the file was saved into media path 
    500         """ 
    501         template_name = self.get_head_template() 
    502         filename = self.filename 
    503         url = reverse("PyLucid-send_head_file", kwargs={"filename": filename}) 
    504         head_link = render_to_string(template_name, {'url': url}) 
    505         return head_link 
    506  
    507     def __unicode__(self): 
    508         return u"EditableHtmlHeadFile '%s'" % self.filename 
    509  
    510     class Meta: 
    511         ordering = ("filename",) 
     542            mimetypes.guess_type(self.filepath)[0] or u"application/octet-stream" 
     543 
     544    def save(self, *args, **kwargs): 
     545        if not self.mimetype: 
     546            # autodetect mimetype 
     547            self.mimetype = self.auto_mimetype() 
     548 
     549        # Try to cache the head file into filesystem (Only worked, if python process has write rights) 
     550        self.save_cache_file() 
     551 
     552        return super(EditableHtmlHeadFile, self).save(*args, **kwargs) 
     553 
     554    def __unicode__(self): 
     555        return u"EditableHtmlHeadFile '%s'" % self.filepath 
     556 
     557    class Meta: 
     558        ordering = ("filepath",) 
    512559 
    513560 
  • branches/0.9/pylucid_project/apps/pylucid/system/pylucid_plugin.py

    r2021 r2022  
    181181    for plugin_name in plugin_names: 
    182182        # Get the middleware class from the plugin 
    183         middleware_class = _get_middleware_class(plugin_name) 
     183        try: 
     184            middleware_class = _get_middleware_class(plugin_name) 
     185        except ImportError, err: 
     186            request.page_msg.error("Can't import context middleware '%s': %s" % (plugin_name, err)) 
     187            continue 
     188         
    184189        # make a instance  
    185190        instance = middleware_class(request, context) 
     
    192197    """ 
    193198    context = request.PYLUCID.context 
     199    context_middlewares = context["context_middlewares"] 
    194200    def replace(match): 
    195201        plugin_name = match.group(1) 
    196         middleware_class_instance = context["context_middlewares"][plugin_name] 
     202        try: 
     203            middleware_class_instance = context_middlewares[plugin_name] 
     204        except KeyError, err: 
     205            return "[Error: context middleware %r doesn't exist!]" % plugin_name 
     206         
    197207        response = middleware_class_instance.render() 
    198208        if response == None: 
  • branches/0.9/pylucid_project/apps/pylucid/templates/admin/base_site.html

    r2020 r2022  
    77<!-- app_extrahead block start --> 
    88{# stylesheets for all PyLucid views #} 
    9 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> 
    10  
     9<script type="text/javascript" src="{{ PyLucid_media_url }}jquery.js"></script> 
    1110<link rel="stylesheet" type="text/css" media="screen" href="{{ PyLucid_media_url }}superfish/superfish.css" /> 
    1211<link rel="stylesheet" type="text/css" media="screen" href="{{ PyLucid_media_url }}superfish/admin_design.css" /> 
     
    5655{% block pretitle %} 
    5756<!-- app pretitle block start --> 
     57{% if request.user.is_authenticated %} 
    5858<ul class="sf-menu"> 
    5959    <li class="current"> 
    60         <a href="/">&lt;&lt; back to root dev page</a> 
     60        <a href="/">&lt;&lt; back to "/" root page</a> 
    6161    </li> 
    6262    <li> 
     
    8484    </li> 
    8585</ul> 
     86{% endif %} 
    8687<!-- app pretitle block end --> 
    8788{% endblock %} 
  • branches/0.9/pylucid_project/apps/pylucid/urls.py

    r1975 r2022  
    2828    url(r'^$', views.root_page, name='PyLucid-root_page'), 
    2929     
    30     url(r'^%s/(?P<filename>[\w/\.]{4,})?$' % settings.PYLUCID.HEAD_FILES_URL_PREFIX, views.send_head_file, 
     30    url(r'^%s/(?P<filepath>[\w/\.]{4,})?$' % settings.PYLUCID.HEAD_FILES_URL_PREFIX, views.send_head_file, 
    3131        name='PyLucid-send_head_file' 
    3232    ), 
  • branches/0.9/pylucid_project/apps/pylucid/views.py

    r2012 r2022  
    174174 
    175175 
    176 def send_head_file(request, filename): 
     176def send_head_file(request, filepath): 
    177177    """ 
    178178    Sending a headfile 
     
    180180    """ 
    181181    try: 
    182         headfile = EditableHtmlHeadFile.objects.get(filename=filename) 
     182        headfile = EditableHtmlHeadFile.objects.get(filepath=filepath) 
    183183    except EditableHtmlHeadFile.DoesNotExist: 
    184184        if settings.DEBUG: 
    185             request.page_msg.error("Headfile %r not found!" % filename) 
     185            request.page_msg.error("Headfile %r not found!" % filepath) 
    186186        raise http.Http404 
    187187     
    188     mimetype = headfile.get_mimetype() 
    189188    content = headfile.content 
    190      
     189    mimetype = headfile.mimetype     
    191190    return http.HttpResponse(content, mimetype=mimetype) 
    192191 
  • branches/0.9/pylucid_project/apps/pylucid_update/views.py

    r2002 r2022  
    11# coding: utf-8 
     2 
     3import posixpath 
    24 
    35from django.conf import settings 
     
    8082    for style in Style08.objects.all(): 
    8183        new_staticfile, created = EditableHtmlHeadFile.objects.get_or_create(request, 
    82             filename = settings.SITE_TEMPLATE_PREFIX + style.name + ".css", 
     84            filepath = settings.SITE_TEMPLATE_PREFIX + style.name + ".css", 
    8385            defaults = { 
    8486                "description": style.description, 
     
    265267        content = template.content 
    266268 
    267         content = replace(content, out,"{% lucidTag page_style %}", "{% lucidTag head_files %}") 
     269        new_head_file_tag = ( 
     270            '<script src="%(url)s"' 
     271            ' onerror="JavaScript:alert(\'Error loading file [%(url)s] !\');"' 
     272            ' type="text/javascript" /></script>\n' 
     273            '<!-- ContextMiddleware extrahead -->\n' 
     274        ) % { 
     275            "url": posixpath.join(settings.MEDIA_URL, settings.PYLUCID.PYLUCID_MEDIA_DIR, "jquery.js") 
     276        } 
     277         
     278        content = replace(content, out,"{% lucidTag page_style %}", new_head_file_tag) 
     279        # temp in developer version: 
     280        content = replace(content, out,"{% lucidTag head_files %}", new_head_file_tag) 
     281        content = replace(content, out,"<!-- ContextMiddleware head_files -->", new_head_file_tag) 
     282         
    268283        content = replace(content, out,"{% lucidTag back_links %}", "<!-- ContextMiddleware breadcrumb -->") 
    269284        content = replace(content, out, 
     
    335350    additional_styles, origin = find_template_source("pylucid_update/additional_styles.css") 
    336351         
    337     styles = EditableHtmlHeadFile.objects.filter(filename__istartswith=settings.SITE_TEMPLATE_PREFIX) 
    338     styles = styles.filter(filename__iendswith=".css") 
     352    styles = EditableHtmlHeadFile.objects.filter(filepath__istartswith=settings.SITE_TEMPLATE_PREFIX) 
     353    styles = styles.filter(filepath__iendswith=".css") 
    339354    for style in styles:        
    340         out.write("\nUpdate Styles: '%s'" % style.filename) 
     355        out.write("\nUpdate Styles: '%s'" % style.filepath) 
    341356         
    342357        content = style.content 
  • branches/0.9/pylucid_project/manage.py

    r1972 r2022  
    11#!/usr/bin/env python 
     2# coding: utf-8 
    23 
    34""" 
  • branches/0.9/pylucid_project/pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html

    r2019 r2022  
    11{% extends "pylucid/css_anchor_div.html" %} 
    22 
     3 
    34{% block plugin_content %} 
    4 <link rel="stylesheet" type="text/css" media="screen" href="{{ PyLucid_media_url }}superfish.css" /> 
     5 
     6{% extrahead %} 
     7<link rel="stylesheet" type="text/css" media="screen" href="{{ PyLucid_media_url }}superfish/superfish.css" onerror="JavaScript:alert('{{ PyLucid_media_url }}superfish/superfish.css');" /> 
     8<link rel="stylesheet" type="text/css" media="screen" href="{{ PyLucid_media_url }}superfish/admin_design.css" onerror="JavaScript:alert('{{ PyLucid_media_url }}superfish/admin_design.css');" /> 
     9<script type="text/javascript" src="{{ PyLucid_media_url }}superfish/superfish.js" onerror="JavaScript:alert('{{ PyLucid_media_url }}superfish/superfish.js');" ></script> 
     10<script type="text/javascript" src="{{ PyLucid_media_url }}superfish/pylucid_superfish_init.js" onerror="JavaScript:alert('{{ PyLucid_media_url }}superfish/pylucid_superfish_init.js');" ></script> 
     11<style type="text/css"> 
     12<!-- 
     13/* setup superfish background urls */ 
     14.sf-sub-indicator { 
     15    background: url('{{ PyLucid_media_url }}superfish/arrows-ffffff.png') no-repeat -10px -100px; /* 8-bit indexed alpha png. IE6 gets solid image only */ 
     16} 
     17.sf-shadow ul { 
     18    background: url('{{ PyLucid_media_url }}superfish/shadow.png') no-repeat bottom right; 
     19} 
     20--> 
     21</style> 
     22{% endextrahead %} 
     23 
    524<ul class="sf-menu"> 
    625    <li class="current"> 
     
    1938    </li> 
    2039    <li> 
    21         <a>{% trans 'admin menu' %}</a> 
     40        <a href="{{ admin_menu_link }}">{% trans 'admin menu' %}</a> 
    2241        <ul> 
    23             <li><a href="{{ admin_menu_link }}">non popup</a></li> 
    24             <li><a href="{{ admin_menu_link }}">popup</a></li> 
     42            <li><a href="{{ admin_menu_link }}">in popup win</a></li> 
    2543        </ul> 
    2644    </li> 
    2745</ul> 
    28  
    29  
    3046{% endblock %} 
  • branches/0.9/pylucid_project/pylucid_plugins/admin_menu/views.py

    r2019 r2022  
    1212    if not request.user.is_authenticated(): 
    1313        # Don't insert the admin top menu 
    14         return 
     14        return   
    1515     
    1616    pagetree = request.PYLUCID.pagetree 
     
    2525         
    2626    edit_meta_admin_panel_link = reverse("admin_pylucid_pagemeta_change", args=(pagemeta.id,)) 
    27          
    2827     
    2928    context = { 
  • branches/0.9/pylucid_project/pylucid_plugins/auth/templates/auth/input_password.html

    r2004 r2022  
     1{% extends "pylucid/css_anchor_div.html" %} 
     2 
     3 
     4{% block plugin_content %} 
     5 
     6{% extrahead %} 
     7<script type="text/javascript" src="{{ PyLucid_media_url }}sha.js"></script> 
     8<script type="text/javascript" src="{{ PyLucid_media_url }}shared_sha_tools.js"></script> 
     9<script type="text/javascript" src="{{ PyLucid_media_url }}sha_login_input_password.js"></script> 
     10<script type="text/javascript"> 
     11debug_msg = {{ debug }}; 
     12salt = '{{ salt }}'; 
     13challenge = '{{ challenge }}'; 
     14submit_url = '{{ form_url }}'; 
     15focus_id = 'plaintext_pass'; 
     16 
     17function start_init() { 
     18    try { 
     19        $(document); 
     20    } catch (e) { 
     21        alert("Error, jQuery JS not loaded!\n Original error was:" + e); 
     22        return; 
     23    } 
     24     
     25    try { 
     26        $(document).ready(function(){ 
     27            init(); 
     28        }); 
     29    } catch (e) { 
     30        alert("Error, can't initialize SHA login:\n\n" + e + "\n\n(Possible error: JS files not loaded.)"); 
     31    } 
     32} 
     33start_init(); 
     34</script> 
     35{% endextrahead %} 
     36 
    137<fieldset><legend>PyLucid <a href="http://www.pylucid.org/_goto/8/JS-SHA-Login/" title="What is the PyLucid JS-SHA-LogIn?">JS-SHA-LogIn</a> - step 2</legend> 
    238 
     
    2561{% endif %} 
    2662</fieldset> 
    27  
    28 <script type="text/javascript"> 
    29 function load_error(filename) { 
    30     alert("Error loading JavaScript library file {{ PyLucid_media_url }}"+filename+"!"); 
    31 } 
    32 </script> 
    33 <script language="javascript" type="text/javascript" src="{{ PyLucid_media_url }}/shared_sha_tools.js" onerror="load_error('shared_sha_tools.js');"></script> 
    34 <script language="javascript" type="text/javascript" src="{{ PyLucid_media_url }}/sha.js" onerror="load_error('sha.js');"></script> 
    35 <script language="javascript" type="text/javascript" src="{{ PyLucid_media_url }}/sha_login_input_password.js" onerror="load_error('sha_login_input_password.js');"></script> 
    36 <script type="text/javascript"> 
    37     debug_msg = {{ debug }}; 
    38     salt = '{{ salt }}'; 
    39     challenge = '{{ challenge }}'; 
    40     submit_url = '{{ form_url }}'; 
    41     focus_id = 'plaintext_pass'; 
    42      
    43     init(); 
    44 </script> 
     63{% endblock %} 
  • branches/0.9/pylucid_project/pylucid_plugins/auth/views.py

    r2018 r2022  
    33from django.contrib import auth 
    44from django.conf import settings 
     5from django.template import RequestContext 
     6from django.http import HttpResponseRedirect 
     7from django.shortcuts import render_to_response 
    58from django.utils.translation import ugettext as _ 
    69from django.template.loader import render_to_string 
    7 from django.http import HttpResponseRedirect 
    8 from django.shortcuts import render_to_response 
    910 
    1011from pylucid_project.utils import crypt 
     
    2425 
    2526 
    26 def _logout_view(request): 
     27def _logout_view(request, next_url): 
    2728    """ Logout the current user. """ 
    2829    auth.logout(request) 
    2930    request.page_msg.successful(_("You are logged out!")) 
     31    return HttpResponseRedirect(next_url) 
    3032 
    3133 
     
    118120     
    119121    context["form"] = SHA_login_form 
    120      
     122 
    121123    # return a string for replacing the normal cms page content 
    122     return render_to_string('auth/input_password.html', context) 
     124    return render_to_string('auth/input_password.html', context,  
     125        context_instance=RequestContext(request) 
     126    ) 
    123127 
    124128 
     
    159163    Login+Logout view via GET parameters 
    160164    """ 
     165    next_url = request.path 
     166     
    161167    action = request.GET["auth"] 
    162168    if action=="login": 
    163169        form_url = request.path + "?auth=login" # FIXME: How can we add the GET Parameter? 
    164         next_url = request.path 
    165170        return _login_view(request, form_url, next_url) 
    166171    elif action=="logout": 
    167         return _logout_view(request) 
     172        return _logout_view(request, next_url) 
    168173     
    169174    if settings.DEBUG: 
  • branches/0.9/pylucid_project/settings.py

    r2004 r2022  
    131131    # http://www.djangoproject.com/documentation/settings/#template-string-if-invalid 
    132132    TEMPLATE_STRING_IF_INVALID = "XXX INVALID TEMPLATE STRING '%s' XXX" 
     133    from django_tools.template import warn_invalid_template_vars 
     134    warn_invalid_template_vars.add_warning() 
     135     
    133136 
    134137 
  • branches/0.9/pylucid_project/tests/test_admin_site.py

    r1968 r2022  
    1616        self.assertResponse(response, 
    1717            must_contain=("PyLucid", "PyLucid - Log in"), 
    18             must_not_contain=("error", "Traceback") 
     18            must_not_contain=("Traceback",)#"error") 
    1919        ) 
    2020         
     
    2424        self.assertResponse(response, 
    2525            must_contain=("PyLucid", "Page trees", "Page contents"), 
    26             must_not_contain=("Log in", "error", "Traceback") 
     26            must_not_contain=("Log in", "Traceback",)#"error") 
    2727        ) 
    2828 
  • branches/0.9/pylucid_project/tests/test_PluginAPI.py

    r2014 r2022  
    185185                            "site_name": site.name, 
    186186                        }, 
    187                         "context_middlewares: {u&#39;breadcrumb&#39;: &lt;pylucid_plugins.breadcrumb", 
     187                        "context_middlewares: [u&#39;extrahead&#39;, u&#39;breadcrumb&#39;]", 
    188188                        "default_lang_code: %s" % self.default_lang_code, 
    189189                        "default_lang_entry: &lt;Language: Language %s" % self.default_lang_code, 
     
    205205                ) 
    206206 
     207    def test_add_headfiles(self): 
     208        """ 
     209        Add content into html head with {% extrahead %} block tag in plugin template. 
     210        """ 
     211        for site in TestSites(): 
     212            for language in TestLanguages(): 
     213                url = "/%s/%s/test_add_headfiles/" % (language.code, unittest_plugin.PLUGIN_PAGE_URL) 
     214                response = self.client.get(url) 
     215                self.assertResponse(response, 
     216                    must_contain=( 
     217                        "Here ist the unittest plugin extra head content ;)", 
     218                        '3-pluginpage title (lang:%(lang)s, site:%(site_name)s) %(site_name)s' % { 
     219                            "lang": language.code, 
     220                            "site_name": site.name, 
     221                        }, 
     222                    ), 
     223                    must_not_contain=( 
     224                        "Traceback", 
     225                    ) 
     226                ) 
     227 
    207228 
    208229if __name__ == "__main__": 
  • branches/0.9/pylucid_project/tests/test_tools/pylucid_test_data.py

    r2011 r2022  
    131131<meta name="DC.Language" content="{{ page_language }}"> 
    132132<link rel="canonical" href="{{ page_get_permalink }}" /> 
    133 {% lucidTag head_files %} 
     133<!-- ContextMiddleware extrahead --> 
    134134</head> 
    135135<body> 
     
    241241def create_headfiles(verbosity, headfile_dict, site, request): 
    242242    headfile_map = {} 
    243     for filename, data in headfile_dict.iteritems(): 
     243    for filepath, data in headfile_dict.iteritems(): 
    244244        headfile = EditableHtmlHeadFile( 
    245             filename = filename, 
     245            filepath = filepath, 
    246246            description = data["description"], 
    247247            content = data["content"], 
     
    250250        headfile.site.add(site) 
    251251        if verbosity: 
    252             print("EditableStaticFile '%s' created on site: %s" % (filename, site.name)) 
    253          
    254         headfile_map[filename+site.name] = headfile 
     252            print("EditableStaticFile '%s' created on site: %s" % (filepath, site.name)) 
     253         
     254        headfile_map[filepath+site.name] = headfile 
    255255    return headfile_map 
    256256 
  • branches/0.9/pylucid_project/tests/unittest_plugin/urls.py

    r2014 r2022  
    3838        views.test_BreadcrumbPlugin, name='UnittestPlugin-test_BreadcrumbPlugin' 
    3939    ), 
     40     
     41    url( 
     42        r'^test_add_headfiles/$', 
     43        views.test_add_headfiles, name='UnittestPlugin-test_add_headfiles' 
     44    ), 
     45 
    4046) 
  • branches/0.9/pylucid_project/tests/unittest_plugin/views.py

    r2014 r2022  
    2121 
    2222from django import http 
     23from django.template import RequestContext 
    2324from django.core.urlresolvers import reverse 
    2425from django.shortcuts import render_to_response 
     
    108109    context = request.PYLUCID.context 
    109110    output = [] 
    110     output.append("context_middlewares: %s" % context["context_middlewares"]) 
     111    output.append("context_middlewares: %s" % context["context_middlewares"].keys()) 
    111112    output.append("default_lang_code: %s" % request.PYLUCID.default_lang_code) 
    112113    output.append("default_lang_entry: %r" % request.PYLUCID.default_lang_entry) 
     
    136137     
    137138    return ADDED_LINK_RESPONSE_STRING 
     139 
     140 
     141#_____________________________________________________________________________ 
     142# Add headfiles tests 
     143 
     144def test_add_headfiles(request): 
     145    """ 
     146    Add content into html head with {% extrahead %} block tag in plugin template. 
     147    """ 
     148    context = request.PYLUCID.context 
     149    output = render_to_response('unittest_plugin/test_extrahead_blocktag.html', context) 
     150    return output 
     151 
     152