7
6
place. Where a bug has things like a title, comments and subscribers,
8
7
it's the bug task that tracks importance, assignee, etc.
10
Working with Bug Tasks in Launchpad
11
===================================
9
= Working with Bug Tasks in Launchpad =
12
== Creating Bug Tasks ==
17
14
All BugTask creation and retrieval is done through an IBugTaskSet utility.
91
88
# the connection after a ProgrammingError is raised. ARGH.
91
== Bug Task Targets ==
97
>>> from lp.registry.interfaces.distributionsourcepackage \
98
... import IDistributionSourcePackage
93
>>> from lp.registry.interfaces.distributionsourcepackage import IDistributionSourcePackage
94
>>> from lp.registry.model.distributionsourcepackage import DistributionSourcePackage
100
96
The "target" of an IBugTask can be one of the items in the following
129
125
* a distribution sourcepackage
131
127
>>> def get_expected_target(distro_sp_task):
128
... expected_target = DistributionSourcePackage(
129
... distro_sp_task.distribution,
130
... distro_sp_task.sourcepackagename)
132
131
... return distro_sp_task.target
134
133
>>> debian_ff_task = bugtaskset.get(4)
135
134
>>> IDistributionSourcePackage.providedBy(debian_ff_task.target)
164
163
Each task has a "bugtargetdisplayname" and a "bugtargetname", strings
165
describing the site of the task. They concatenate the names of the
164
describing the site of the task. They concatenate the names of the distribution,
168
166
>>> bugtask = bugtaskset.get(17)
169
167
>>> bugtask.bugtargetdisplayname
212
== Editing Bug Tasks ==
218
214
When changing status we must pass the user making the change. Some
219
215
statuses are restricted to Bug Supervisors only.
218
=== Upstream Bug Tasks ===
225
220
To edit an upstream task, you must be logged in. Anonymous users
226
221
cannot edit upstream tasks.
239
234
... STATUS_FIXRELEASED, getUtility(ILaunchBag).user)
242
Distro and Distro Series Bug Tasks
243
..................................
237
=== Distro and Distro Series Bug Tasks ===
245
239
Any logged-in user can edit tasks filed on distros as long as the bug
246
240
is not marked private. So, as an anonymous user, we cannot edit
270
264
>>> distro_series_task.transitionToAssignee(sample_person)
267
=== Conjoined Bug Tasks ===
276
269
A bugtask open on the current development series for a distro is kept
277
270
in sync with the "generic" bugtask for that distro, because they
278
271
represent the same piece of work. The same is true for product and
279
272
productseries tasks, when the productseries task is targeted to the
280
IProduct.developmentfocus. The following attributes are synced:
273
IProduct.developmentfocus. The following attributes are synched:
570
563
Traceback (most recent call last):
572
565
UserCannotEditBugTaskImportance:
573
User does not have sufficient permissions to edit the
566
User does not have sufficient permissions to edit the bug task importance.
576
568
>>> print generic_netapplet_task.importance.title
602
594
Traceback (most recent call last):
604
596
UserCannotEditBugTaskMilestone:
605
User does not have sufficient permissions to edit the bug
597
User does not have sufficient permissions to edit the bug task milestone.
608
599
>>> print devel_focus_alsa_utils_task.milestone.name
700
A bug is either private or public. Private bugs are only visible
701
(e.g. in search listings) to explicit subscribers and Launchpad
702
admins. Public bugs are visible to anyone.
690
A bug is either private or public. Private bugs are only visible (e.g. in search
691
listings) to explicit subscribers and Launchpad admins. Public bugs are visible
704
694
>>> from zope.event import notify
705
695
>>> from lazr.lifecycle.event import ObjectModifiedEvent
708
Privacy and Unprivileged Users
709
------------------------------
698
== Privacy and Unprivileged Users ==
711
700
Let's log in as the user Foo Bar (to be allowed to edit bugs):
740
729
>>> from canonical.database.sqlbase import flush_database_updates
741
730
>>> flush_database_updates()
743
If we now login as someone who was neither implicitly nor explicitly
744
subscribed to this bug, e.g. No Privileges Person, they will not be
745
able to access or set properties of the bugtask.
732
If we now login as someone who was neither implicitly nor explicitly subscribed
733
to this bug, e.g. No Privileges Person, they will not be able to access or set
734
properties of the bugtask.
747
736
>>> login("no-priv@canonical.com")
748
737
>>> mr_no_privs = launchbag.user
786
Open bugtask count for a given list of projects
787
-----------------------------------------------
775
== Open bugtask count for a given list of projects ==
789
777
IBugTaskSet.getOpenBugTasksPerProduct() will return a dictionary
790
778
of product_id:count entries for bugs in an open status that
822
810
product_id=20 count=3
825
Privacy and Priviledged Users
826
-----------------------------
813
== Privacy and Priviledged Users ==
828
815
Now, we'll log in as Mark Shuttleworth, who was assigned to this bug
829
816
when it was marked private:
839
826
... BugTaskStatus.NEW, getUtility(ILaunchBag).user)
842
Privacy and Team Awareness
843
--------------------------
829
== Privacy and Team Awareness ==
845
831
No Privileges Person can't see the private bug, because he's not a subscriber:
855
But if we add No Privileges Person to the Ubuntu Team, and because the
856
Ubuntu Team *is* subscribed to the bug, No Privileges Person will see
841
But if we add No Privileges Person to the Ubuntu Team, and because the Ubuntu
842
Team *is* subscribed to the bug, No Privileges Person will see the private bug.
859
844
>>> login("mark@example.com")
860
845
>>> ignored = ubuntu_team.addMember(
935
== BugTask Adaptation ==
955
937
An IBugTask can be adapted to an IBug.
957
>>> from lp.bugs.interfaces.bug import IBug
959
>>> bugtask_four = bugtaskset.get(4)
960
>>> bug = IBug(bugtask_four)
962
u'Firefox does not support SVG'
965
The targetnamecache attribute of BugTask
966
----------------------------------------
968
The BugTask table has this targetnamecache attribute which stores a
969
computed value to allow us to sort and search on that value without
970
having to do lots of SQL joins. This cached value gets updated daily
971
by the update-bugtask-targetnamecaches cronscript and whenever the
972
bugtask is changed. Of course, it's also computed and set when a
939
>>> from lp.bugs.interfaces.bug import IBug
941
>>> bugtask_four = bugtaskset.get(4)
942
>>> bug = IBug(bugtask_four)
944
u'Firefox does not support SVG'
947
== The targetnamecache attribute of BugTask ==
949
The BugTask table has this targetnamecache attribute which stores a computed
950
value to allow us to sort and search on that value without having to do lots
951
of SQL joins. This cached value gets updated daily by the
952
update-bugtask-targetnamecaches cronscript and whenever the bugtask is changed.
953
Of course, it's also computed and set when a bugtask is created.
975
955
`BugTask.bugtargetdisplayname` simply returns `targetnamecache`, and
976
956
the latter is not exposed in `IBugTask`, so the `bugtargetdisplayname`
1008
988
>>> (out, err) = process.communicate()
1011
INFO Creating lockfile:
1012
/var/lock/launchpad-launchpad-targetnamecacheupdater.lock
991
INFO Creating lockfile: /var/lock/launchpad-launchpad-targetnamecacheupdater.lock
1013
992
INFO Updating targetname cache of bugtasks.
1014
993
INFO Calculating targets.
1015
994
INFO Will check ... targets.