Merge ~ilasc/launchpad:stormify-bug-tracker-person into launchpad:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: 7b0581eb2623a52de537709d0257993de139bfbf
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/launchpad:stormify-bug-tracker-person
Merge into: launchpad:master
Diff against target: 180 lines (+50/-26)
3 files modified
lib/lp/bugs/doc/externalbugtracker-comment-imports.txt (+17/-12)
lib/lp/bugs/model/bugtracker.py (+5/-1)
lib/lp/bugs/model/bugtrackerperson.py (+28/-13)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+390284@code.launchpad.net

Commit message

Stormify BugTrackerPerson

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
7b0581e... by Ioana Lasc

Change Moin-style headings RST-style

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt b/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt
2index 7c7a5b0..d2c7931 100644
3--- a/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt
4+++ b/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt
5@@ -1,4 +1,5 @@
6-= ExternalBugTracker comment imports =
7+ExternalBugTracker comment imports
8+**********************************
9
10 Some ExternalBugTrackers support the importing of comments from the
11 remote bug tracker into Launchpad.
12@@ -7,7 +8,6 @@ In order to demonstrate this we need to create example Bug, BugTracker
13 and BugWatch instances with which to work.
14
15 >>> from zope.interface import implementer
16- >>> from lp.services.config import config
17 >>> from lp.bugs.tests.externalbugtracker import (
18 ... new_bugtracker)
19 >>> from lp.services.messages.interfaces.message import IMessageSet
20@@ -41,7 +41,8 @@ ExternalBugTracker class which implements these three methods.
21
22 >>> from lp.bugs.externalbugtracker import (
23 ... ExternalBugTracker)
24- >>> from lp.bugs.interfaces.externalbugtracker import ISupportsCommentImport
25+ >>> from lp.bugs.interfaces.externalbugtracker import (
26+ ... ISupportsCommentImport)
27 >>> @implementer(ISupportsCommentImport)
28 ... class CommentImportingExternalBugTracker(ExternalBugTracker):
29 ...
30@@ -139,7 +140,8 @@ form which it was imported.
31 four: Yet another comment.
32
33
34-== Creating Person records ==
35+Creating Person records
36+***********************
37
38 In the examples above, joe.bloggs@example.com was used as the poster of
39 all the comments. Since Joe didn't have a Launchpad account, it was
40@@ -186,7 +188,7 @@ address. In those cases, the ExternalBugTracker's getPosterForComment()
41 method will return a tuple of (displayname, None), which can then be
42 used to create a Person based on the displayname alone.
43
44- >>> external_bugtracker.poster_tuple = ('noemail', None)
45+ >>> external_bugtracker.poster_tuple = (u'noemail', None)
46 >>> external_bugtracker.remote_comments['no-email-comment'] = (
47 ... "Yet another comment.")
48
49@@ -204,8 +206,8 @@ used to create a Person based on the displayname alone.
50 A BugTrackerPerson record will have been created to map the new Person
51 to the name 'noemail' on our example bugtracker.
52
53- >>> bug_watch.bugtracker.getLinkedPersonByName('noemail')
54- <BugTrackerPerson at ...>
55+ >>> bug_watch.bugtracker.getLinkedPersonByName(u'noemail')
56+ <lp.bugs.model.bugtrackerperson.BugTrackerPerson ...>
57
58 If the remote person is invalid (i.e. a Launchpad Person can't be
59 created for them) an error will be logged and the comment will not be
60@@ -232,7 +234,8 @@ Let's delete that comment now so that it doesn't break later tests.
61 ... 'No Priv', 'no-priv@canonical.com')
62
63
64-== BugWatch comment importing functionality ==
65+BugWatch comment importing functionality
66+****************************************
67
68 The IBugWatch interface provides methods for linking imported comments
69 to bug watches and for checking whether an imported comment is already
70@@ -308,7 +311,8 @@ remote tracker and will not be returned by getImportedBugMessages()
71 >>> transaction.commit()
72
73
74-== Importing two messages with the same ID ==
75+Importing two messages with the same ID
76+***************************************
77
78 It is possible for two Messages with the same ID to coexist within
79 Launchpad, for example if a comment on a bug was sent to both Launchpad
80@@ -366,7 +370,8 @@ examining the BugMessages which link the messages to the bug.
81 True
82
83
84-== Importing comments with CVE references ==
85+Importing comments with CVE references
86+**************************************
87
88 If a comment contains a CVE reference, that CVE reference will be
89 imported and linked to the bug. However, the user who authored the
90@@ -422,8 +427,8 @@ Once again, CVE links are created but no karma is assigned.
91
92 >>> karma_helper.unregister_listener()
93
94-
95-== Email notifications ==
96+Email notifications
97+*******************
98
99 When bug comments are imported, notifications are sent to inform the bug
100 subscribers about it. The first time we import comments from a bug
101diff --git a/lib/lp/bugs/model/bugtracker.py b/lib/lp/bugs/model/bugtracker.py
102index 21375c7..6b840f0 100644
103--- a/lib/lp/bugs/model/bugtracker.py
104+++ b/lib/lp/bugs/model/bugtracker.py
105@@ -605,7 +605,11 @@ class BugTracker(SQLBase):
106
107 def getLinkedPersonByName(self, name):
108 """Return the Person with a given name on this bugtracker."""
109- return BugTrackerPerson.selectOneBy(name=name, bugtracker=self)
110+ person = IStore(BugTrackerPerson).find(
111+ BugTrackerPerson,
112+ BugTrackerPerson.name == name,
113+ BugTrackerPerson.bugtracker == self).one()
114+ return person
115
116 def linkPersonToSelf(self, name, person):
117 """See `IBugTrackerSet`."""
118diff --git a/lib/lp/bugs/model/bugtrackerperson.py b/lib/lp/bugs/model/bugtrackerperson.py
119index ce4f989..8008680 100644
120--- a/lib/lp/bugs/model/bugtrackerperson.py
121+++ b/lib/lp/bugs/model/bugtrackerperson.py
122@@ -1,4 +1,4 @@
123-# Copyright 2009 Canonical Ltd. This software is licensed under the
124+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
125 # GNU Affero General Public License version 3 (see the file LICENSE).
126
127 """BugTrackerPerson database class."""
128@@ -8,25 +8,40 @@ __all__ = [
129 'BugTrackerPerson',
130 ]
131
132-from sqlobject import (
133- ForeignKey,
134- StringCol,
135+import pytz
136+import six
137+from storm.locals import (
138+ DateTime,
139+ Int,
140+ Reference,
141+ Unicode,
142 )
143 from zope.interface import implementer
144
145 from lp.bugs.interfaces.bugtrackerperson import IBugTrackerPerson
146 from lp.services.database.constants import UTC_NOW
147-from lp.services.database.datetimecol import UtcDateTimeCol
148-from lp.services.database.sqlbase import SQLBase
149+from lp.services.database.stormbase import StormBase
150
151
152 @implementer(IBugTrackerPerson)
153-class BugTrackerPerson(SQLBase):
154+class BugTrackerPerson(StormBase):
155 """See `IBugTrackerPerson`."""
156+ __storm_table__ = 'BugTrackerPerson'
157+ id = Int(primary=True)
158
159- bugtracker = ForeignKey(
160- dbName='bugtracker', foreignKey='BugTracker', notNull=True)
161- person = ForeignKey(
162- dbName='person', foreignKey='Person', notNull=True)
163- name = StringCol(notNull=True)
164- date_created = UtcDateTimeCol(notNull=True, default=UTC_NOW)
165+ bugtracker_id = Int(name='bugtracker', allow_none=False)
166+ bugtracker = Reference(bugtracker_id, 'BugTracker.id')
167+
168+ person_id = Int(name='person', allow_none=False)
169+ person = Reference(person_id, 'Person.id')
170+
171+ name = Unicode(allow_none=False)
172+
173+ date_created = DateTime(
174+ tzinfo=pytz.UTC, name='date_created', allow_none=False,
175+ default=UTC_NOW)
176+
177+ def __init__(self, name, bugtracker, person):
178+ self.bugtracker = bugtracker
179+ self.person = person
180+ self.name = six.ensure_text(name)

Subscribers

People subscribed via source and target branches

to status/vote changes: