Merge lp:~stevenk/launchpad/branch-privacy-properties into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 15414
Proposed branch: lp:~stevenk/launchpad/branch-privacy-properties
Merge into: lp:launchpad
Diff against target: 69 lines (+16/-7)
2 files modified
lib/lp/code/model/branch.py (+15/-6)
lib/lp/code/model/branchnamespace.py (+1/-1)
To merge this branch: bzr merge lp:~stevenk/launchpad/branch-privacy-properties
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+109987@code.launchpad.net

Commit message

As the first step to weaning our code off Branch.private and Branch.transitively_private, shift them to be properties.

Description of the change

As the first step to weaning our code off Branch.private and Branch.transitively_private, shift them to be properties, and leave the columns protected by underscores.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Both the new properties can just return self.private, but otherwise fine.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/branch.py'
2--- lib/lp/code/model/branch.py 2012-06-06 23:34:24 +0000
3+++ lib/lp/code/model/branch.py 2012-06-14 00:00:28 +0000
4@@ -187,15 +187,24 @@
5
6 # This attribute signifies whether *this* branch is private, irrespective
7 # of the state of any stacked on branches.
8- explicitly_private = BoolCol(
9+ _explicitly_private = BoolCol(
10 default=False, notNull=True, dbName='private')
11 # A branch is transitively private if it is private or it is stacked on a
12 # transitively private branch. The value of this attribute is maintained
13 # by a database trigger.
14- transitively_private = BoolCol(dbName='transitively_private')
15+ _transitively_private = BoolCol(dbName='transitively_private')
16 information_type = EnumCol(
17 enum=InformationType, default=InformationType.PUBLIC)
18
19+ # These can die after the UI is dropped.
20+ @property
21+ def explicitly_private(self):
22+ return self.private
23+
24+ @property
25+ def transitively_private(self):
26+ return self.private
27+
28 @property
29 def private(self):
30 return self.information_type in PRIVATE_INFORMATION_TYPES
31@@ -242,13 +251,13 @@
32 self.information_type = information_type
33 self._reconcileAccess()
34 # Set the legacy values for now.
35- self.explicitly_private = private
36+ self._explicitly_private = private
37 # If this branch is private, then it is also transitively_private
38 # otherwise we need to reload the value.
39 if private:
40- self.transitively_private = True
41+ self._transitively_private = True
42 else:
43- self.transitively_private = AutoReload
44+ self._transitively_private = AutoReload
45
46 registrant = ForeignKey(
47 dbName='registrant', foreignKey='Person',
48@@ -1511,7 +1520,7 @@
49 naked_branch.unique_name = AutoReload
50 naked_branch.owner_name = AutoReload
51 naked_branch.target_suffix = AutoReload
52- naked_branch.transitively_private = AutoReload
53+ naked_branch._transitively_private = AutoReload
54
55
56 def branch_modified_subscriber(branch, event):
57
58=== modified file 'lib/lp/code/model/branchnamespace.py'
59--- lib/lp/code/model/branchnamespace.py 2012-06-04 09:41:48 +0000
60+++ lib/lp/code/model/branchnamespace.py 2012-06-14 00:00:28 +0000
61@@ -118,7 +118,7 @@
62 registrant=registrant,
63 name=name, owner=self.owner, product=product, url=url,
64 title=title, lifecycle_status=lifecycle_status, summary=summary,
65- whiteboard=whiteboard, explicitly_private=private,
66+ whiteboard=whiteboard, _explicitly_private=private,
67 information_type=information_type, date_created=date_created,
68 branch_type=branch_type, date_last_modified=date_created,
69 branch_format=branch_format, repository_format=repository_format,