Merge lp:~wgrant/launchpad/remove-dbnote into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~wgrant/launchpad/remove-dbnote
Merge into: lp:launchpad
Prerequisite: lp:~wgrant/launchpad/amputate-buildergroup
Diff against target: 119 lines (+0/-92)
3 files modified
lib/canonical/buildd/utils.py (+0/-53)
lib/lp/buildmaster/manager.py (+0/-4)
lib/lp/soyuz/doc/buildd-dbnotes.txt (+0/-35)
To merge this branch: bzr merge lp:~wgrant/launchpad/remove-dbnote
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Brad Crittenden (community) Needs Information
Review via email: mp+22736@code.launchpad.net

Commit message

Remove unused DBNote and related paraphernalia.

Description of the change

This branch removes canonical.buildd.utils and associated cruft. It contained only the DBNote abomination, which was used only by the DAS-and-crack-driven buildd-manager approach, which was replaced in the prereq branch.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the branch William. It makes sense to me but before I can approve it I need to verify that you discussed this with Julian or another Soyuz-er.

As an aside, you may want to install Aaron's plugin for 'bzr lpsend' (lp:lpreview-body) since it creates a template for merge proposals and includes the output of 'make lint' for you. Having the template to fill out makes it less likely that you'll forget to mention some of the required information.

Again, thanks for the work. Have a quick chat with Soyuz and then I'll be happy to land this.

review: Needs Information
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Yay for getting rid of DBNote!

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'lib/canonical/buildd/utils.py'
2--- lib/canonical/buildd/utils.py 2009-06-25 05:30:52 +0000
3+++ lib/canonical/buildd/utils.py 1970-01-01 00:00:00 +0000
4@@ -1,53 +0,0 @@
5-# Copyright 2009 Canonical Ltd. This software is licensed under the
6-# GNU Affero General Public License version 3 (see the file LICENSE).
7-
8-# Author: Daniel Silverstone <daniel.silverstone@canonical.com>
9-
10-"""Utility functions for the buildd master."""
11-
12-# For more information on how to use this module, see
13-# lib/canonical/launchpad/doc/buildd-dbnotes.txt
14-
15-# XXX dsilvers 2005-07-01: Can we replace all uses of notes with
16-# foo.non_db_attribute = 'bar' and perhaps also with properties on the
17-# instances which DTRT?
18-
19-__metaclass__ = type
20-
21-__all__ = ['notes']
22-
23-class DBNote2:
24- """Dictionary-style class which autovivifys real dicts based on
25- ids used to index it."""
26-
27- def __init__(self):
28- self.notes = {}
29-
30- def __getitem__(self, id):
31- self.notes.setdefault(id,{})
32- return self.notes[id]
33-
34-
35-
36-class DBNote:
37- """Dictionary-style class which takes in SQLObject instances or class
38- names and returns dicts or DBNote2 class instances as appropriate.
39-
40- This class is designed to allow arbitrary annotations of SQLObjects
41- without worrying about the fact that across transactions they might change
42- their instance locations and thusly not be the same for keying in a dict.
43- """
44-
45- def __init__(self):
46- self.notes = {}
47-
48- def __getitem__(self, idx):
49- if isinstance(idx, type):
50- # It's a type, so it's an SQLObject class, so we return the DBNote2
51- return self.notes.setdefault(idx, DBNote2())
52- # It's not a type, so it's an SQLObject instance, we delve into the
53- # DBNote2 and return the dict
54- return self.notes.setdefault(type(idx), DBNote2())[idx.id]
55-
56-# Import this in order to share the annotations around.
57-notes = DBNote()
58
59=== modified file 'lib/lp/buildmaster/manager.py'
60--- lib/lp/buildmaster/manager.py 2010-03-19 10:43:51 +0000
61+++ lib/lp/buildmaster/manager.py 2010-04-03 04:26:17 +0000
62@@ -26,7 +26,6 @@
63
64 from zope.component import getUtility
65
66-from canonical.buildd.utils import notes
67 from canonical.config import config
68 from canonical.launchpad.webapp import urlappend
69 from canonical.librarian.db import write_transaction
70@@ -238,9 +237,6 @@
71 """Service entry point, run at the start of a scan/dispatch cycle."""
72 self.logger.info('Starting scanning cycle.')
73
74- # Ensure there are no previous annotation from the previous cycle.
75- notes.notes = {}
76-
77 d = defer.maybeDeferred(self.scan)
78 d.addCallback(self.resumeAndDispatch)
79 d.addErrback(self.scanFailed)
80
81=== removed file 'lib/lp/soyuz/doc/buildd-dbnotes.txt'
82--- lib/lp/soyuz/doc/buildd-dbnotes.txt 2009-07-23 17:49:31 +0000
83+++ lib/lp/soyuz/doc/buildd-dbnotes.txt 1970-01-01 00:00:00 +0000
84@@ -1,35 +0,0 @@
85-Buildd Master Database Notes
86-============================
87-
88-The DBNote class in canonical.buildd.utils is a very simple class
89-which when combined with SQLObject instances can provide a powerful
90-annotation semantic for remembering things outside of the database for
91-the duration of the program's execution.
92-
93-First you have to have some SQLObject instances or classes to use.
94-For now we do this by importing the database classes directly. When
95-the buildd is upgraded to use getUtility, we'll simultaneously upgrade
96-this test to use it too.
97-
98- >>> from lp.registry.model.person import Person
99- >>> from lp.registry.model.distribution import Distribution
100- >>> person1 = Person.get(1)
101- >>> distro1 = Distribution.get(1)
102-
103-Next we get hold of the standard DBNote instance
104-
105- >>> from canonical.buildd.utils import notes
106-
107-Finally we record some annotations and check them
108-
109- >>> notes[person1]["thing"] = "person"
110- >>> notes[distro1]["thing"] = "distro"
111- >>> notes[person1]["thing"]
112- 'person'
113- >>> notes[distro1]["thing"]
114- 'distro'
115- >>> notes[Person][1] is notes[person1]
116- True
117- >>> notes[Distribution][1] is notes[person1]
118- False
119-