Changeset 2022
- Timestamp:
- 06/09/09 16:15:25 (9 months ago)
- Location:
- branches/0.9/pylucid_project
- Files:
-
- 5 added
- 1 removed
- 21 modified
- 3 moved
-
apps/pylucid/admin.py (modified) (1 diff)
-
apps/pylucid/app_settings.py (modified) (2 diffs)
-
apps/pylucid/defaulttags/extraheadBlock.py (added)
-
apps/pylucid/defaulttags/lucidTag.py (modified) (1 diff)
-
apps/pylucid/defaulttags/__init__.py (modified) (2 diffs)
-
apps/pylucid/models.py (modified) (5 diffs)
-
apps/pylucid/system/headfile.py (added)
-
apps/pylucid/system/pylucid_plugin.py (modified) (2 diffs)
-
apps/pylucid/templates/admin/base_site.html (modified) (3 diffs)
-
apps/pylucid/templates/pylucid/headfile_css_link.html (moved) (moved from branches/0.9/pylucid_project/apps/pylucid/templates/pylucid/headlink_css_file.html)
-
apps/pylucid/templates/pylucid/headfile_js_link.html (moved) (moved from branches/0.9/pylucid_project/apps/pylucid/templates/pylucid/headlink_js_file.html)
-
apps/pylucid/urls.py (modified) (1 diff)
-
apps/pylucid/views.py (modified) (2 diffs)
-
apps/pylucid_update/views.py (modified) (4 diffs)
-
manage.py (modified) (1 diff)
-
media/PyLucid/jquery.js (added)
-
media/PyLucid/superfish/pylucid_superfish_init.js (added)
-
pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html (modified) (2 diffs)
-
pylucid_plugins/admin_menu/views.py (modified) (2 diffs)
-
pylucid_plugins/auth/templates/auth/input_password.html (modified) (2 diffs)
-
pylucid_plugins/auth/views.py (modified) (4 diffs)
-
pylucid_plugins/extrahead (moved) (moved from branches/0.9/pylucid_project/pylucid_plugins/head_files)
-
pylucid_plugins/extrahead/context_middleware.py (added)
-
pylucid_plugins/head_files/views.py (deleted)
-
settings.py (modified) (1 diff)
-
tests/test_admin_site.py (modified) (2 diffs)
-
tests/test_PluginAPI.py (modified) (2 diffs)
-
tests/test_tools/pylucid_test_data.py (modified) (3 diffs)
-
tests/unittest_plugin/urls.py (modified) (1 diff)
-
tests/unittest_plugin/views.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/apps/pylucid/admin.py
r2000 r2022 115 115 116 116 class EditableHtmlHeadFileAdmin(UpdateInfoBaseAdmin, VersionAdmin): 117 list_display = ("file name", "description", "lastupdatetime", "lastupdateby")118 list_display_links = ("file name", "description")117 list_display = ("filepath", "description", "lastupdatetime", "lastupdateby") 118 list_display_links = ("filepath", "description") 119 119 list_filter = ("site",) 120 120 -
branches/0.9/pylucid_project/apps/pylucid/app_settings.py
r2002 r2022 11 11 CSS_PLUGIN_CLASS_NAME = "PyLucidPlugins" 12 12 13 EDITABLE_HEAD_LINK_TEMPLATE = "pylucid/headlink_%s_file.html" 13 HEADFILE_INLINE_TEMPLATES = "pylucid/headfile_%s_inline.html" 14 HEADFILE_LINK_TEMPLATES = "pylucid/headfile_%s_link.html" 14 15 HEAD_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 21 CACHE_DIR = "headfile_cache" # store path: 15 22 16 23 # i18n stuff: … … 21 28 # All PyLucid media files stored in a sub directory under the django media 22 29 # path. Used for building filesystem path and URLs. 23 # filesystem path: MEDIA_ROOT + PYLUCID_MEDIA_ SUBDIR24 # URLs: MEDIA_URL + PYLUCID_MEDIA_ SUBDIR30 # filesystem path: MEDIA_ROOT + PYLUCID_MEDIA_DIR 31 # URLs: MEDIA_URL + PYLUCID_MEDIA_DIR 25 32 PYLUCID_MEDIA_DIR = "PyLucid" # Without slashes at begin/end! -
branches/0.9/pylucid_project/apps/pylucid/defaulttags/lucidTag.py
r1951 r2022 138 138 if response==None: 139 139 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!") 144 147 # 145 148 # # callback is either a string like 'foo.views.news.stories.story_detail' -
branches/0.9/pylucid_project/apps/pylucid/defaulttags/__init__.py
r1889 r2022 26 26 from django.templatetags.i18n import do_translate, do_block_translate 27 27 28 from pylucid_project.apps.pylucid.defaulttags.lucidTag import lucidTag 28 from pylucid_project.apps.pylucid.defaulttags import lucidTag 29 from pylucid_project.apps.pylucid.defaulttags import extraheadBlock 29 30 #from PyLucid.template_addons.lucidTag import lucidTag 30 31 #from PyLucid.template_addons.blocktag_pygments import sourcecode … … 34 35 register = Library() 35 36 36 register.tag(lucidTag) 37 register.tag(lucidTag.lucidTag) 38 register.tag("extrahead", extraheadBlock.do_extrahead) 39 #register.tag(extraheadBlock.ExtraheadNode) 37 40 #register.tag(sourcecode) 38 41 #register.filter(chmod_symbol) -
branches/0.9/pylucid_project/apps/pylucid/models.py
r2002 r2022 21 21 22 22 import os 23 import warnings 24 import posixpath 25 import mimetypes 23 26 from xml.sax.saxutils import escape 24 27 … … 33 36 34 37 from pylucid.system.auto_model_info import UpdateInfoBaseModel, UpdateInfoBaseModelManager 35 38 from pylucid.system import headfile 36 39 37 40 … … 426 429 #------------------------------------------------------------------------------ 427 430 428 429 431 class Design(UpdateInfoBaseModel): 430 432 """ … … 461 463 #------------------------------------------------------------------------------ 462 464 465 class 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 463 473 464 474 class EditableHtmlHeadFile(UpdateInfoBaseModel): … … 471 481 createby -> ForeignKey to user who creaded this entry 472 482 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 476 486 site = models.ManyToManyField(Site, default=[settings.SITE_ID]) 477 487 on_site = CurrentSiteManager() 478 488 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 ) 480 494 description = models.TextField(null=True, blank=True) 481 495 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": 485 538 return u"text/css" 486 elif self.filename.endswith(".js"):539 elif fileext == ".js": 487 540 return u"text/javascript" 488 541 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",) 512 559 513 560 -
branches/0.9/pylucid_project/apps/pylucid/system/pylucid_plugin.py
r2021 r2022 181 181 for plugin_name in plugin_names: 182 182 # 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 184 189 # make a instance 185 190 instance = middleware_class(request, context) … … 192 197 """ 193 198 context = request.PYLUCID.context 199 context_middlewares = context["context_middlewares"] 194 200 def replace(match): 195 201 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 197 207 response = middleware_class_instance.render() 198 208 if response == None: -
branches/0.9/pylucid_project/apps/pylucid/templates/admin/base_site.html
r2020 r2022 7 7 <!-- app_extrahead block start --> 8 8 {# 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> 11 10 <link rel="stylesheet" type="text/css" media="screen" href="{{ PyLucid_media_url }}superfish/superfish.css" /> 12 11 <link rel="stylesheet" type="text/css" media="screen" href="{{ PyLucid_media_url }}superfish/admin_design.css" /> … … 56 55 {% block pretitle %} 57 56 <!-- app pretitle block start --> 57 {% if request.user.is_authenticated %} 58 58 <ul class="sf-menu"> 59 59 <li class="current"> 60 <a href="/"><< back to root devpage</a>60 <a href="/"><< back to "/" root page</a> 61 61 </li> 62 62 <li> … … 84 84 </li> 85 85 </ul> 86 {% endif %} 86 87 <!-- app pretitle block end --> 87 88 {% endblock %} -
branches/0.9/pylucid_project/apps/pylucid/urls.py
r1975 r2022 28 28 url(r'^$', views.root_page, name='PyLucid-root_page'), 29 29 30 url(r'^%s/(?P<file name>[\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, 31 31 name='PyLucid-send_head_file' 32 32 ), -
branches/0.9/pylucid_project/apps/pylucid/views.py
r2012 r2022 174 174 175 175 176 def send_head_file(request, file name):176 def send_head_file(request, filepath): 177 177 """ 178 178 Sending a headfile … … 180 180 """ 181 181 try: 182 headfile = EditableHtmlHeadFile.objects.get(file name=filename)182 headfile = EditableHtmlHeadFile.objects.get(filepath=filepath) 183 183 except EditableHtmlHeadFile.DoesNotExist: 184 184 if settings.DEBUG: 185 request.page_msg.error("Headfile %r not found!" % file name)185 request.page_msg.error("Headfile %r not found!" % filepath) 186 186 raise http.Http404 187 187 188 mimetype = headfile.get_mimetype()189 188 content = headfile.content 190 189 mimetype = headfile.mimetype 191 190 return http.HttpResponse(content, mimetype=mimetype) 192 191 -
branches/0.9/pylucid_project/apps/pylucid_update/views.py
r2002 r2022 1 1 # coding: utf-8 2 3 import posixpath 2 4 3 5 from django.conf import settings … … 80 82 for style in Style08.objects.all(): 81 83 new_staticfile, created = EditableHtmlHeadFile.objects.get_or_create(request, 82 file name= settings.SITE_TEMPLATE_PREFIX + style.name + ".css",84 filepath = settings.SITE_TEMPLATE_PREFIX + style.name + ".css", 83 85 defaults = { 84 86 "description": style.description, … … 265 267 content = template.content 266 268 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 268 283 content = replace(content, out,"{% lucidTag back_links %}", "<!-- ContextMiddleware breadcrumb -->") 269 284 content = replace(content, out, … … 335 350 additional_styles, origin = find_template_source("pylucid_update/additional_styles.css") 336 351 337 styles = EditableHtmlHeadFile.objects.filter(file name__istartswith=settings.SITE_TEMPLATE_PREFIX)338 styles = styles.filter(file name__iendswith=".css")352 styles = EditableHtmlHeadFile.objects.filter(filepath__istartswith=settings.SITE_TEMPLATE_PREFIX) 353 styles = styles.filter(filepath__iendswith=".css") 339 354 for style in styles: 340 out.write("\nUpdate Styles: '%s'" % style.file name)355 out.write("\nUpdate Styles: '%s'" % style.filepath) 341 356 342 357 content = style.content -
branches/0.9/pylucid_project/manage.py
r1972 r2022 1 1 #!/usr/bin/env python 2 # coding: utf-8 2 3 3 4 """ -
branches/0.9/pylucid_project/pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html
r2019 r2022 1 1 {% extends "pylucid/css_anchor_div.html" %} 2 2 3 3 4 {% 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 5 24 <ul class="sf-menu"> 6 25 <li class="current"> … … 19 38 </li> 20 39 <li> 21 <a >{% trans 'admin menu' %}</a>40 <a href="{{ admin_menu_link }}">{% trans 'admin menu' %}</a> 22 41 <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> 25 43 </ul> 26 44 </li> 27 45 </ul> 28 29 30 46 {% endblock %} -
branches/0.9/pylucid_project/pylucid_plugins/admin_menu/views.py
r2019 r2022 12 12 if not request.user.is_authenticated(): 13 13 # Don't insert the admin top menu 14 return 14 return 15 15 16 16 pagetree = request.PYLUCID.pagetree … … 25 25 26 26 edit_meta_admin_panel_link = reverse("admin_pylucid_pagemeta_change", args=(pagemeta.id,)) 27 28 27 29 28 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"> 11 debug_msg = {{ debug }}; 12 salt = '{{ salt }}'; 13 challenge = '{{ challenge }}'; 14 submit_url = '{{ form_url }}'; 15 focus_id = 'plaintext_pass'; 16 17 function 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 } 33 start_init(); 34 </script> 35 {% endextrahead %} 36 1 37 <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> 2 38 … … 25 61 {% endif %} 26 62 </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 3 3 from django.contrib import auth 4 4 from django.conf import settings 5 from django.template import RequestContext 6 from django.http import HttpResponseRedirect 7 from django.shortcuts import render_to_response 5 8 from django.utils.translation import ugettext as _ 6 9 from django.template.loader import render_to_string 7 from django.http import HttpResponseRedirect8 from django.shortcuts import render_to_response9 10 10 11 from pylucid_project.utils import crypt … … 24 25 25 26 26 def _logout_view(request ):27 def _logout_view(request, next_url): 27 28 """ Logout the current user. """ 28 29 auth.logout(request) 29 30 request.page_msg.successful(_("You are logged out!")) 31 return HttpResponseRedirect(next_url) 30 32 31 33 … … 118 120 119 121 context["form"] = SHA_login_form 120 122 121 123 # 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 ) 123 127 124 128 … … 159 163 Login+Logout view via GET parameters 160 164 """ 165 next_url = request.path 166 161 167 action = request.GET["auth"] 162 168 if action=="login": 163 169 form_url = request.path + "?auth=login" # FIXME: How can we add the GET Parameter? 164 next_url = request.path165 170 return _login_view(request, form_url, next_url) 166 171 elif action=="logout": 167 return _logout_view(request )172 return _logout_view(request, next_url) 168 173 169 174 if settings.DEBUG: -
branches/0.9/pylucid_project/settings.py
r2004 r2022 131 131 # http://www.djangoproject.com/documentation/settings/#template-string-if-invalid 132 132 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 133 136 134 137 -
branches/0.9/pylucid_project/tests/test_admin_site.py
r1968 r2022 16 16 self.assertResponse(response, 17 17 must_contain=("PyLucid", "PyLucid - Log in"), 18 must_not_contain=(" error", "Traceback")18 must_not_contain=("Traceback",)#"error") 19 19 ) 20 20 … … 24 24 self.assertResponse(response, 25 25 must_contain=("PyLucid", "Page trees", "Page contents"), 26 must_not_contain=("Log in", " error", "Traceback")26 must_not_contain=("Log in", "Traceback",)#"error") 27 27 ) 28 28 -
branches/0.9/pylucid_project/tests/test_PluginAPI.py
r2014 r2022 185 185 "site_name": site.name, 186 186 }, 187 "context_middlewares: {u'breadcrumb': <pylucid_plugins.breadcrumb",187 "context_middlewares: [u'extrahead', u'breadcrumb']", 188 188 "default_lang_code: %s" % self.default_lang_code, 189 189 "default_lang_entry: <Language: Language %s" % self.default_lang_code, … … 205 205 ) 206 206 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 207 228 208 229 if __name__ == "__main__": -
branches/0.9/pylucid_project/tests/test_tools/pylucid_test_data.py
r2011 r2022 131 131 <meta name="DC.Language" content="{{ page_language }}"> 132 132 <link rel="canonical" href="{{ page_get_permalink }}" /> 133 {% lucidTag head_files %} 133 <!-- ContextMiddleware extrahead --> 134 134 </head> 135 135 <body> … … 241 241 def create_headfiles(verbosity, headfile_dict, site, request): 242 242 headfile_map = {} 243 for file name, data in headfile_dict.iteritems():243 for filepath, data in headfile_dict.iteritems(): 244 244 headfile = EditableHtmlHeadFile( 245 file name = filename,245 filepath = filepath, 246 246 description = data["description"], 247 247 content = data["content"], … … 250 250 headfile.site.add(site) 251 251 if verbosity: 252 print("EditableStaticFile '%s' created on site: %s" % (file name, site.name))253 254 headfile_map[file name+site.name] = headfile252 print("EditableStaticFile '%s' created on site: %s" % (filepath, site.name)) 253 254 headfile_map[filepath+site.name] = headfile 255 255 return headfile_map 256 256 -
branches/0.9/pylucid_project/tests/unittest_plugin/urls.py
r2014 r2022 38 38 views.test_BreadcrumbPlugin, name='UnittestPlugin-test_BreadcrumbPlugin' 39 39 ), 40 41 url( 42 r'^test_add_headfiles/$', 43 views.test_add_headfiles, name='UnittestPlugin-test_add_headfiles' 44 ), 45 40 46 ) -
branches/0.9/pylucid_project/tests/unittest_plugin/views.py
r2014 r2022 21 21 22 22 from django import http 23 from django.template import RequestContext 23 24 from django.core.urlresolvers import reverse 24 25 from django.shortcuts import render_to_response … … 108 109 context = request.PYLUCID.context 109 110 output = [] 110 output.append("context_middlewares: %s" % context["context_middlewares"] )111 output.append("context_middlewares: %s" % context["context_middlewares"].keys()) 111 112 output.append("default_lang_code: %s" % request.PYLUCID.default_lang_code) 112 113 output.append("default_lang_entry: %r" % request.PYLUCID.default_lang_entry) … … 136 137 137 138 return ADDED_LINK_RESPONSE_STRING 139 140 141 #_____________________________________________________________________________ 142 # Add headfiles tests 143 144 def 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