1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
= Bug Reporting Guidelines =
Guidelines can be set at the Distribution, DistributionSourcePackage,
ProjectGroup or Product level to help users file good bug reports, direct
them to FAQs, and so forth.
>>> login('foo.bar@canonical.com')
>>> from lp.registry.interfaces.distribution import IDistributionSet
>>> from lp.registry.interfaces.product import IProductSet
>>> from lp.registry.interfaces.projectgroup import IProjectGroupSet
>>> distribution = getUtility(IDistributionSet).getByName('ubuntu')
>>> distribution_source_package = (
... distribution.getSourcePackage('alsa-utils'))
>>> project = getUtility(IProjectGroupSet).getByName('mozilla')
>>> product = getUtility(IProductSet).getByName('firefox')
>>> settable_contexts = [
... distribution,
... distribution_source_package,
... project,
... product,
... ]
>>> for context in settable_contexts:
... context.bug_reporting_guidelines = (
... "Welcome to %s!" % context.displayname)
In fact, all IBugTargets have guidelines available, but the others
delegate to the distribution or product level.
DistroSeries and SourcePackages defer to the Distribution:
>>> distro_series = distribution.getSeries('warty')
>>> print distro_series.bug_reporting_guidelines
Welcome to Ubuntu!
>>> source_package = distro_series.getSourcePackage('alsa-utils')
>>> print source_package.bug_reporting_guidelines
Welcome to Ubuntu!
ProductSeries defer to the Product:
>>> product_series = product.getSeries('trunk')
>>> print product_series.bug_reporting_guidelines
Welcome to Mozilla Firefox!
One day these objects that defer bug_reporting_guidelines may have
their own guidelines. In the meantime the deferral is done with a
read-only property, and the security proxies also only allow read
access.
>>> distro_series.bug_reporting_guidelines = 'Foobar'
Traceback (most recent call last):
...
ForbiddenAttribute: ...
>>> source_package.bug_reporting_guidelines = 'Foobar'
Traceback (most recent call last):
...
ForbiddenAttribute: ...
>>> product_series.bug_reporting_guidelines = 'Foobar'
Traceback (most recent call last):
...
ForbiddenAttribute: ...
The security proxies also prevent unprivileged users from editing the
guidelines.
>>> from lp.registry.interfaces.person import IPerson
>>> def check_access(user, context):
... if IPerson.providedBy(user):
... login_person(user)
... else:
... login(user)
... context.bug_reporting_guidelines = (
... "%s let %s have access." % (
... context.displayname,
... getUtility(ILaunchBag).user.displayname))
... print context.bug_reporting_guidelines
>>> check_access("no-priv@canonical.com", distribution)
Traceback (most recent call last):
...
Unauthorized: ...
>>> check_access("no-priv@canonical.com", distribution_source_package)
Traceback (most recent call last):
...
Unauthorized: ...
>>> check_access("no-priv@canonical.com", project)
Traceback (most recent call last):
...
Unauthorized: ...
>>> check_access("no-priv@canonical.com", product)
Traceback (most recent call last):
...
Unauthorized: ...
Of course the owner can edit the guidelines.
>>> check_access(distribution.owner.activemembers[0], distribution)
Ubuntu let Alexander Limi have access.
>>> check_access(project.owner, project)
The Mozilla Project let Sample Person have access.
>>> check_access(product.owner, product)
Mozilla Firefox let Sample Person have access.
In the case of DistributionSourcePackages, the owner of the
Distribution can edit the guidelines.
>>> check_access(
... distribution_source_package.distribution.owner.activemembers[0],
... distribution_source_package)
alsa-utils in Ubuntu let Alexander Limi have access.
|