isDebug now also checks melange version
authorSverre Rabbelier <srabbelier@gmail.com>
Wed, 11 Mar 2009 21:29:32 +0000
changeset 1797 f0c83ca3bb08
parent 1796 5cd78a7aacdd
child 1798 ba4c00bc0c39
isDebug now also checks melange version To facilitate this getMelangeVersion was introduced and in order to not show the 'Flush Cache' button a isLocal method was also added. Patch by: Sverre Rabbelier
app/soc/logic/system.py
app/soc/templates/soc/base.html
app/soc/views/helper/responses.py
--- a/app/soc/logic/system.py	Wed Mar 11 21:28:48 2009 +0000
+++ b/app/soc/logic/system.py	Wed Mar 11 21:29:32 2009 +0000
@@ -26,16 +26,35 @@
 import settings
 
 
-def isDebug():
-  """Returns True if Melange application is running in "debug mode".
-  
-  "Debug mode" is currently determined from settings.DEBUG but may become
-  more sophisticated in the future.
-  """
-  return settings.DEBUG
-
 def getAppVersion():
   """Returns the Google App Engine "version" of the running instance.
   """
 
   return os.environ.get('CURRENT_VERSION_ID')
+
+
+def getMelangeVersion():
+  """Returns the Melange part of the GAE version.
+  """
+
+  return getAppVersion().split('.', 1)[0]
+
+
+def isLocal():
+  """Returns True if Melange application is running locally.
+  
+  "Local mode" is currently determined from settings.DEBUG but may become
+  more sophisticated in the future.
+  """
+
+  return settings.DEBUG
+
+
+def isDebug():
+  """Returns True if Melange application is running in "debug mode".
+
+  "Debug mode" is currently enabled if running locally or if the
+  current Melange version is 'devvin'.
+  """
+
+  return isLocal() or getMelangeVersion() == 'devvin'
--- a/app/soc/templates/soc/base.html	Wed Mar 11 21:28:48 2009 +0000
+++ b/app/soc/templates/soc/base.html	Wed Mar 11 21:29:32 2009 +0000
@@ -110,6 +110,9 @@
 	Developer |
 	{% endif %}
 	{% if is_debug %}
+	Debug Mode |
+	{% endif %}
+	{% if is_local %}
 	<form id="flush_form" action="/_ah/admin/memcache" method="post" style="display: inline;">
       <input type="submit" class="button" name="action:flush" value="Flush Cache"/>
     </form> | 
--- a/app/soc/views/helper/responses.py	Wed Mar 11 21:28:48 2009 +0000
+++ b/app/soc/views/helper/responses.py	Wed Mar 11 21:29:32 2009 +0000
@@ -122,15 +122,15 @@
   context['user'] = user
   context['is_admin'] = is_admin
 
+  context['is_local'] = system.isLocal()
   context['is_debug'] = system.isDebug()
   context['sign_in'] = users.create_login_url(request.path)
   context['sign_out'] = users.create_logout_url(request.path)
 
   context['sidebar_menu_items'] = sidebar.getSidebar(account, user)
 
-  gae_version = system.getAppVersion()
-  context['gae_version'] = gae_version
-  context['soc_release'] = gae_version.split('.', 1)[0]
+  context['gae_version'] = system.getAppVersion()
+  context['soc_release'] = system.getMelangeVersion()
 
   settings = site.logic.getSingleton()