Return-Path: X-Original-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EA18E9A1E for ; Sun, 1 Apr 2012 01:29:51 +0000 (UTC) Received: (qmail 96867 invoked by uid 500); 1 Apr 2012 01:29:51 -0000 Delivered-To: apmail-incubator-bloodhound-commits-archive@incubator.apache.org Received: (qmail 96850 invoked by uid 500); 1 Apr 2012 01:29:51 -0000 Mailing-List: contact bloodhound-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bloodhound-dev@incubator.apache.org Delivered-To: mailing list bloodhound-commits@incubator.apache.org Received: (qmail 96843 invoked by uid 99); 1 Apr 2012 01:29:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Apr 2012 01:29:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Apr 2012 01:29:49 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EB556238890B; Sun, 1 Apr 2012 01:29:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1307983 - in /incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard: api.py web_ui.py Date: Sun, 01 Apr 2012 01:29:27 -0000 To: bloodhound-commits@incubator.apache.org From: gjm@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120401012927.EB556238890B@eris.apache.org> Author: gjm Date: Sun Apr 1 01:29:27 2012 New Revision: 1307983 URL: http://svn.apache.org/viewvc?rev=1307983&view=rev Log: Dashboard code import: BH_Dashboard: Widget providers in schema loaded dynamically Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py?rev=1307983&r1=1307982&r2=1307983&view=diff ============================================================================== --- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py (original) +++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py Sun Apr 1 01:29:27 2012 @@ -92,7 +92,7 @@ class ILayoutProvider(Interface): class DashboardSystem(Component): implements(IPermissionRequestor) - providers = ExtensionPoint(IWidgetProvider) + widget_providers = ExtensionPoint(IWidgetProvider) # IPermissionRequestor methods def get_permission_actions(self): Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py?rev=1307983&r1=1307982&r2=1307983&view=diff ============================================================================== --- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py (original) +++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py Sun Apr 1 01:29:27 2012 @@ -35,10 +35,13 @@ from trac.mimeview.api import Context from trac.util.translation import _ from trac.ticket.query import QueryModule from trac.ticket.report import ReportModule +from trac.util.compat import groupby from trac.web.api import IRequestHandler from trac.web.chrome import add_ctxtnav, add_stylesheet, Chrome, \ INavigationContributor, ITemplateProvider +from bhdashboard.api import DashboardSystem + class DashboardModule(Component): implements(IRequestHandler, INavigationContributor, ITemplateProvider) @@ -140,7 +143,6 @@ class DashboardModule(Component): ], 'widgets' : [ { - 'c' : TicketQueryWidget(self.env), 'args' : ['TicketQuery', ctx, {'args' : {'max' : 10, 'query' : dashboard_query, @@ -149,11 +151,9 @@ class DashboardModule(Component): 'altlinks' : False }, { - 'c' : TimelineWidget(self.env), 'args' : ['Timeline', ctx, {'args' : {}}] }, { - 'c' : TicketFieldCloudWidget(self.env), 'args' : ['TicketFieldCloud', ctx, {'args' : {'field' : 'component', 'verbose' : True} @@ -175,6 +175,18 @@ class DashboardModule(Component): """ # TODO: Implement dynamic dashboard specification widgets_spec = schema.pop('widgets', []) + widgets_index = dict([k, list(v)] for k,v in \ + groupby(widgets_spec, lambda w : w['args'][0])) + for wp in DashboardSystem(self.env).widget_providers: + for wnm in wp.get_widgets(): + substitutions = widgets_index.pop(wnm, []) + i = -1 + for i, w in enumerate(substitutions): + w['c'] = wp + self.log.debug('Widget %s (%s substitutions)', wnm, i + 1) + if len(widgets_index) > 0: + raise LookupError('Unknown provider for widgets %s', + ' , '.join(widgets_index.keys())) chrome = Chrome(self.env) render = chrome.render_template data_strm = (w['c'].render_widget(*w['args']) for w in widgets_spec)