Source

bugs.python.org / schema.py

erik.forsberg ae1df84 









stefan.seefeld 2a440e2 





erik.forsberg ae1df84 
stefan.seefeld 278d178 



martin.v.loewis e5e6ab6 
martin.v.loewis 2f31016 

stefan.seefeld 278d178 















stefan.seefeld a85d5ef 




erik.forsberg 6e86993 
stefan.seefeld a85d5ef 
martin.v.loewis a129c72 






stefan.seefeld 278d178 





erik.forsberg ae1df84 
erik.forsberg ad954ff 


stefan.seefeld 57b8395 
erik.forsberg ad954ff 


erik.forsberg 9934b1d 





erik.forsberg ae1df84 

stefan.seefeld 278d178 



erik.forsberg ae1df84 



stefan.seefeld 278d178 








martin.v.loewis f3010cb 

martin.v.loewis a2aca9c 

martin.v.loewis 9b8e6be 
martin.v.loewis 3769850 
martin.v.loewis a2aca9c 
erik.forsberg ae1df84 
martin.v.loewis 78074cf 

erik.forsberg ae1df84 
martin.v.loewis f9e0829 







martin.v.loewis a2aca9c 





martin.v.loewis 9eb7cd7 
martin.v.loewis a2aca9c 





erik.forsberg ae1df84 









erik.forsberg 0e945e8 


erik.forsberg ae1df84 

martin.v.loewis d4293db 









erik.forsberg ae1df84 
martin.v.loewis 59532d2 
martin.v.loewis 6cfbfac 



martin.v.loewis 59532d2 
erik.forsberg ae1df84 




stefan.seefeld 2a440e2 





stefan.seefeld a85d5ef 
stefan.seefeld 2a440e2 



erik.forsberg 9934b1d 
martin.v.loewis a129c72 
martin.v.loewis 2c07b69 

martin.v.loewis 59532d2 

erik.forsberg ae1df84 






stefan.seefeld 278d178 


erik.forsberg 1869766 

erik.forsberg 520b5a7 
erik.forsberg ae1df84 



stefan.seefeld 278d178 


erik.forsberg ae1df84 
stefan.seefeld 278d178 


erik.forsberg 0e945e8 
stefan.seefeld b2b7855 
martin.v.loewis a129c72 
martin.v.loewis 59532d2 
erik.forsberg ae1df84 
erik.forsberg 246436a 
stefan.seefeld 278d178 
martin.v.loewis 6cfbfac 

martin.v.loewis 59532d2 
martin.v.loewis 6cfbfac 
martin.v.loewis b620c7b 
martin.v.loewis 59532d2 

erik.forsberg 0e945e8 









martin.v.loewis bb1161d 
erik.forsberg 0e945e8 


erik.forsberg 520b5a7 
erik.forsberg 0e945e8 




erik.forsberg 520b5a7 
erik.forsberg 0e945e8 






erik.forsberg 02e273d 
erik.forsberg 0e945e8 


erik.forsberg 520b5a7 






Ezio Melotti 5872f58 


erik.forsberg 0e945e8 
erik.forsberg 520b5a7 
erik.forsberg 0e945e8 

erik.forsberg 520b5a7 
erik.forsberg 0e945e8 

martin.v.loewis da49dbd 




erik.forsberg 0e945e8 
stefan.seefeld 2a440e2 
stefan.seefeld 278d178 
stefan.seefeld b2b7855 
stefan.seefeld 278d178 
ezio.melotti 581841c 
stefan.seefeld 2a440e2 
stefan.seefeld 278d178 

stefan.seefeld 2a440e2 
stefan.seefeld 1bcd557 
stefan.seefeld b2b7855 
stefan.seefeld 278d178 
martin.v.loewis 59532d2 
stefan.seefeld 2a440e2 
stefan.seefeld 278d178 

martin.v.loewis 8e616d9 



