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
=== removed file 'lib/canonical/buildd/utils.py'
--- lib/canonical/buildd/utils.py 2009-06-25 05:30:52 +0000
+++ lib/canonical/buildd/utils.py 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4# Author: Daniel Silverstone <daniel.silverstone@canonical.com>
5
6"""Utility functions for the buildd master."""
7
8# For more information on how to use this module, see
9# lib/canonical/launchpad/doc/buildd-dbnotes.txt
10
11# XXX dsilvers 2005-07-01: Can we replace all uses of notes with
12# foo.non_db_attribute = 'bar' and perhaps also with properties on the
13# instances which DTRT?
14
15__metaclass__ = type
16
17__all__ = ['notes']
18
19class DBNote2:
20 """Dictionary-style class which autovivifys real dicts based on
21 ids used to index it."""
22
23 def __init__(self):
24 self.notes = {}
25
26 def __getitem__(self, id):
27 self.notes.setdefault(id,{})
28 return self.notes[id]
29
30
31
32class DBNote:
33 """Dictionary-style class which takes in SQLObject instances or class
34 names and returns dicts or DBNote2 class instances as appropriate.
35
36 This class is designed to allow arbitrary annotations of SQLObjects
37 without worrying about the fact that across transactions they might change
38 their instance locations and thusly not be the same for keying in a dict.
39 """
40
41 def __init__(self):
42 self.notes = {}
43
44 def __getitem__(self, idx):
45 if isinstance(idx, type):
46 # It's a type, so it's an SQLObject class, so we return the DBNote2
47 return self.notes.setdefault(idx, DBNote2())
48 # It's not a type, so it's an SQLObject instance, we delve into the
49 # DBNote2 and return the dict
50 return self.notes.setdefault(type(idx), DBNote2())[idx.id]
51
52# Import this in order to share the annotations around.
53notes = DBNote()
540
=== modified file 'lib/lp/buildmaster/manager.py'
--- lib/lp/buildmaster/manager.py 2010-03-19 10:43:51 +0000
+++ lib/lp/buildmaster/manager.py 2010-04-03 04:26:17 +0000
@@ -26,7 +26,6 @@
2626
27from zope.component import getUtility27from zope.component import getUtility
2828
29from canonical.buildd.utils import notes
30from canonical.config import config29from canonical.config import config
31from canonical.launchpad.webapp import urlappend30from canonical.launchpad.webapp import urlappend
32from canonical.librarian.db import write_transaction31from canonical.librarian.db import write_transaction
@@ -238,9 +237,6 @@
238 """Service entry point, run at the start of a scan/dispatch cycle."""237 """Service entry point, run at the start of a scan/dispatch cycle."""
239 self.logger.info('Starting scanning cycle.')238 self.logger.info('Starting scanning cycle.')
240239
241 # Ensure there are no previous annotation from the previous cycle.
242 notes.notes = {}
243
244 d = defer.maybeDeferred(self.scan)240 d = defer.maybeDeferred(self.scan)
245 d.addCallback(self.resumeAndDispatch)241 d.addCallback(self.resumeAndDispatch)
246 d.addErrback(self.scanFailed)242 d.addErrback(self.scanFailed)
247243
=== removed file 'lib/lp/soyuz/doc/buildd-dbnotes.txt'
--- lib/lp/soyuz/doc/buildd-dbnotes.txt 2009-07-23 17:49:31 +0000
+++ lib/lp/soyuz/doc/buildd-dbnotes.txt 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1Buildd Master Database Notes
2============================
3
4The DBNote class in canonical.buildd.utils is a very simple class
5which when combined with SQLObject instances can provide a powerful
6annotation semantic for remembering things outside of the database for
7the duration of the program's execution.
8
9First you have to have some SQLObject instances or classes to use.
10For now we do this by importing the database classes directly. When
11the buildd is upgraded to use getUtility, we'll simultaneously upgrade
12this test to use it too.
13
14 >>> from lp.registry.model.person import Person
15 >>> from lp.registry.model.distribution import Distribution
16 >>> person1 = Person.get(1)
17 >>> distro1 = Distribution.get(1)
18
19Next we get hold of the standard DBNote instance
20
21 >>> from canonical.buildd.utils import notes
22
23Finally we record some annotations and check them
24
25 >>> notes[person1]["thing"] = "person"
26 >>> notes[distro1]["thing"] = "distro"
27 >>> notes[person1]["thing"]
28 'person'
29 >>> notes[distro1]["thing"]
30 'distro'
31 >>> notes[Person][1] is notes[person1]
32 True
33 >>> notes[Distribution][1] is notes[person1]
34 False
35