launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25257
[Merge] ~ilasc/launchpad:stormify-bug-tracker-person into launchpad:master
Ioana Lasc has proposed merging ~ilasc/launchpad:stormify-bug-tracker-person into launchpad:master.
Commit message:
Stormify BugTrackerPerson
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/390284
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:stormify-bug-tracker-person into launchpad:master.
diff --git a/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt b/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt
index 7c7a5b0..58d407e 100644
--- a/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt
+++ b/lib/lp/bugs/doc/externalbugtracker-comment-imports.txt
@@ -1,5 +1,3 @@
-= ExternalBugTracker comment imports =
-
Some ExternalBugTrackers support the importing of comments from the
remote bug tracker into Launchpad.
@@ -7,7 +5,6 @@ In order to demonstrate this we need to create example Bug, BugTracker
and BugWatch instances with which to work.
>>> from zope.interface import implementer
- >>> from lp.services.config import config
>>> from lp.bugs.tests.externalbugtracker import (
... new_bugtracker)
>>> from lp.services.messages.interfaces.message import IMessageSet
@@ -41,7 +38,8 @@ ExternalBugTracker class which implements these three methods.
>>> from lp.bugs.externalbugtracker import (
... ExternalBugTracker)
- >>> from lp.bugs.interfaces.externalbugtracker import ISupportsCommentImport
+ >>> from lp.bugs.interfaces.externalbugtracker import (
+ ... ISupportsCommentImport)
>>> @implementer(ISupportsCommentImport)
... class CommentImportingExternalBugTracker(ExternalBugTracker):
...
@@ -139,8 +137,6 @@ form which it was imported.
four: Yet another comment.
-== Creating Person records ==
-
In the examples above, joe.bloggs@xxxxxxxxxxx was used as the poster of
all the comments. Since Joe didn't have a Launchpad account, it was
created automatically for him, with the email address marked as
@@ -186,7 +182,7 @@ address. In those cases, the ExternalBugTracker's getPosterForComment()
method will return a tuple of (displayname, None), which can then be
used to create a Person based on the displayname alone.
- >>> external_bugtracker.poster_tuple = ('noemail', None)
+ >>> external_bugtracker.poster_tuple = (u'noemail', None)
>>> external_bugtracker.remote_comments['no-email-comment'] = (
... "Yet another comment.")
@@ -204,8 +200,8 @@ used to create a Person based on the displayname alone.
A BugTrackerPerson record will have been created to map the new Person
to the name 'noemail' on our example bugtracker.
- >>> bug_watch.bugtracker.getLinkedPersonByName('noemail')
- <BugTrackerPerson at ...>
+ >>> bug_watch.bugtracker.getLinkedPersonByName(u'noemail')
+ <lp.bugs.model.bugtrackerperson.BugTrackerPerson ...>
If the remote person is invalid (i.e. a Launchpad Person can't be
created for them) an error will be logged and the comment will not be
@@ -232,8 +228,6 @@ Let's delete that comment now so that it doesn't break later tests.
... 'No Priv', 'no-priv@xxxxxxxxxxxxx')
-== BugWatch comment importing functionality ==
-
The IBugWatch interface provides methods for linking imported comments
to bug watches and for checking whether an imported comment is already
linked to a bug watch.
@@ -308,8 +302,6 @@ remote tracker and will not be returned by getImportedBugMessages()
>>> transaction.commit()
-== Importing two messages with the same ID ==
-
It is possible for two Messages with the same ID to coexist within
Launchpad, for example if a comment on a bug was sent to both Launchpad
and to DebBugs and the subsequently imported into Launchpad from the
@@ -366,8 +358,6 @@ examining the BugMessages which link the messages to the bug.
True
-== Importing comments with CVE references ==
-
If a comment contains a CVE reference, that CVE reference will be
imported and linked to the bug. However, the user who authored the
comment containing the CVE reference doesn't get any karma from this
@@ -423,8 +413,6 @@ Once again, CVE links are created but no karma is assigned.
>>> karma_helper.unregister_listener()
-== Email notifications ==
-
When bug comments are imported, notifications are sent to inform the bug
subscribers about it. The first time we import comments from a bug
watch, there can be a lot of comments. To avoid causing a lot of email
diff --git a/lib/lp/bugs/model/bugtracker.py b/lib/lp/bugs/model/bugtracker.py
index 21375c7..6b840f0 100644
--- a/lib/lp/bugs/model/bugtracker.py
+++ b/lib/lp/bugs/model/bugtracker.py
@@ -605,7 +605,11 @@ class BugTracker(SQLBase):
def getLinkedPersonByName(self, name):
"""Return the Person with a given name on this bugtracker."""
- return BugTrackerPerson.selectOneBy(name=name, bugtracker=self)
+ person = IStore(BugTrackerPerson).find(
+ BugTrackerPerson,
+ BugTrackerPerson.name == name,
+ BugTrackerPerson.bugtracker == self).one()
+ return person
def linkPersonToSelf(self, name, person):
"""See `IBugTrackerSet`."""
diff --git a/lib/lp/bugs/model/bugtrackerperson.py b/lib/lp/bugs/model/bugtrackerperson.py
index ce4f989..8008680 100644
--- a/lib/lp/bugs/model/bugtrackerperson.py
+++ b/lib/lp/bugs/model/bugtrackerperson.py
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""BugTrackerPerson database class."""
@@ -8,25 +8,40 @@ __all__ = [
'BugTrackerPerson',
]
-from sqlobject import (
- ForeignKey,
- StringCol,
+import pytz
+import six
+from storm.locals import (
+ DateTime,
+ Int,
+ Reference,
+ Unicode,
)
from zope.interface import implementer
from lp.bugs.interfaces.bugtrackerperson import IBugTrackerPerson
from lp.services.database.constants import UTC_NOW
-from lp.services.database.datetimecol import UtcDateTimeCol
-from lp.services.database.sqlbase import SQLBase
+from lp.services.database.stormbase import StormBase
@implementer(IBugTrackerPerson)
-class BugTrackerPerson(SQLBase):
+class BugTrackerPerson(StormBase):
"""See `IBugTrackerPerson`."""
+ __storm_table__ = 'BugTrackerPerson'
+ id = Int(primary=True)
- bugtracker = ForeignKey(
- dbName='bugtracker', foreignKey='BugTracker', notNull=True)
- person = ForeignKey(
- dbName='person', foreignKey='Person', notNull=True)
- name = StringCol(notNull=True)
- date_created = UtcDateTimeCol(notNull=True, default=UTC_NOW)
+ bugtracker_id = Int(name='bugtracker', allow_none=False)
+ bugtracker = Reference(bugtracker_id, 'BugTracker.id')
+
+ person_id = Int(name='person', allow_none=False)
+ person = Reference(person_id, 'Person.id')
+
+ name = Unicode(allow_none=False)
+
+ date_created = DateTime(
+ tzinfo=pytz.UTC, name='date_created', allow_none=False,
+ default=UTC_NOW)
+
+ def __init__(self, name, bugtracker, person):
+ self.bugtracker = bugtracker
+ self.person = person
+ self.name = six.ensure_text(name)