Merge lp:~stevenk/launchpad/dsp-changelog-timeout into lp:launchpad

Proposed by Steve Kowalik on 2012-09-12
Status: Merged
Approved by: William Grant on 2012-09-12
Approved revision: no longer in the source branch.
Merged at revision: 15942
Proposed branch: lp:~stevenk/launchpad/dsp-changelog-timeout
Merge into: lp:launchpad
Diff against target: 103 lines (+14/-29)
2 files modified
lib/lp/app/browser/stringformatter.py (+10/-13)
lib/lp/registry/browser/distributionsourcepackage.py (+4/-16)
To merge this branch: bzr merge lp:~stevenk/launchpad/dsp-changelog-timeout
Reviewer Review Type Date Requested Status
William Grant code 2012-09-12 Approve on 2012-09-12
Review via email: mp+123880@code.launchpad.net

Commit Message

Destroy the bug pre-loading in DistributionSourcePackage:+changelog. All it buys us is a slow awkward query.

Description of the Change

Destroy the bug pre-loading in DistributionSourcePackage:+changelog. For busy packages this would end up bringing in huge numbers of bugs that we don't need to since we linkify them anyway.

Clean up stringformatter, since it was a *mess*.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/browser/stringformatter.py'
2--- lib/lp/app/browser/stringformatter.py 2012-07-09 14:10:11 +0000
3+++ lib/lp/app/browser/stringformatter.py 2012-09-12 04:33:21 +0000
4@@ -1,9 +1,7 @@
5-# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
6+# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """TALES formatter for strings."""
10-from base64 import urlsafe_b64encode
11-
12
13 __metaclass__ = type
14 __all__ = [
15@@ -18,12 +16,13 @@
16 'split_paragraphs',
17 ]
18
19+from base64 import urlsafe_b64encode
20 import cgi
21 import re
22+from xml.sax.saxutils import unescape as xml_unescape
23+
24 from lxml import html
25-from xml.sax.saxutils import unescape as xml_unescape
26 import markdown
27-
28 from zope.component import getUtility
29 from zope.interface import implements
30 from zope.traversing.interfaces import (
31@@ -31,18 +30,16 @@
32 TraversalError,
33 )
34
35-from lp.services.config import config
36-from lp.services.webapp import canonical_url
37-from lp.services.webapp.interfaces import ILaunchBag
38 from lp.answers.interfaces.faq import IFAQSet
39 from lp.registry.interfaces.person import IPersonSet
40+from lp.services.config import config
41+from lp.services.features import getFeatureFlag
42 from lp.services.utils import (
43+ obfuscate_email,
44 re_email_address,
45- obfuscate_email,
46- )
47-from lp.services.features import (
48- getFeatureFlag,
49- )
50+ )
51+from lp.services.webapp import canonical_url
52+from lp.services.webapp.interfaces import ILaunchBag
53
54
55 def escape(text, quote=True):
56
57=== modified file 'lib/lp/registry/browser/distributionsourcepackage.py'
58--- lib/lp/registry/browser/distributionsourcepackage.py 2012-08-09 16:39:41 +0000
59+++ lib/lp/registry/browser/distributionsourcepackage.py 2012-09-12 04:33:21 +0000
60@@ -41,10 +41,7 @@
61 action,
62 LaunchpadEditFormView,
63 )
64-from lp.app.browser.stringformatter import (
65- extract_bug_numbers,
66- extract_email_addresses,
67- )
68+from lp.app.browser.stringformatter import extract_email_addresses
69 from lp.app.browser.tales import CustomizableFormatter
70 from lp.app.enums import ServiceUsage
71 from lp.app.interfaces.launchpad import IServiceUsage
72@@ -54,7 +51,6 @@
73 StructuralSubscriptionMenuMixin,
74 StructuralSubscriptionTargetTraversalMixin,
75 )
76-from lp.bugs.interfaces.bug import IBugSet
77 from lp.bugs.interfaces.bugtask import BugTaskStatus
78 from lp.bugs.interfaces.bugtasksearch import BugTaskSearchParams
79 from lp.registry.browser import add_subscribe_link
80@@ -290,20 +286,12 @@
81 return []
82
83 sprs = [dspr.sourcepackagerelease for (dspr, spphs) in dspr_pubs]
84- # Pre-load the bugs and persons referenced by the +changelog page from
85- # the database.
86- # This will improve the performance of the ensuing changelog
87- # linkification.
88+ # Preload email/person data only if user is logged on. In the opposite
89+ # case the emails in the changelog will be obfuscated anyway and thus
90+ # cause no database lookups.
91 the_changelog = '\n'.join(
92 [spr.changelog_entry for spr in sprs
93 if not_empty(spr.changelog_entry)])
94- unique_bugs = extract_bug_numbers(the_changelog)
95- self._bug_data = list(
96- getUtility(IBugSet).getByNumbers(
97- [int(key) for key in unique_bugs.keys()]))
98- # Preload email/person data only if user is logged on. In the opposite
99- # case the emails in the changelog will be obfuscated anyway and thus
100- # cause no database lookups.
101 if self.user:
102 self._person_data = dict(
103 [(email.email, person) for (email, person) in