Milimetric has submitted this change and it was merged.

Change subject: adds placeholder and fixes Metric inheritance tree
......................................................................


adds placeholder and fixes Metric inheritance tree

Change-Id: I4bef462e9f2826e1cefe79794e1b68b68da64eac
---
M wikimetrics/metrics/metric.py
M wikimetrics/metrics/namespace_edits.py
M wikimetrics/templates/form.html
3 files changed, 13 insertions(+), 10 deletions(-)

Approvals:
  Milimetric: Verified; Looks good to me, approved



diff --git a/wikimetrics/metrics/metric.py b/wikimetrics/metrics/metric.py
index d08c1e0..8476039 100644
--- a/wikimetrics/metrics/metric.py
+++ b/wikimetrics/metrics/metric.py
@@ -1,5 +1,6 @@
 from flask.ext import wtf
-from werkzeug.local import LocalStack
+import logging
+logger = logging.getLogger(__name__)
 
 __all__ = [
     'Metric',
@@ -33,15 +34,17 @@
         Returns:
             dictionary from user ids to the metric results.
         """
-        
         return {user: None for user in user_ids}
     
     def __init__(self):
-        print LocalStack().top
         """
-        This __init__ calls its super __init__ (the one in wtf.Form) only when
-        it runs inside a flask context.  Otherwise, tests would not be able to
-        instantiate any Metrics.
+        This __init__ handles the problem with calling wtf.Form.__init__()
+        outside of a flask request context.
         """
-        if LocalStack().top is not None:
-            super(wtf.Form, self).__init__()
+        try:
+            wtf.Form.__init__(self)
+        except(RuntimeError):
+            logger.debug(
+                'initializing Metric outside Flask context,'
+                'most likely in testing or interactive mode'
+            )
diff --git a/wikimetrics/metrics/namespace_edits.py 
b/wikimetrics/metrics/namespace_edits.py
index ae4e3f2..5f4573c 100644
--- a/wikimetrics/metrics/namespace_edits.py
+++ b/wikimetrics/metrics/namespace_edits.py
@@ -33,7 +33,7 @@
     label       = 'Edits'
     description = 'Compute the number of edits in a specific namespace of a 
mediawiki project'
     
-    namespace = wtf.IntegerField(default=0)
+    namespaces = wtf.IntegerField(default=0, description='0, 2, 4, etc.')
     
     def __init__(self, namespaces=[0]):
         """
diff --git a/wikimetrics/templates/form.html b/wikimetrics/templates/form.html
index b07fe0e..8d00f7d 100644
--- a/wikimetrics/templates/form.html
+++ b/wikimetrics/templates/form.html
@@ -4,7 +4,7 @@
         <div class="control-group">
             {{ f.label(class="control-label") }}
             <div class="controls">
-                {{ f }}
+                {{ f(placeholder=f.description) }}
                 {% if f.errors %}
                     <ul class="unstyled">
                         {% for e in f.errors %}

-- 
To view, visit https://gerrit.wikimedia.org/r/71080
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4bef462e9f2826e1cefe79794e1b68b68da64eac
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikimetrics
Gerrit-Branch: master
Gerrit-Owner: Milimetric <dandree...@wikimedia.org>
Gerrit-Reviewer: Milimetric <dandree...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to