Merge ~cjwatson/launchpad:stormify-bug into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 781668475e3065ef27a871302ea3b82ad5ae1c1c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:stormify-bug
Merge into: launchpad:master
Diff against target: 602 lines (+107/-91)
21 files modified
lib/lp/answers/doc/karma.rst (+1/-1)
lib/lp/bugs/browser/bug.py (+2/-5)
lib/lp/bugs/browser/buglisting.py (+1/-1)
lib/lp/bugs/browser/bugtask.py (+1/-1)
lib/lp/bugs/doc/bug.rst (+1/-1)
lib/lp/bugs/doc/bugnotificationrecipients.rst (+3/-2)
lib/lp/bugs/doc/bugnotifications.rst (+1/-1)
lib/lp/bugs/doc/cve.rst (+2/-1)
lib/lp/bugs/interfaces/bug.py (+1/-1)
lib/lp/bugs/model/bug.py (+69/-52)
lib/lp/bugs/model/bugtask.py (+2/-2)
lib/lp/bugs/model/bugtasksearch.py (+1/-1)
lib/lp/bugs/model/personsubscriptioninfo.py (+1/-1)
lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst (+4/-3)
lib/lp/bugs/templates/bug-portlet-duplicates.pt (+1/-1)
lib/lp/bugs/tests/bugs-emailinterface.rst (+8/-8)
lib/lp/bugs/vocabularies.py (+2/-3)
lib/lp/registry/tests/test_person.py (+1/-1)
lib/lp/scripts/harness.py (+2/-2)
lib/lp/services/database/tests/test_bulk.py (+1/-1)
lib/lp/services/statistics/model/statistics.py (+2/-2)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+447358@code.launchpad.net

Commit message