ezio.melotti 7800183 
martin.v.loewis 8e616d9 



erik.forsberg 520b5a7 


stefan.seefeld 278d178 



stefan.seefeld b2b7855 
martin.v.loewis a129c72 
erik.forsberg 9934b1d 
stefan.seefeld 278d178 

erik.forsberg 9934b1d 
stefan.seefeld 278d178 






stefan.seefeld b2b7855 
Ezio Melotti 5872f58 
martin.v.loewis 6cfbfac 
stefan.seefeld 278d178 


martin.v.loewis 5bc191f 


stefan.seefeld 278d178 
erik.forsberg 520b5a7 
Ezio Melotti 5872f58 
erik.forsberg 520b5a7 
erik.forsberg ae1df84 


stefan.seefeld 278d178 

erik.forsberg ae1df84 
erik.forsberg 520fd49 



erik.forsberg ae1df84 






stefan.seefeld 278d178 

erik.forsberg ae1df84 
erik.forsberg 520fd49 


martin.v.loewis 8583c9f 
erik.forsberg 520fd49 

martin.v.loewis 9b8e6be 

erik.forsberg 520fd49 
stefan.seefeld 278d178 
erik.forsberg ae1df84 











stefan.seefeld 278d178 

erik.forsberg ae1df84 

stefan.seefeld 278d178 

erik.forsberg ae1df84 

stefan.seefeld 278d178 

erik.forsberg ae1df84 



















martin.v.loewis 78074cf 
erik.forsberg ae1df84 
stefan.seefeld 2a440e2 
erik.forsberg 520b5a7 



erik.forsberg 0e945e8 
erik.forsberg ae1df84 


stefan.seefeld 2a440e2 
erik.forsberg ae1df84 
stefan.seefeld 2a440e2 
erik.forsberg ae1df84 



  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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
#
# TRACKER SCHEMA
#

# Class automatically gets these properties:
#   creation = Date()
#   activity = Date()
#   creator = Link('user')
#   actor = Link('user')

# Issue Type
issue_type = Class(db, 'issue_type',
                   name=String(),
                   description=String(),
                   order=Number())
issue_type.setkey('name')

# Component
component = Class(db, 'component',
                  name=String(),
                  description=String(),
                  order=Number(),
                  assign_to=Link('user'),
                  add_as_nosy=Multilink('user'))
component.setkey('name')

# Version
version = Class(db, 'version',
                name=String(),
                description=String(),
                order=Number())
version.setkey('name')

# Severity
severity = Class(db, 'severity',
                 name=String(),
                 description=String(),
                 order=Number())
severity.setkey('name')

# Priority
priority = Class(db, 'priority',
                 name=String(),
                 description=String(),
                 order=Number())
priority.setkey('name')

# Stage
stage = Class(db, 'stage',
              name = String(),
              description = String(),
              order = Number())
stage.setkey('name')

# Status
status = Class(db, "status",
               name=String(),
               description=String(),
               order=Number())
status.setkey("name")

# Resolution
resolution = Class(db, "resolution",
                   name=String(),
                   description=String(),
                   order=Number())
resolution.setkey('name')

# Keyword
keyword = Class(db, "keyword",
                name=String(),
                description=String())
keyword.setkey("name")

# User-defined saved searches
query = Class(db, "query",
              klass=String(),
              name=String(),
              url=String(),
              private_for=Link('user'))

# add any additional database schema configuration here

user = Class(db, "user",
             username=String(),
             password=Password(),
             address=String(),
             realname=String(),
             phone=String(),
             organisation=String(),
             alternate_addresses=String(),
             queries=Multilink('query'),
             roles=String(),     # comma-separated string of Role names
             timezone=String(),
             contrib_form=Boolean(),
             contrib_form_date=Date(),
             openids=String(), # space separated list
             iscommitter=Boolean(),
             homepage=String(),
             )
