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
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2012-06-06 23:34:24 +0000
+++ lib/lp/code/model/branch.py 2012-06-14 00:00:28 +0000
@@ -187,15 +187,24 @@
187187
188 # This attribute signifies whether *this* branch is private, irrespective188 # This attribute signifies whether *this* branch is private, irrespective
189 # of the state of any stacked on branches.189 # of the state of any stacked on branches.
190 explicitly_private = BoolCol(190 _explicitly_private = BoolCol(
191 default=False, notNull=True, dbName='private')191 default=False, notNull=True, dbName='private')
192 # A branch is transitively private if it is private or it is stacked on a192 # A branch is transitively private if it is private or it is stacked on a
193 # transitively private branch. The value of this attribute is maintained193 # transitively private branch. The value of this attribute is maintained
194 # by a database trigger.194 # by a database trigger.
195 transitively_private = BoolCol(dbName='transitively_private')195 _transitively_private = BoolCol(dbName='transitively_private')
196 information_type = EnumCol(196 information_type = EnumCol(
197 enum=InformationType, default=InformationType.PUBLIC)197 enum=InformationType, default=InformationType.PUBLIC)
198198
199 # These can die after the UI is dropped.
200 @property
201 def explicitly_private(self):
202 return self.private
203
204 @property
205 def transitively_private(self):
206 return self.private
207
199 @property208 @property
200 def private(self):209 def private(self):
201 return self.information_type in PRIVATE_INFORMATION_TYPES210 return self.information_type in PRIVATE_INFORMATION_TYPES
@@ -242,13 +251,13 @@
242 self.information_type = information_type251 self.information_type = information_type
243 self._reconcileAccess()252 self._reconcileAccess()
244 # Set the legacy values for now.253 # Set the legacy values for now.
245 self.explicitly_private = private254 self._explicitly_private = private
246 # If this branch is private, then it is also transitively_private255 # If this branch is private, then it is also transitively_private
247 # otherwise we need to reload the value.256 # otherwise we need to reload the value.
248 if private:257 if private:
249 self.transitively_private = True258 self._transitively_private = True
250 else:259 else:
251 self.transitively_private = AutoReload260 self._transitively_private = AutoReload
252261
253 registrant = ForeignKey(262 registrant = ForeignKey(
254 dbName='registrant', foreignKey='Person',263 dbName='registrant', foreignKey='Person',
@@ -1511,7 +1520,7 @@
1511 naked_branch.unique_name = AutoReload1520 naked_branch.unique_name = AutoReload
1512 naked_branch.owner_name = AutoReload1521 naked_branch.owner_name = AutoReload
1513 naked_branch.target_suffix = AutoReload1522 naked_branch.target_suffix = AutoReload
1514 naked_branch.transitively_private = AutoReload1523 naked_branch._transitively_private = AutoReload
15151524
15161525
1517def branch_modified_subscriber(branch, event):1526def branch_modified_subscriber(branch, event):
15181527
=== modified file 'lib/lp/code/model/branchnamespace.py'
--- lib/lp/code/model/branchnamespace.py 2012-06-04 09:41:48 +0000
+++ lib/lp/code/model/branchnamespace.py 2012-06-14 00:00:28 +0000
@@ -118,7 +118,7 @@
118 registrant=registrant,118 registrant=registrant,
119 name=name, owner=self.owner, product=product, url=url,119 name=name, owner=self.owner, product=product, url=url,
120 title=title, lifecycle_status=lifecycle_status, summary=summary,120 title=title, lifecycle_status=lifecycle_status, summary=summary,
121 whiteboard=whiteboard, explicitly_private=private,121 whiteboard=whiteboard, _explicitly_private=private,
122 information_type=information_type, date_created=date_created,122 information_type=information_type, date_created=date_created,
123 branch_type=branch_type, date_last_modified=date_created,123 branch_type=branch_type, date_last_modified=date_created,
124 branch_format=branch_format, repository_format=repository_format,124 branch_format=branch_format, repository_format=repository_format,