incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1301699 - in /incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct: __init__.py common.py ticket/__init__.py ticket/web_ui.py
Date Fri, 16 Mar 2012 18:57:06 GMT
Author: gjm
Date: Fri Mar 16 18:57:05 2012
New Revision: 1301699

URL: http://svn.apache.org/viewvc?rev=1301699&view=rev
Log:
provides an override for the ReportModule; small refactor to separate out common determination
of the product from the path

Added:
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/common.py   (with props)
Modified:
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/__init__.py
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py

Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/__init__.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/__init__.py?rev=1301699&r1=1301698&r2=1301699&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/__init__.py (original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/__init__.py Fri Mar 16
18:57:05 2012
@@ -20,3 +20,4 @@
 from model import MultiProductEnvironmentProvider
 from product_admin import ProductAdminPanel
 import multiproduct.ticket
+import common

Added: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/common.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/common.py?rev=1301699&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/common.py (added)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/common.py Fri Mar 16 18:57:05
2012
@@ -0,0 +1,37 @@
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+import re
+
+from multiproduct.model import Product
+
+PRODUCT_RE = re.compile(r'^/(?P<pid>[^/]*)(?P<pathinfo>.*)')
+
+def match_product_path(env, req):
+    """Matches a product in pathinfo, stores the associated product id and
+    returns what is left"""
+    pathinfo = req.path_info[:]
+    match = PRODUCT_RE.match(pathinfo)
+    if match:
+        pid = match.group('pid')
+        products = Product.select(env, where={'prefix':pid})
+        if len(products) == 1:
+            req.args['productid'] = match.group('pid')
+            req.args['product'] = products[0].name
+            pathinfo = match.group('pathinfo')
+    return pathinfo

Propchange: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/common.py
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py?rev=1301699&r1=1301698&r2=1301699&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py (original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py Fri
Mar 16 18:57:05 2012
@@ -17,5 +17,5 @@
 #  under the License.
 
 """multiproduct ticket related functionality and overrides"""
-from web_ui import ProductTicketModule
-from api import ProductTicketFields
+from web_ui import ProductTicketModule, ProductReportModule
+from api import ProductTicketFields
\ No newline at end of file

Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py?rev=1301699&r1=1301698&r2=1301699&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py (original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py Fri Mar
16 18:57:05 2012
@@ -22,6 +22,7 @@ import re
 
 from trac.core import TracError
 from trac.ticket.web_ui import TicketModule
+from trac.ticket.report import ReportModule
 from trac.attachment import AttachmentModule
 from trac.ticket.api import TicketSystem
 from trac.resource import Resource, get_resource_shortname
@@ -30,26 +31,18 @@ from trac.util.datefmt import from_utime
 from trac.util.translation import _, tag_
 from genshi.builder import tag
 
-from multiproduct.model import Product
+from multiproduct.common import match_product_path
 
-PRODUCT_RE = re.compile(r'^/(?P<pid>[^/]*)(?P<pathinfo>.*)')
 TICKET_RE = re.compile(r'/ticket/(?P<ticket>[0-9]+)$')
+REPORT_RE = re.compile(r'/report(?:/(?:([0-9]+)|-1))?$')
+
 class ProductTicketModule(TicketModule):
     """Product Overrides for the TicketModule"""
     
     # IRequestHandler methods
     def match_request(self, req):
         """Override of TicketModule match_request"""
-        pathinfo = req.path_info[:]
-        match = PRODUCT_RE.match(pathinfo)
-        if match:
-            pid = match.group('pid')
-            products = Product.select(self.env, where={'prefix':pid})
-            if len(products) == 1:
-                req.args['productid'] = match.group('pid')
-                req.args['product'] = products[0].name
-                pathinfo = match.group('pathinfo')
-            
+        pathinfo = match_product_path(self.env, req)
         # is it a newticket request:
         if pathinfo == "/newticket":
             return True
@@ -137,3 +130,19 @@ class ProductTicketModule(TicketModule):
         for result in AttachmentModule(self.env).get_search_results(
             req, ticket_realm, terms):
             yield result
+
+class ProductReportModule(ReportModule):
+    """replacement for ReportModule"""
+    
+    # IRequestHandler methods
+    def match_request(self, req):
+        """Override of ReportModule match_request"""
+        pathinfo = match_product_path(self.env, req)
+        match = REPORT_RE.match(pathinfo)
+        if match:
+            if match.group(1):
+                req.args['id'] = match.group(1)
+            return True
+    
+    #def process_request(self, req):
+    # not yet required



Mime
View raw message