@@ -4374,12 +4374,12 @@ the following into ``detectors/anti_spam.py`` in your tracker::
43744374
43754375 def reject_html(db, cl, nodeid, newvalues):
43764376 if newvalues['type'] == 'text/html':
4377- raise Reject, 'not allowed'
4377+ raise Reject( 'not allowed')
43784378
43794379 def reject_manylinks(db, cl, nodeid, newvalues):
43804380 content = newvalues['content']
43814381 if content.count('http://') > 2:
4382- raise Reject, 'not allowed'
4382+ raise Reject( 'not allowed')
43834383
43844384 def init(db):
43854385 db.file.audit('create', reject_html)
@@ -4389,7 +4389,7 @@ You may also wish to block image attachments if your tracker does not
43894389need that ability::
43904390
43914391 if newvalues['type'].startswith('image/'):
4392- raise Reject, 'not allowed'
4392+ raise Reject( 'not allowed')
43934393
43944394
43954395Stop "nosy" messages going to people on vacation
@@ -4453,7 +4453,7 @@ vacation". Not very useful, and relatively easy to stop.
44534453 if users.get(nosyid, 'username') == 'anonymous':
44544454 continue
44554455 # make sure they haven't seen the message already
4456- if not seen_message.has_key(nosyid) :
4456+ if nosyid not in seen_message:
44574457 # send it to them
44584458 sendto.append(nosyid)
44594459 recipients.append(nosyid)
@@ -4520,16 +4520,16 @@ move issues. You can do this by following these steps:
45204520 ''' Check that the desired transition is valid for the "status"
45214521 property.
45224522 '''
4523- if not newvalues.has_key( 'status') :
4523+ if 'status' not in newvalues :
45244524 return
45254525 current = cl.get(nodeid, 'status')
45264526 new = newvalues['status']
45274527 if new == current:
45284528 return
45294529 ok = db.status.get(current, 'transitions')
45304530 if new not in ok:
4531- raise ValueError, 'Status not allowed to move from "%s" to "%s"'%(
4532- db.status.get(current, 'name'), db.status.get(new, 'name'))
4531+ raise ValueError( 'Status not allowed to move from "%s" to "%s"'%(
4532+ db.status.get(current, 'name'), db.status.get(new, 'name')))
45334533
45344534 def init(db):
45354535 db.issue.audit('set', checktransition)
@@ -4623,7 +4623,7 @@ resolved. To achieve this:
46234623
46244624 # don't do anything if there's no blockers or the status hasn't
46254625 # changed
4626- if not blockers or not newvalues.has_key( 'status') :
4626+ if not blockers or 'status' not in newvalues :
46274627 return
46284628
46294629 # get the resolved state ID
@@ -4640,7 +4640,7 @@ resolved. To achieve this:
46404640
46414641 # ok, see if we're trying to resolve
46424642 if newvalues['status'] == resolved_id:
4643- raise ValueError, "This issue can't be resolved until %s resolved."%s
4643+ raise ValueError( "This issue can't be resolved until %s resolved."%s)
46444644
46454645
46464646 def resolveblockers(db, cl, nodeid, oldvalues):
@@ -4826,23 +4826,23 @@ This results in the following function::
48264826 ok = ('yes',)
48274827 # old node, get the current values from the node if they haven't
48284828 # changed
4829- if not newvalues.has_key( 'nosy') :
4829+ if 'nosy' not in newvalues :
48304830 nosy = cl.get(nodeid, 'nosy')
48314831 for value in nosy:
4832- if not current.has_key(value) :
4832+ if value not in current:
48334833 current[value] = 1
48344834
48354835 # if the nosy list changed in this transaction, init from the new value
4836- if newvalues.has_key( 'nosy') :
4836+ if 'nosy' in newvalues :
48374837 nosy = newvalues.get('nosy', [])
48384838 for value in nosy:
48394839 if not db.hasnode('user', value):
48404840 continue
4841- if not current.has_key(value) :
4841+ if value not in current:
48424842 current[value] = 1
48434843
48444844 # add users with keyword in nosy_keywords to the nosy list
4845- if newvalues.has_key( 'keyword') and newvalues['keyword'] is not None:
4845+ if 'keyword' in newvalues and newvalues['keyword'] is not None:
48464846 keyword_ids = newvalues['keyword']
48474847 for keyword in keyword_ids:
48484848 # loop over all users,
@@ -4857,7 +4857,7 @@ This results in the following function::
48574857 current[user_id] = 1
48584858
48594859 # that's it, save off the new nosy list
4860- newvalues['nosy'] = current.keys()
4860+ newvalues['nosy'] = list( current.keys() )
48614861
48624862These two function are the only ones needed in the file.
48634863
@@ -4919,7 +4919,7 @@ directory of your tracker::
49194919 def restrict_nosy_changes(db, cl, nodeid, newvalues):
49204920 '''Do not permit changes to nosy via email.'''
49214921
4922- if not (newvalues.has_key( 'nosy')) :
4922+ if 'nosy' not in newvalues :
49234923 # the nosy field has not changed so no need to check.
49244924 return
49254925
@@ -4999,14 +4999,14 @@ tracker ``detectors`` directory)::
49994999 ''' Ensure the assignedto value in newvalues is used with the
50005000 Fixer Permission
50015001 '''
5002- if not newvalues.has_key( 'assignedto') :
5002+ if 'assignedto' not in newvalues :
50035003 # don't care
50045004 return
50055005
50065006 # get the userid
50075007 userid = newvalues['assignedto']
50085008 if not db.security.hasPermission('Fixer', userid, cl.classname):
5009- raise ValueError, 'You do not have permission to edit %s'%cl.classname
5009+ raise ValueError( 'You do not have permission to edit %s'%cl.classname)
50105010
50115011 def init(db):
50125012 db.issue.audit('set', assignedtoMustBeFixer)
0 commit comments