[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
eric at webkit.org
eric at webkit.org
Wed Dec 22 14:44:33 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit d5744a570b62edf572654988e7595542b998a5a4
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 19 02:13:19 2010 +0000
2010-10-18 Eric Seidel <eric at webkit.org>
Reviewed by Adam Barth.
Deploy Queue class in more places throughout QueueStatusServer
https://bugs.webkit.org/show_bug.cgi?id=47855
I also caught two typos from the previous change. Unfortunately
I don't yet know how to unittest request handlers yet.
* QueueStatusServer/handlers/dashboard.py:
* QueueStatusServer/handlers/statusbubble.py:
* QueueStatusServer/handlers/updateworkitems.py:
* QueueStatusServer/model/activeworkitems.py:
* QueueStatusServer/model/attachment.py:
* QueueStatusServer/model/queuepropertymixin.py: Added.
* QueueStatusServer/model/queuepropertymixin_unittest.py: Added.
* QueueStatusServer/model/queuestatus.py:
* QueueStatusServer/model/workitems.py:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70016 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 2166ff8..60cfe11 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2010-10-18 Eric Seidel <eric at webkit.org>
+
+ Reviewed by Adam Barth.
+
+ Deploy Queue class in more places throughout QueueStatusServer
+ https://bugs.webkit.org/show_bug.cgi?id=47855
+
+ I also caught two typos from the previous change. Unfortunately
+ I don't yet know how to unittest request handlers yet.
+
+ * QueueStatusServer/handlers/dashboard.py:
+ * QueueStatusServer/handlers/statusbubble.py:
+ * QueueStatusServer/handlers/updateworkitems.py:
+ * QueueStatusServer/model/activeworkitems.py:
+ * QueueStatusServer/model/attachment.py:
+ * QueueStatusServer/model/queuepropertymixin.py: Added.
+ * QueueStatusServer/model/queuepropertymixin_unittest.py: Added.
+ * QueueStatusServer/model/queuestatus.py:
+ * QueueStatusServer/model/workitems.py:
+
2010-10-18 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
diff --git a/WebKitTools/QueueStatusServer/handlers/dashboard.py b/WebKitTools/QueueStatusServer/handlers/dashboard.py
index 3b93fff..660c595 100644
--- a/WebKitTools/QueueStatusServer/handlers/dashboard.py
+++ b/WebKitTools/QueueStatusServer/handlers/dashboard.py
@@ -41,7 +41,7 @@ class Dashboard(webapp.RequestHandler):
_header_names = [queue.short_name() for queue in _ordered_queues]
def _build_bubble(self, attachment, queue):
- queue_status = attachment.status_for_queue(queue.name())
+ queue_status = attachment.status_for_queue(queue)
bubble = {
"status_class": attachment.state_from_queue_status(queue_status) if queue_status else "none",
"status_date": queue_status.date if queue_status else None,
diff --git a/WebKitTools/QueueStatusServer/handlers/statusbubble.py b/WebKitTools/QueueStatusServer/handlers/statusbubble.py
index 3bad6d1..0f1601f 100644
--- a/WebKitTools/QueueStatusServer/handlers/statusbubble.py
+++ b/WebKitTools/QueueStatusServer/handlers/statusbubble.py
@@ -40,11 +40,11 @@ class StatusBubble(webapp.RequestHandler):
_queues_to_display = [queue for queue in Queue.all() if queue.is_ews()]
def _build_bubble(self, queue, attachment):
- queue_status = attachment.status_for_queue(queue.name())
+ queue_status = attachment.status_for_queue(queue)
bubble = {
"name": queue.short_name().lowercase(),
"attachment_id": attachment.id,
- "queue_position": attachment.position_in_queue(queue.name()),
+ "queue_position": attachment.position_in_queue(queue),
"state": attachment.state_from_queue_status(queue_status) if queue_status else "none",
"status": queue_status,
}
diff --git a/WebKitTools/QueueStatusServer/handlers/updateworkitems.py b/WebKitTools/QueueStatusServer/handlers/updateworkitems.py
index 41d96b6..7743297 100644
--- a/WebKitTools/QueueStatusServer/handlers/updateworkitems.py
+++ b/WebKitTools/QueueStatusServer/handlers/updateworkitems.py
@@ -40,15 +40,11 @@ class UpdateWorkItems(UpdateBase):
def get(self):
self.response.out.write(template.render("templates/updateworkitems.html", None))
- def _work_items_for_queue(self, queue_name):
- queue = Queue.queue_for_name(queue_name)
- if queue:
- self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all()))
- return None
- work_items = WorkItems.all().filter("queue_name =", queue_name).get()
+ def _work_items_for_queue(self, queue):
+ work_items = WorkItems.all().filter("queue_name =", queue.name()).get()
if not work_items:
work_items = WorkItems()
- work_items.queue_name = queue_name
+ work_items.queue = queue
return work_items
def _parse_work_items_string(self, items_string):
@@ -58,7 +54,12 @@ class UpdateWorkItems(UpdateBase):
def _work_items_from_request(self):
queue_name = self.request.get("queue_name")
- work_items = self._work_items_for_queue(queue_name)
+ queue = Queue.queue_for_name(queue_name)
+ if not queue:
+ self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all()))
+ return None
+
+ work_items = self._work_items_for_queue(queue)
if not work_items:
return None
items_string = self.request.get("work_items")
diff --git a/WebKitTools/QueueStatusServer/model/activeworkitems.py b/WebKitTools/QueueStatusServer/model/activeworkitems.py
index a244c7d..b218e63 100644
--- a/WebKitTools/QueueStatusServer/model/activeworkitems.py
+++ b/WebKitTools/QueueStatusServer/model/activeworkitems.py
@@ -31,8 +31,10 @@ from google.appengine.ext import db
from datetime import timedelta, datetime
import time
+from model.queuepropertymixin import QueuePropertyMixin
-class ActiveWorkItems(db.Model):
+
+class ActiveWorkItems(db.Model, QueuePropertyMixin):
queue_name = db.StringProperty()
item_ids = db.ListProperty(int)
item_dates = db.ListProperty(float)
diff --git a/WebKitTools/QueueStatusServer/model/attachment.py b/WebKitTools/QueueStatusServer/model/attachment.py
index a8f67fa..9a887e9 100644
--- a/WebKitTools/QueueStatusServer/model/attachment.py
+++ b/WebKitTools/QueueStatusServer/model/attachment.py
@@ -87,13 +87,12 @@ class Attachment(object):
return "pending"
return None
- def position_in_queue(self, queue_name):
- return self._queue_positions().get(queue_name)
+ def position_in_queue(self, queue):
+ return self._queue_positions().get(queue.name())
- def status_for_queue(self, queue_name):
- underscore_queue_name = Queue(queue_name).name_with_underscores()
+ def status_for_queue(self, queue):
# summary() is a horrible API and should be killed.
- queue_summary = self.summary().get(underscore_queue_name)
+ queue_summary = self.summary().get(queue.name_with_underscores())
if not queue_summary:
return None
return queue_summary.get("status")
@@ -109,16 +108,8 @@ class Attachment(object):
return self._cached_queue_positions
def _calculate_queue_positions(self):
- queue_positions = {}
- for work_items in WorkItems.all().fetch(limit=len(queues)):
- queue_name = str(work_items.queue_name)
- try:
- position = work_items.item_ids.index(self.id)
- # Display 1-based indecies to the user.
- queue_positions[queue_name] = position + 1
- except ValueError, e:
- queue_positions[queue_name] = None
- return queue_positions
+ all_work_items = WorkItems.all().fetch(limit=len(Queues.all()))
+ return dict([(items.queue.name(), items.display_position_for_attachment(self.id)) for items in all_work_items])
# FIXME: This is controller/view code and does not belong in a model.
def _fetch_summary(self):
@@ -130,13 +121,12 @@ class Attachment(object):
return summary
summary["bug_id"] = first_status.active_bug_id
- for queue in queues:
- summary[queue] = None
- status = QueueStatus.all().filter('queue_name =', queue).filter('active_patch_id =', self.id).order('-date').get()
+ for queue in Queues.all():
+ summary[queue.name_with_underscores()] = None
+ status = QueueStatus.all().filter('queue_name =', queue.name()).filter('active_patch_id =', self.id).order('-date').get()
if status:
- queue_name = Queue(queue_name).name_with_underscores()
# summary() is a horrible API and should be killed.
- summary[queue_name] = {
+ summary[queue.name_with_underscores()] = {
"state": self.state_from_queue_status(status),
"status": status,
}
diff --git a/WebKitTools/QueueStatusServer/model/queuepropertymixin.py b/WebKitTools/QueueStatusServer/model/queuepropertymixin.py
new file mode 100644
index 0000000..1e3853e
--- /dev/null
+++ b/WebKitTools/QueueStatusServer/model/queuepropertymixin.py
@@ -0,0 +1,39 @@
+# Copyright (C) 2010 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from model.queues import Queue
+
+
+class QueuePropertyMixin(object):
+ def _queue_getter(self):
+ return Queue.queue_from_name(self.queue_name)
+
+ def _queue_setter(self, queue):
+ self.queue_name = queue.name() if queue else None
+
+ queue = property(_queue_getter, _queue_setter)
diff --git a/WebKitTools/QueueStatusServer/model/queuepropertymixin_unittest.py b/WebKitTools/QueueStatusServer/model/queuepropertymixin_unittest.py
new file mode 100644
index 0000000..3841a9f
--- /dev/null
+++ b/WebKitTools/QueueStatusServer/model/queuepropertymixin_unittest.py
@@ -0,0 +1,51 @@
+# Copyright (C) 2010 Google, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Research in Motion Ltd. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import unittest
+
+from model.queuepropertymixin import QueuePropertyMixin
+from model.queues import Queue
+
+
+class ObjectWithQueueName(QueuePropertyMixin):
+ def __init__(self):
+ self.queue_name = None
+
+
+class QueuePropertyMixinTest(unittest.TestCase):
+ def test_queue_property(self):
+ test_object = ObjectWithQueueName()
+ mac_ews = Queue("mac-ews")
+ test_object.queue = mac_ews
+ self.assertEquals(test_object.queue_name, "mac-ews")
+ test_object.queue = None
+ self.assertEquals(test_object.queue_name, None)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/WebKitTools/QueueStatusServer/model/queuestatus.py b/WebKitTools/QueueStatusServer/model/queuestatus.py
index d7dae45..68b50da 100644
--- a/WebKitTools/QueueStatusServer/model/queuestatus.py
+++ b/WebKitTools/QueueStatusServer/model/queuestatus.py
@@ -27,8 +27,10 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from google.appengine.ext import db
+from model.queuepropertymixin import QueuePropertyMixin
-class QueueStatus(db.Model):
+
+class QueueStatus(db.Model, QueuePropertyMixin):
author = db.UserProperty()
queue_name = db.StringProperty()
bot_id = db.StringProperty()
diff --git a/WebKitTools/QueueStatusServer/model/workitems.py b/WebKitTools/QueueStatusServer/model/workitems.py
index 3ea59cb..45125c9 100644
--- a/WebKitTools/QueueStatusServer/model/workitems.py
+++ b/WebKitTools/QueueStatusServer/model/workitems.py
@@ -28,8 +28,18 @@
from google.appengine.ext import db
+from model.queuepropertymixin import QueuePropertyMixin
-class WorkItems(db.Model):
+
+class WorkItems(db.Model, QueuePropertyMixin):
queue_name = db.StringProperty()
item_ids = db.ListProperty(int)
date = db.DateTimeProperty(auto_now_add=True)
+
+ def display_position_for_attachment(self, attachment_id):
+ """Returns a 1-based index corresponding to the position
+ of the attachment_id in the queue. If the attachment is
+ not in this queue, this returns None"""
+ if attachment_id in attachment_id:
+ return self.item_ids.index(attachment_id) + 1
+ return None
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list