user.setkey("username")
db.security.addPermission(name='Register', klass='user',
                          description='User is allowed to register new user')

openid_discovery = Class(db, 'openid_discovery',
                         url=String(), # key
                         services=String(), # space-separated list
                         op_endpoint=String(),
                         op_local=String())
openid_discovery.setkey('url')
openid_discovery.disableJournalling()

openid_session = Class(db, 'openid_session',
                       url=String(),
                       assoc_handle=String(),
                       expires=Date(),
                       mac_key=String())
openid_session.setkey('assoc_handle')
openid_session.disableJournalling()

openid_nonce = Class(db, 'openid_nonce',
                     created=Date(),
                     nonce=String())
openid_nonce.setkey('nonce')

# FileClass automatically gets this property in addition to the Class ones:
#   content = String()    [saved to disk in <tracker home>/db/files/]
#   type = String()       [MIME type of the content, default 'text/plain']
msg = FileClass(db, "msg",
                author=Link("user", do_journal='no'),
                recipients=Multilink("user", do_journal='no'),
                date=Date(),
                summary=String(),
                files=Multilink("file"),
                messageid=String(),
                inreplyto=String(),
                spambayes_score=Number(),
                spambayes_misclassified=Boolean(),)

file = FileClass(db, "file",
                 name=String(),
                 description=String(indexme='yes'),
                 spambayes_score=Number(),
                 spambayes_misclassified=Boolean(),
                 # filled out if this is a patch
                 revision=String(),
                 branch=String(),
                 # filled out if a corresponding Rietveld
                 # patchset exists for the issue
                 patchset=String(),)

hgrepo = Class(db, "hgrepo",
               url=String(),
               lastrev=String(),
               patchbranch=String(),
               )

# IssueClass automatically gets these properties in addition to the Class ones:
#   title = String()
#   messages = Multilink("msg")
#   files = Multilink("file")
#   nosy = Multilink("user")
#   superseder = Multilink("issue")
issue = IssueClass(db, "issue",
                   type=Link('issue_type'),
                   components=Multilink('component'),
                   versions=Multilink('version'),
                   severity=Link('severity'),
                   priority=Link('priority'),
                   dependencies=Multilink('issue'),
                   assignee=Link('user'),
                   status=Link('status'),
                   resolution=Link('resolution'),
                   superseder=Link('issue'),
                   keywords=Multilink("keyword"),
                   stage=Link('stage'),
                   nosy_count=Number(),
                   message_count=Number(),
                   hgrepos=Multilink('hgrepo'))

#
# TRACKER SECURITY SETTINGS
#
# See the configuration and customisation document for information
# about security setup.

db.security.addRole(name='Developer', description='A developer')
db.security.addRole(name='Coordinator', description='A coordinator')

db.security.addPermission(name="SB: May Classify")
db.security.addPermission(name="SB: May Report Misclassified")

#
# REGULAR USERS
#
# Give the regular users access to the web and email interface
for r in 'User', 'Developer', 'Coordinator':
    db.security.addPermissionToRole(r, 'Web Access')
    db.security.addPermissionToRole(r, 'Email Access')

##########################
# User permissions
##########################

for cl in ('issue_type', 'severity', 'component',
           'version', 'priority', 'stage', 'status', 'resolution',
           'issue', 'keyword', 'hgrepo'):
    db.security.addPermissionToRole('User', 'View', cl)
    db.security.addPermissionToRole('Anonymous', 'View', cl)

def may_edit_hgrepo(db, userid, itemid):
    return userid == db.hgrepo.get(itemid, "creator")
db.security.addPermissionToRole('User', 'Create', 'hgrepo')
p = db.security.addPermission(name='Edit', klass='hgrepo', check=may_edit_hgrepo,
                              properties=['url', 'patchbranch'])
db.security.addPermissionToRole('User', p)

class may_view_spam:
    def __init__(self, klassname):
        self.klassname = klassname

    def __call__(self, db, userid, itemid):
        cutoff_score = float(db.config.detectors['SPAMBAYES_SPAM_CUTOFF'])
        klass = db.getclass(self.klassname)

        try:
            score = klass.get(itemid, 'spambayes_score')
        except (KeyError, IndexError):
            return True

        if score > cutoff_score:
            return False

        return True

for cl in ('file', 'msg'):
    p = db.security.addPermission(name='View', klass=cl,
                                  description="allowed to see metadata object regardless of spam status",
                                  properties=('creation', 'activity',
                                              'creator', 'actor',
                                              'name', 'spambayes_score',
                                              'spambayes_misclassified',
                                              'author', 'recipients',
                                              'date', 'files', 'messageid',
                                              'inreplyto', 'type',
                                              'description',
                                              ))

    db.security.addPermissionToRole('Anonymous', p)
    db.security.addPermissionToRole('User', p)

    db.security.addPermissionToRole('User', 'Create', cl)

    p = db.security.addPermission(name='View', klass=cl,
                                  description="Allowed to see content of object regardless of spam status",
                                  properties = ('content', 'summary'))

    db.security.addPermissionToRole('User', p)

    spamcheck = db.security.addPermission(name='View', klass=cl,
                                          description="allowed to see content if not spam",
                                          properties=('content', 'summary'),
                                          check=may_view_spam(cl))

    db.security.addPermissionToRole('Anonymous', spamcheck)

def may_edit_file(db, userid, itemid):
    return userid == db.file.get(itemid, "creator")
p = db.security.addPermission(name='Edit', klass='file', check=may_edit_file,
    description="User is allowed to remove their own files")
db.security.addPermissionToRole('User', p)

p = db.security.addPermission(name='Create', klass='issue',
                              properties=('title', 'type',
                                          'components', 'versions',
                                          'severity',
                                          'messages', 'files', 'nosy', 'hgrepos'),
                              description='User can report and discuss issues')
db.security.addPermissionToRole('User', p)

p = db.security.addPermission(name='Edit', klass='issue',
                              properties=('title', 'type',
                                          'components', 'versions',
                                          'severity',
                                          'messages', 'files', 'nosy', 'hgrepos'),
                              description='User can report and discuss issues')
db.security.addPermissionToRole('User', p)

# Allow users to close issues they created
def close_own_issue(db, userid, itemid):
    return userid == db.issue.get(itemid, 'creator')
p = db.security.addPermission(name='Edit', klass='issue',
                              properties=('status', 'resolution'),
                              description='User can close issues he created',
                              check=close_own_issue)
db.security.addPermissionToRole('User', p)

db.security.addPermissionToRole('User', 'SB: May Report Misclassified')



##########################
# Developer permissions
##########################
for cl in ('issue_type', 'severity', 'component',
           'version', 'priority', 'stage', 'status', 'resolution',
           'issue', 'file', 'msg', 'keyword'):
    db.security.addPermissionToRole('Developer', 'View', cl)

for cl in ('issue', 'file', 'msg', 'keyword'):
    db.security.addPermissionToRole('Developer', 'Edit', cl)
    db.security.addPermissionToRole('Developer', 'Create', cl)


##########################
# Coordinator permissions
##########################
for cl in ('issue_type', 'severity', 'component',
           'version', 'priority', 'stage', 'status', 'resolution', 'issue',
           'file', 'msg', 'hgrepo'):
    db.security.addPermissionToRole('Coordinator', 'View', cl)
    db.security.addPermissionToRole('Coordinator', 'Edit', cl)
    db.security.addPermissionToRole('Coordinator', 'Create', cl)
    p = db.security.addPermission(name='Retire', klass=cl,
                                  description='Coordinator may retire '+cl)
    db.security.addPermissionToRole('Coordinator', p)