Convert Bug to Storm

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Guruprasad (lgp171188) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/answers/doc/karma.rst b/lib/lp/answers/doc/karma.rst
2index 5bc61ef..488a2a3 100644
3--- a/lib/lp/answers/doc/karma.rst
4+++ b/lib/lp/answers/doc/karma.rst
5@@ -216,7 +216,7 @@ Linking to a bug
6 ................
7
8 >>> from lp.bugs.model.bug import Bug
9- >>> questionbug = firefox_question.linkBug(Bug.get(5))
10+ >>> questionbug = firefox_question.linkBug(IStore(Bug).get(Bug, 5))
11 Karma added: action=questionlinkedtobug, product=firefox, person=name12
12
13
14diff --git a/lib/lp/bugs/browser/bug.py b/lib/lp/bugs/browser/bug.py
15index 3a34c23..190ba78 100644
16--- a/lib/lp/bugs/browser/bug.py
17+++ b/lib/lp/bugs/browser/bug.py
18@@ -1202,11 +1202,8 @@ class BugTextView(LaunchpadView):
19 else:
20 text.append("duplicate-of: ")
21
22- if bug.duplicates:
23- dupes = " ".join(str(dupe.id) for dupe in bug.duplicates)
24- text.append("duplicates: %s" % dupes)
25- else:
26- text.append("duplicates: ")
27+ dupes = " ".join(str(dupe.id) for dupe in bug.duplicates)
28+ text.append("duplicates: %s" % dupes)
29
30 if bug.private:
31 # XXX kiko 2007-10-31: this could include date_made_private and
32diff --git a/lib/lp/bugs/browser/buglisting.py b/lib/lp/bugs/browser/buglisting.py
33index cef7d6e..3b579c7 100644
34--- a/lib/lp/bugs/browser/buglisting.py
35+++ b/lib/lp/bugs/browser/buglisting.py
36@@ -682,7 +682,7 @@ class BugTaskListingItem:
37 assignee = None
38 if self.assignee_id is not None:
39 assignee = self.people[self.assignee_id].displayname
40- reporter = self.people[self.bug.ownerID]
41+ reporter = self.people[self.bug.owner_id]
42
43 # the case that there is no target context (e.g. viewing bug that
44 # are related to a user account) is intercepted
45diff --git a/lib/lp/bugs/browser/bugtask.py b/lib/lp/bugs/browser/bugtask.py
46index ad3a7a2..adedd6b 100644
47--- a/lib/lp/bugs/browser/bugtask.py
48+++ b/lib/lp/bugs/browser/bugtask.py
49@@ -435,7 +435,7 @@ class BugTaskView(LaunchpadView, BugViewMixin, FeedsMixin):
50 self.context = context
51 list(
52 getUtility(IPersonSet).getPrecachedPersonsFromIDs(
53- [self.context.bug.ownerID], need_validity=True
54+ [self.context.bug.owner_id], need_validity=True
55 )
56 )
57
58diff --git a/lib/lp/bugs/doc/bug.rst b/lib/lp/bugs/doc/bug.rst
59index e1c54e5..7893e52 100644
60--- a/lib/lp/bugs/doc/bug.rst
61+++ b/lib/lp/bugs/doc/bug.rst
62@@ -263,7 +263,7 @@ private:
63 >>> from lp.bugs.model.bug import Bug
64 >>> from lp.services.database.interfaces import IStore
65
66- >>> all_bugs = set(IStore(Bug).find(Bug).values(Bug.id))
67+ >>> all_bugs = set(IStore(Bug).find(Bug.id))
68
69 >>> taskset = getUtility(IBugTaskSet)
70 >>> def hidden_bugs():
71diff --git a/lib/lp/bugs/doc/bugnotificationrecipients.rst b/lib/lp/bugs/doc/bugnotificationrecipients.rst
72index c633ea9..c3688c9 100644
73--- a/lib/lp/bugs/doc/bugnotificationrecipients.rst
74+++ b/lib/lp/bugs/doc/bugnotificationrecipients.rst
75@@ -14,7 +14,8 @@ action:
76 >>> from lp.bugs.model.bug import Bug
77 >>> from lp.registry.model.distribution import Distribution
78 >>> from lp.registry.model.product import Product
79- >>> bug_one = Bug.get(1)
80+ >>> from lp.services.database.interfaces import IStore
81+ >>> bug_one = IStore(Bug).get(Bug, 1)
82 >>> recipients = bug_one.getBugNotificationRecipients()
83
84 The instance of BugNotificationRecipients we get back correctly
85@@ -124,7 +125,7 @@ additional step is involved. A BugNotificationRecipients instance is
86 created, annotating that it represents a master bug (of which we are a
87 duplicate of).
88
89- >>> bug_two = Bug.get(2)
90+ >>> bug_two = IStore(Bug).get(Bug, 2)
91 >>> recipients = BugNotificationRecipients(duplicateof=bug_two)
92
93 >>> foo_bar = personset.getByEmail("foo.bar@canonical.com")
94diff --git a/lib/lp/bugs/doc/bugnotifications.rst b/lib/lp/bugs/doc/bugnotifications.rst
95index c7aaeb5..4b4d755 100644
96--- a/lib/lp/bugs/doc/bugnotifications.rst
97+++ b/lib/lp/bugs/doc/bugnotifications.rst
98@@ -354,7 +354,7 @@ this document:
99 ... status=CveStatus.ENTRY,
100 ... )
101 >>> from lp.bugs.model.bug import Bug
102- >>> bug = Bug.get(1)
103+ >>> bug = IStore(Bug).get(Bug, 1)
104 >>> bugcve = cve.linkBug(bug) # note this creates the event and notifies
105
106 >>> latest_notification = (
107diff --git a/lib/lp/bugs/doc/cve.rst b/lib/lp/bugs/doc/cve.rst
108index e06fe5f..86b2a3f 100644
109--- a/lib/lp/bugs/doc/cve.rst
110+++ b/lib/lp/bugs/doc/cve.rst
111@@ -75,7 +75,8 @@ You can link a CVE to a bug. You can also see which CVEs are currently
112 linked to a bug:
113
114 >>> from lp.bugs.model.bug import Bug
115- >>> b = Bug.get(1)
116+ >>> from lp.services.database.interfaces import IStore
117+ >>> b = IStore(Bug).get(Bug, 1)
118 >>> for c in b.cves:
119 ... print(c.displayname)
120 ...
121diff --git a/lib/lp/bugs/interfaces/bug.py b/lib/lp/bugs/interfaces/bug.py
122index e02f2ff..acf5c6e 100644
123--- a/lib/lp/bugs/interfaces/bug.py
124+++ b/lib/lp/bugs/interfaces/bug.py
125@@ -240,7 +240,7 @@ class IBugView(Interface):
126 max_length=50000,
127 )
128 )
129- ownerID = Int(title=_("Owner"), required=True, readonly=True)
130+ owner_id = Int(title=_("Owner"), required=True, readonly=True)
131 owner = exported(
132 Reference(IPerson, title=_("The owner's IPerson"), readonly=True)
133 )
134diff --git a/lib/lp/bugs/model/bug.py b/lib/lp/bugs/model/bug.py
135index dc2d66b..2db7afe 100644
136--- a/lib/lp/bugs/model/bug.py
137+++ b/lib/lp/bugs/model/bug.py
138@@ -33,6 +33,7 @@ from lazr.lifecycle.snapshot import Snapshot
139 from lazr.restful.declarations import error_status
140 from storm.expr import (
141 SQL,
142+ Add,
143 And,
144 Coalesce,
145 Desc,
146@@ -170,19 +171,10 @@ from lp.registry.model.pillar import pillar_sort_key
147 from lp.registry.model.teammembership import TeamParticipation
148 from lp.services.config import config
149 from lp.services.database import bulk
150-from lp.services.database.constants import UTC_NOW
151-from lp.services.database.datetimecol import UtcDateTimeCol
152+from lp.services.database.constants import DEFAULT, UTC_NOW
153 from lp.services.database.decoratedresultset import DecoratedResultSet
154 from lp.services.database.enumcol import DBEnum
155 from lp.services.database.interfaces import IStore
156-from lp.services.database.sqlbase import SQLBase, sqlvalues
157-from lp.services.database.sqlobject import (
158- ForeignKey,
159- IntCol,
160- SQLMultipleJoin,
161- SQLObjectNotFound,
162- StringCol,
163-)
164 from lp.services.database.stormbase import StormBase
165 from lp.services.database.stormexpr import WithMaterialized
166 from lp.services.fields import DuplicateBug
167@@ -261,7 +253,6 @@ class BugTag(StormBase):
168 __storm_table__ = "BugTag"
169 id = Int(primary=True)
170
171- bug = ForeignKey(dbName="bug", foreignKey="Bug", notNull=True)
172 bug_id = Int(name="bug", allow_none=False)
173 bug = Reference(bug_id, "Bug.id")
174
175@@ -356,33 +347,36 @@ def update_bug_heat(bug_ids):
176
177
178 @implementer(IBug, IInformationType)
179-class Bug(SQLBase, InformationTypeMixin):
180+class Bug(StormBase, InformationTypeMixin):
181 """A bug."""
182
183- _defaultOrder = "-id"
184+ __storm_table__ = "Bug"
185+ __storm_order__ = "-id"
186
187 # db field names
188- name = StringCol(unique=True, default=None)
189- title = StringCol(notNull=True)
190- description = StringCol(notNull=False, default=None)
191- owner = ForeignKey(
192- dbName="owner",
193- foreignKey="Person",
194- storm_validator=validate_public_person,
195- notNull=True,
196+ id = Int(primary=True)
197+ name = Unicode(default=None)
198+ title = Unicode(allow_none=False)
199+ description = Unicode(allow_none=True, default=None)
200+ owner_id = Int(
201+ name="owner", validator=validate_public_person, allow_none=False
202+ )
203+ owner = Reference(owner_id, "Person.id")
204+ duplicateof_id = Int(name="duplicateof", default=None)
205+ duplicateof = Reference(duplicateof_id, "Bug.id")
206+ datecreated = DateTime(
207+ allow_none=False, default=UTC_NOW, tzinfo=timezone.utc
208+ )
209+ date_last_updated = DateTime(
210+ allow_none=False, default=UTC_NOW, tzinfo=timezone.utc
211 )
212- duplicateof = ForeignKey(
213- dbName="duplicateof", foreignKey="Bug", default=None
214+ date_made_private = DateTime(
215+ allow_none=True, default=None, tzinfo=timezone.utc
216 )
217- datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW)
218- date_last_updated = UtcDateTimeCol(notNull=True, default=UTC_NOW)
219- date_made_private = UtcDateTimeCol(notNull=False, default=None)
220- who_made_private = ForeignKey(
221- dbName="who_made_private",
222- foreignKey="Person",
223- storm_validator=validate_public_person,
224- default=None,
225+ who_made_private_id = Int(
226+ name="who_made_private", validator=validate_public_person, default=None
227 )
228+ who_made_private = Reference(who_made_private_id, "Person.id")
229 information_type = DBEnum(
230 enum=InformationType, allow_none=False, default=InformationType.PUBLIC
231 )
232@@ -397,25 +391,44 @@ class Bug(SQLBase, InformationTypeMixin):
233 BugWatch.bug_id,
234 order_by=(BugWatch.bugtracker_id, BugWatch.remotebug),
235 )
236- duplicates = SQLMultipleJoin("Bug", joinColumn="duplicateof", orderBy="id")
237+ duplicates = ReferenceSet("id", "Bug.duplicateof_id", order_by="Bug.id")
238 linked_bugbranches = ReferenceSet(
239 "id", BugBranch.bug_id, order_by=BugBranch.id
240 )
241- date_last_message = UtcDateTimeCol(default=None)
242- number_of_duplicates = IntCol(notNull=True, default=0)
243- message_count = IntCol(notNull=True, default=0)
244- users_affected_count = IntCol(notNull=True, default=0)
245- users_unaffected_count = IntCol(notNull=True, default=0)
246- heat = IntCol(notNull=True, default=0)
247- heat_last_updated = UtcDateTimeCol(default=None)
248- latest_patch_uploaded = UtcDateTimeCol(default=None)
249+ date_last_message = DateTime(default=None, tzinfo=timezone.utc)
250+ number_of_duplicates = Int(allow_none=False, default=0)
251+ message_count = Int(allow_none=False, default=0)
252+ users_affected_count = Int(allow_none=False, default=0)
253+ users_unaffected_count = Int(allow_none=False, default=0)
254+ heat = Int(allow_none=False, default=0)
255+ heat_last_updated = DateTime(default=None, tzinfo=timezone.utc)
256+ latest_patch_uploaded = DateTime(default=None, tzinfo=timezone.utc)
257 lock_status = DBEnum(
258 name="lock_status",
259 enum=BugLockStatus,
260 allow_none=False,
261 default=BugLockStatus.UNLOCKED,
262 )
263- lock_reason = StringCol(notNull=False, default=None)
264+ lock_reason = Unicode(allow_none=True, default=None)
265+
266+ def __init__(
267+ self,
268+ title,
269+ owner,
270+ description=None,
271+ datecreated=DEFAULT,
272+ date_made_private=None,
273+ who_made_private=None,
274+ information_type=InformationType.PUBLIC,
275+ ):
276+ super().__init__()
277+ self.title = title
278+ self.owner = owner
279+ self.description = description
280+ self.datecreated = datecreated
281+ self.date_made_private = date_made_private
282+ self.who_made_private = who_made_private
283+ self.information_type = information_type
284
285 @property
286 def locked(self):
287@@ -1905,7 +1918,7 @@ class Bug(SQLBase, InformationTypeMixin):
288 def _question_from_bug(self):
289 for question in self.questions:
290 if (
291- question.owner_id == self.ownerID
292+ question.owner_id == self.owner_id
293 and question.datecreated == self.datecreated
294 ):
295 return question
296@@ -1934,10 +1947,12 @@ class Bug(SQLBase, InformationTypeMixin):
297 # range.
298 slices.append(
299 BugMessage.index
300- >= SQL(
301- "(select max(index) from "
302- "bugmessage where bug=%s) + 1 - %s"
303- % (sqlvalues(self.id, -slice.start))
304+ >= Add(
305+ Select(
306+ Max(BugMessage.index),
307+ where=(BugMessage.bug == self),
308+ ),
309+ slice.start + 1,
310 )
311 )
312 else:
313@@ -2397,7 +2412,7 @@ class Bug(SQLBase, InformationTypeMixin):
314 try:
315 if duplicate_of is not None:
316 field._validate(duplicate_of)
317- if self.duplicates:
318+ if not self.duplicates.is_empty():
319 user = getUtility(ILaunchBag).user
320 for duplicate in self.duplicates:
321 old_value = duplicate.duplicateof
322@@ -3204,17 +3219,17 @@ class BugSet:
323
324 def get(self, bugid):
325 """See `IBugSet`."""
326- try:
327- return Bug.get(bugid)
328- except SQLObjectNotFound:
329+ bug = IStore(Bug).get(Bug, int(bugid))
330+ if bug is None:
331 raise NotFoundError(
332 "Unable to locate bug with ID %s." % str(bugid)
333 )
334+ return bug
335
336 def getByNameOrID(self, bugid):
337 """See `IBugSet`."""
338 if self.valid_bug_name_re.match(bugid):
339- bug = Bug.selectOneBy(name=bugid)
340+ bug = IStore(Bug).find(Bug, name=bugid).one()
341 if bug is None:
342 raise NotFoundError("Unable to locate bug with ID %s." % bugid)
343 else:
344@@ -3334,6 +3349,8 @@ class BugSet:
345 if params.tags:
346 bug.tags = params.tags
347
348+ Store.of(bug).flush()
349+
350 # Link the bug to the message.
351 BugMessage(bug=bug, message=params.msg, index=0)
352
353@@ -3497,7 +3514,7 @@ def generate_subscription_with(bug, person):
354 BugSubscription,
355 Join(Bug, Bug.id == BugSubscription.bug_id),
356 ],
357- where=Or(Bug.id == bug.id, Bug.duplicateofID == bug.id),
358+ where=Or(Bug.id == bug.id, Bug.duplicateof_id == bug.id),
359 ),
360 ),
361 WithMaterialized(
362diff --git a/lib/lp/bugs/model/bugtask.py b/lib/lp/bugs/model/bugtask.py
363index 2a0dce7..2606bed 100644
364--- a/lib/lp/bugs/model/bugtask.py
365+++ b/lib/lp/bugs/model/bugtask.py
366@@ -1019,7 +1019,7 @@ class BugTask(StormBase):
367 return True
368 elif (
369 self.status == BugTaskStatus.FIXRELEASED
370- and user.id != self.bug.ownerID
371+ and user.id != self.bug.owner_id
372 and not user.inTeam(self.bug.owner)
373 ):
374 # The bug reporter can reopen a Fix Released bug.
375@@ -1606,7 +1606,7 @@ class BugTaskSet:
376
377 people_ids = set(
378 [bugtask.assignee_id for bugtask in bugtasks]
379- + [bugtask.bug.ownerID for bugtask in bugtasks]
380+ + [bugtask.bug.owner_id for bugtask in bugtasks]
381 )
382 people = getUtility(IPersonSet).getPrecachedPersonsFromIDs(people_ids)
383 return {person.id: person for person in people}
384diff --git a/lib/lp/bugs/model/bugtasksearch.py b/lib/lp/bugs/model/bugtasksearch.py
385index 9ec4c25..7f7dd20 100644
386--- a/lib/lp/bugs/model/bugtasksearch.py
387+++ b/lib/lp/bugs/model/bugtasksearch.py
388@@ -1105,7 +1105,7 @@ def _build_exclude_conjoined_clause(milestone):
389 """
390 # XXX: EdwinGrubbs 2010-12-15 bug=682989
391 # (ConjoinedPrimary.bug == X) produces the wrong sql, but
392- # (ConjoinedPrimary.bugID == X) works right. This bug applies to
393+ # (ConjoinedPrimary.bug_id == X) works right. This bug applies to
394 # all foreign keys on the ClassAlias.
395
396 # Perform a LEFT JOIN to the conjoined primary bugtask. If the
397diff --git a/lib/lp/bugs/model/personsubscriptioninfo.py b/lib/lp/bugs/model/personsubscriptioninfo.py
398index 8e28966..aaff8d4 100644
399--- a/lib/lp/bugs/model/personsubscriptioninfo.py
400+++ b/lib/lp/bugs/model/personsubscriptioninfo.py
401@@ -184,7 +184,7 @@ class PersonSubscriptions:
402 # Preload bug owners, then all pillars.
403 list(
404 getUtility(IPersonSet).getPrecachedPersonsFromIDs(
405- [bug.ownerID for bug in bugs]
406+ [bug.owner_id for bug in bugs]
407 )
408 )
409 all_tasks = load_referencing(BugTask, bugs, ["bug_id"])
410diff --git a/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst b/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst
411index bfa0b6e..116baaa 100644
412--- a/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst
413+++ b/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst
414@@ -9,14 +9,15 @@ To demonstrate this feature, we'll use bug 1.
415 We'll start by adding some attachments to the bug:
416
417 >>> from io import BytesIO
418- >>> from lp.services.database.sqlbase import flush_database_updates
419- >>> from lp.testing import login, logout
420 >>> from lp.bugs.model.bug import Bug
421 >>> from lp.registry.model.person import Person
422+ >>> from lp.services.database.interfaces import IStore
423+ >>> from lp.services.database.sqlbase import flush_database_updates
424+ >>> from lp.testing import login, logout
425 >>> login("foo.bar@canonical.com")
426 >>> mark = Person.selectOneBy(name="mark")
427 >>> mark.display_name = "M\xe1rk Sh\xfattlew\xf2rth"
428- >>> bug = Bug.get(1)
429+ >>> bug = IStore(Bug).get(Bug, 1)
430 >>> content = BytesIO(b"<html><body>bogus</body></html>")
431 >>> a1 = bug.addAttachment(
432 ... mark,
433diff --git a/lib/lp/bugs/templates/bug-portlet-duplicates.pt b/lib/lp/bugs/templates/bug-portlet-duplicates.pt
434index 0a11c96..a2f0afa 100644
435--- a/lib/lp/bugs/templates/bug-portlet-duplicates.pt
436+++ b/lib/lp/bugs/templates/bug-portlet-duplicates.pt
437@@ -3,7 +3,7 @@
438 xmlns:metal="http://xml.zope.org/namespaces/metal"
439 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
440 class="portlet" id="portlet-duplicates"
441- tal:condition="context/duplicates">
442+ tal:condition="not: context/duplicates/is_empty">
443 <h2>Duplicates of this bug</h2>
444 <ul>
445 <li tal:repeat="dupe view/duplicates">
446diff --git a/lib/lp/bugs/tests/bugs-emailinterface.rst b/lib/lp/bugs/tests/bugs-emailinterface.rst
447index 1a8a900..6555137 100644
448--- a/lib/lp/bugs/tests/bugs-emailinterface.rst
449+++ b/lib/lp/bugs/tests/bugs-emailinterface.rst
450@@ -2085,7 +2085,7 @@ An empty unsigned mail to new@malone:
451 If we submit an email with no affects command, it is rejected.
452
453 >>> from lp.bugs.model.bug import Bug
454- >>> before_count = Bug.select().count()
455+ >>> before_count = IStore(Bug).find(Bug).count()
456 >>> submit_mail = b"""From: Foo Bar <foo.bar@canonical.com>
457 ... To: new@bugs.launchpad.ubuntu.com
458 ... Date: Fri Jun 17 10:20:23 BST 2005
459@@ -2099,7 +2099,7 @@ If we submit an email with no affects command, it is rejected.
460 ... """
461
462 >>> process_email(submit_mail)
463- >>> before_count == Bug.select().count()
464+ >>> before_count == IStore(Bug).find(Bug).count()
465 True
466
467 >>> print_latest_email()
468@@ -2118,7 +2118,7 @@ required. If it is missing, the message is also rejected.
469 XXX: Gavin Panella 2009-07-24 bug=404010: The need for this test
470 arises from the implementation of MaloneHandler.
471
472- >>> before_count = Bug.select().count()
473+ >>> before_count = IStore(Bug).find(Bug).count()
474 >>> submit_mail = b"""From: Foo Bar <foo.bar@canonical.com>
475 ... To: new@bugs.launchpad.ubuntu.com
476 ... Date: Fri Jun 17 10:20:23 BST 2005
477@@ -2130,7 +2130,7 @@ arises from the implementation of MaloneHandler.
478 ... """
479
480 >>> process_email(submit_mail)
481- >>> before_count == Bug.select().count()
482+ >>> before_count == IStore(Bug).find(Bug).count()
483 True
484
485 >>> print_latest_email()
486@@ -2151,7 +2151,7 @@ edit@bugs).
487 XXX: Gavin Panella 2009-07-24 bug=404010: The need for this test
488 arises from the implementation of MaloneHandler.
489
490- >>> before_count = Bug.select().count()
491+ >>> before_count = IStore(Bug).find(Bug).count()
492 >>> submit_mail = b"""\
493 ... From: Foo Bar <foo.bar@canonical.com>
494 ... To: new@bugs.launchpad.ubuntu.com
495@@ -2162,7 +2162,7 @@ arises from the implementation of MaloneHandler.
496 ... """
497
498 >>> process_email(submit_mail)
499- >>> before_count == Bug.select().count()
500+ >>> before_count == IStore(Bug).find(Bug).count()
501 True
502
503 >>> print_latest_email()
504@@ -2184,7 +2184,7 @@ bug-related commands do blow up before the check for a bugtask is
505 reached. For example, unsubscribing oneself from a private bug then
506 linking a CVE.
507
508- >>> before_count = Bug.select().count()
509+ >>> before_count = IStore(Bug).find(Bug).count()
510 >>> submit_mail = b"""\
511 ... From: Foo Bar <foo.bar@canonical.com>
512 ... To: new@bugs.launchpad.ubuntu.com
513@@ -2197,7 +2197,7 @@ linking a CVE.
514 ... """
515
516 >>> process_email(submit_mail)
517- >>> before_count == Bug.select().count()
518+ >>> before_count == IStore(Bug).find(Bug).count()
519 True
520
521 >>> print_latest_email()
522diff --git a/lib/lp/bugs/vocabularies.py b/lib/lp/bugs/vocabularies.py
523index 9b337e0..5586ef3 100644
524--- a/lib/lp/bugs/vocabularies.py
525+++ b/lib/lp/bugs/vocabularies.py
526@@ -56,7 +56,6 @@ from lp.services.webapp.vocabulary import (
527 CountableIterator,
528 IHugeVocabulary,
529 NamedSQLObjectVocabulary,
530- SQLObjectVocabularyBase,
531 StormVocabularyBase,
532 )
533
534@@ -85,9 +84,9 @@ class UsesBugsDistributionVocabulary(DistributionVocabulary):
535 )
536
537
538-class BugVocabulary(SQLObjectVocabularyBase):
539+class BugVocabulary(StormVocabularyBase):
540 _table = Bug
541- _orderBy = "id"
542+ _order_by = "id"
543
544
545 @implementer(IHugeVocabulary)
546diff --git a/lib/lp/registry/tests/test_person.py b/lib/lp/registry/tests/test_person.py
547index e0f005c..3646ff7 100644
548--- a/lib/lp/registry/tests/test_person.py
549+++ b/lib/lp/registry/tests/test_person.py
550@@ -1016,7 +1016,7 @@ class TestPersonStates(TestCaseWithFactory):
551 )
552
553 def test_Bug_person_validator(self):
554- bug = Bug.select(limit=1)[0]
555+ bug = IStore(Bug).find(Bug).first()
556 for attr_name in ["owner", "who_made_private"]:
557 self.assertRaises(
558 PrivatePersonLinkageError, setattr, bug, attr_name, self.myteam
559diff --git a/lib/lp/scripts/harness.py b/lib/lp/scripts/harness.py
560index 7be9884..a5a03ec 100644
561--- a/lib/lp/scripts/harness.py
562+++ b/lib/lp/scripts/harness.py
563@@ -77,8 +77,8 @@ def _get_locals():
564 ds = DistroSeries.get(1)
565 prod = Product.get(1)
566 proj = ProjectGroup.get(1)
567- b2 = Bug.get(2)
568- b1 = Bug.get(1)
569+ b2 = store.get(Bug, 2)
570+ b1 = store.get(Bug, 1)
571 s = store.get(Specification, 1)
572 q = store.get(Question, 1)
573 # Silence unused name warnings
574diff --git a/lib/lp/services/database/tests/test_bulk.py b/lib/lp/services/database/tests/test_bulk.py
575index 6cdf569..b9f64c8 100644
576--- a/lib/lp/services/database/tests/test_bulk.py
577+++ b/lib/lp/services/database/tests/test_bulk.py
578@@ -252,7 +252,7 @@ class TestLoaders(TestCaseWithFactory):
579 expected = {bug.owner for bug in owning_objects}
580 self.assertEqual(
581 expected,
582- set(bulk.load_related(Person, owning_objects, ["ownerID"])),
583+ set(bulk.load_related(Person, owning_objects, ["owner_id"])),
584 )
585
586 def test_load_referencing(self):
587diff --git a/lib/lp/services/statistics/model/statistics.py b/lib/lp/services/statistics/model/statistics.py
588index 4b4ff60..f0a182e 100644
589--- a/lib/lp/services/statistics/model/statistics.py
590+++ b/lib/lp/services/statistics/model/statistics.py
591@@ -106,10 +106,10 @@ class LaunchpadStatisticSet:
592 getUtility(IPersonSet).updateStatistics()
593
594 def _updateMaloneStatistics(self, ztm):
595- self.update("bug_count", Bug.select().count())
596+ store = IStore(Bug)
597+ self.update("bug_count", store.find(Bug).count())
598 ztm.commit()
599
600- store = IStore(BugTask)
601 self.update("bugtask_count", store.find(BugTask).count())
602 ztm.commit()
603

Subscribers

People subscribed via source and target branches

to status/vote changes: