changeset 2491:8f054781b48a

more defensive checking for item existence, improved generation of current_url, pep8 fixes remain
author sharky93 <rishabhr123@gmail.com>
date Sun, 15 Sep 2013 23:21:51 +0530
parents e3dfa238d68d
children f1d470ade3c0
files MoinMoin/themes/__init__.py MoinMoin/themes/basic/templates/layout.html
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Sun Sep 15 22:19:14 2013 +0530
+++ b/MoinMoin/themes/__init__.py	Sun Sep 15 23:21:51 2013 +0530
@@ -132,6 +132,9 @@
 
         exists = flaskg.storage.has_item(item_name)
 
+        if not exists:
+            return [], [], []
+
         user_actions_endpoints = ['frontend.quicklink_item', 'frontend.subscribe_item', ]
         item_navigation_endpoints = ['special.supplementation']
         item_actions_endpoints = ['frontend.rename_item', 'frontend.delete_item', 'frontend.destroy_item',
--- a/MoinMoin/themes/basic/templates/layout.html	Sun Sep 15 22:19:14 2013 +0530
+++ b/MoinMoin/themes/basic/templates/layout.html	Sun Sep 15 23:21:51 2013 +0530
@@ -6,12 +6,9 @@
 {% set credits = snippets.credits() %}
 {% set user_actions, item_navigation, item_actions = theme_supp.get_local_panel(item_name) %}
 
-{% if item_name in ['@NONAMEGIVEN',''] %}
-{% set current_url = url_for(request.endpoint) %}
-{% else %}
-{% set current_url = url_for_item(endpoint = request.endpoint, item_name = item_name) %}
+{% set current_url = request.url %}
+{% set current_path = request.path %}
 {% set current_url_showview = url_for_item(endpoint='frontend.show_item', item_name=item_name) %}
-{% endif %}
 
 {# Helper macro to generate the local panel #}
 {% macro local_panel_main(panelname) -%}
@@ -214,7 +211,7 @@
                             <div class="list-group-item moin-list-heading"> {{ _("Site Navigation") }} </div>
                             {% for cls, url, text, title in navibar_items if cls != 'userlink' %}
                                 <a class="list-group-item {{ cls }}
-                                    {% if url in [current_url, current_url_showview] %} active{% endif %}" href="{{ url }}" 
+                                    {% if url in [current_url, current_path] %} active{% endif %}" href="{{ url }}" 
                                     {% if title %}title="{{ title }}"{% endif %}>
                                     {{ text|shorten_item_name }}
                                 </a>