diff MoinMoin/themes/__init__.py @ 1764:19b19d4d9291

Add a @timed decorator. The decorator adds flaskg.clock.{start,stop} calls to entrance and exit of a function.
author Cheer Xiao <xiaqqaix@gmail.com>
date Sat, 01 Sep 2012 20:53:20 +0800
parents d697fd14e772
children 54be46b8a0b4
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Sat Sep 01 20:47:50 2012 +0800
+++ b/MoinMoin/themes/__init__.py	Sat Sep 01 20:53:20 2012 +0800
@@ -28,6 +28,7 @@
 from MoinMoin.util.interwiki import split_interwiki, getInterwikiHome, is_local_wiki, is_known_wiki, url_for_item
 from MoinMoin.util.crypto import cache_key
 from MoinMoin.util.forms import make_generator
+from MoinMoin.util.clock import timed
 
 
 def get_current_theme():
@@ -45,11 +46,9 @@
         return get_theme(theme_name)
 
 
+@timed()
 def render_template(template, **context):
-    flaskg.clock.start('render_template')
-    output = render_theme_template(get_current_theme(), template, **context)
-    flaskg.clock.stop('render_template')
-    return output
+    return render_theme_template(get_current_theme(), template, **context)
 
 def themed_error(e):
     item_name = request.view_args.get('item_name', u'')
@@ -205,6 +204,7 @@
             title = item_name
         return href, title, wiki_name
 
+    @timed()
     def navibar(self, item_name):
         """
         Assemble the navibar
@@ -212,7 +212,6 @@
         :rtype: list
         :returns: list of tuples (css_class, url, link_text, title)
         """
-        flaskg.clock.start('navibar')
         current = item_name
         # Process config navi_bar
         items = [(cls, url_for(endpoint, **args), link_text, title)
@@ -253,7 +252,6 @@
                 if current in sisteritems:
                     url = sisteritems[current]
                     items.append(('sisterwiki', url, sistername, ''))
-        flaskg.clock.stop('navibar')
         return items
 
     def parent_item(self, item_name):