db.security.addPermissionToRole('Coordinator', 'SB: May Classify')
db.security.addPermissionToRole('Developer', 'SB: May Classify')

# May users view other user information? Comment these lines out
# if you don't want them to
db.security.addPermissionToRole('User', 'View', 'user')
db.security.addPermissionToRole('Developer', 'View', 'user')
db.security.addPermissionToRole('Coordinator', 'View', 'user')

# Allow Coordinator to edit any user, including their roles.
db.security.addPermissionToRole('Coordinator', 'Edit', 'user')
db.security.addPermissionToRole('Coordinator', 'Web Roles')

# Users should be able to edit their own details -- this permission is
# limited to only the situation where the Viewed or Edited item is their own.
def own_record(db, userid, itemid):
    '''Determine whether the userid matches the item being accessed.'''
    return userid == itemid
p = db.security.addPermission(name='View', klass='user', check=own_record,
    description="User is allowed to view their own user details")
for r in 'User', 'Developer', 'Coordinator':
    db.security.addPermissionToRole(r, p)
p = db.security.addPermission(name='Edit', klass='user', check=own_record,
    description="User is allowed to edit their own user details",
    properties=('username', 'password',
                'address', 'realname',
                'phone', 'organisation',
                'alternate_addresses',
                'queries',
                'timezone')) # Note: 'roles' excluded - users should not be able to edit their own roles.
                             # Also excluded: contrib_form, contrib_form_date, iscommitter
for r in 'User', 'Developer':
    db.security.addPermissionToRole(r, p)

# Users should be able to edit and view their own queries. They should also
# be able to view any marked as not private. They should not be able to
# edit others' queries, even if they're not private
def view_query(db, userid, itemid):
    private_for = db.query.get(itemid, 'private_for')
    if not private_for: return True
    return userid == private_for
def edit_query(db, userid, itemid):
    return userid == db.query.get(itemid, 'creator')
p = db.security.addPermission(name='View', klass='query', check=view_query,
    description="User is allowed to view their own and public queries")
for r in 'User', 'Developer', 'Coordinator':
    db.security.addPermissionToRole(r, p)
p = db.security.addPermission(name='Edit', klass='query', check=edit_query,
    description="User is allowed to edit their queries")
for r in 'User', 'Developer', 'Coordinator':
    db.security.addPermissionToRole(r, p)
p = db.security.addPermission(name='Create', klass='query',
    description="User is allowed to create queries")
for r in 'User', 'Developer', 'Coordinator':
    db.security.addPermissionToRole(r, p)


#
# ANONYMOUS USER PERMISSIONS
#
# Let anonymous users access the web interface. Note that almost all
# trackers will need this Permission. The only situation where it's not
# required is in a tracker that uses an HTTP Basic Authenticated front-end.
db.security.addPermissionToRole('Anonymous', 'Web Access')

# Let anonymous users access the email interface (note that this implies
# that they will be registered automatically, hence they will need the
# "Create" user Permission below)
# This is disabled by default to stop spam from auto-registering users on
# public trackers.
#db.security.addPermissionToRole('Anonymous', 'Email Access')

# Assign the appropriate permissions to the anonymous user's Anonymous
# Role. Choices here are:
# - Allow anonymous users to register
db.security.addPermissionToRole('Anonymous', 'Register', 'user')

# Allow anonymous users access to view issues (and the related, linked
# information).
# Note permissions settings for file and msg above (due to spambayes
# integration).

for cl in 'issue', 'severity', 'status', 'resolution':
    db.security.addPermissionToRole('Anonymous', 'View', cl)

# [OPTIONAL]
# Allow anonymous users access to create or edit "issue" items (and the
# related file and message items)
#for cl in 'issue', 'file', 'msg':
#   db.security.addPermissionToRole('Anonymous', 'Create', cl)
#   db.security.addPermissionToRole('Anonymous', 'Edit', cl)


# vim: set filetype=python sts=4 sw=4 et si :