Change some deprecated code
Python docs say: "Test for the presence of key in the dictionary. has_key() is deprecated in favor of key in d."
This commit is contained in:
parent
a7ec8bc5fa
commit
edc81ca1e1
|
@ -59,7 +59,7 @@ class BuyableItemHandler(BaseHandler):
|
|||
except Buyable.DoesNotExist:
|
||||
return rc.NOT_FOUND
|
||||
else:
|
||||
if request.GET.has_key('type'):
|
||||
if 'type' in request.GET:
|
||||
obj = Buyable.objects.filter(buyableType__name=request.GET['type'])
|
||||
return obj
|
||||
try:
|
||||
|
@ -129,12 +129,12 @@ class BuyableItemHandler(BaseHandler):
|
|||
if not request.content_type:
|
||||
return getError(rc.BAD_REQUEST, "The content-type of the request must not be empty/urlencoded")
|
||||
|
||||
if not request.data.has_key("items") and not request.data.has_key("deposits"):
|
||||
if not "items" in request.data and not "deposits" in request.data:
|
||||
return getError(rc.BAD_REQUEST, "You need to specify either items or deposits (or both).")
|
||||
|
||||
if not request.data.has_key("items"):
|
||||
if not "items" in request.data:
|
||||
request.data['items'] = []
|
||||
if not request.data.has_key("deposits"):
|
||||
if not "deposits" in request.data:
|
||||
request.data['deposits'] = []
|
||||
|
||||
itemList = []
|
||||
|
@ -142,7 +142,7 @@ class BuyableItemHandler(BaseHandler):
|
|||
if not isinstance(request.data['items'], Iterable):
|
||||
raise TypeError()
|
||||
itemList += request.data['items']
|
||||
if request.data.has_key('items'):
|
||||
if 'items' in request.data:
|
||||
if not isinstance(request.data['deposits'], Iterable):
|
||||
raise TypeError()
|
||||
itemList += request.data['deposits']
|
||||
|
@ -157,7 +157,7 @@ class BuyableItemHandler(BaseHandler):
|
|||
|
||||
ids = {}
|
||||
for item in itemList:
|
||||
if not ids.has_key(item):
|
||||
if not item in ids:
|
||||
try:
|
||||
ids[item] = Buyable.objects.get(id=item)
|
||||
except Buyable.DoesNotExist:
|
||||
|
@ -397,7 +397,7 @@ class AuthBlobHandler(BaseHandler):
|
|||
"""
|
||||
if not request.plugin.pluginCanWriteAuthblob:
|
||||
return getError(rc.FORBIDDEN, "This plugin is not allowed to write the user's authblob")
|
||||
if not request.data.has_key('authblob'):
|
||||
if not 'authblob' in request.data:
|
||||
return getError(rc.BAD_REQUEST, "To change the user's auth blob you actually need to provide one")
|
||||
request.pluginperms.authblob = request.data['authblob']
|
||||
request.pluginperms.authblob.save()
|
||||
|
@ -424,7 +424,7 @@ class AuthUserHandler(BaseHandler):
|
|||
if not request.plugin.uniqueAuthblob:
|
||||
return getError(rc.BAD_REQUEST, "This plugin does not support unique auth blobs, therefore we can't identify a user uniquely by their authblob")
|
||||
|
||||
if not request.GET.has_key('authblob') or request.GET['authblob'] == '':
|
||||
if request.GET.get('authblob', '') == '':
|
||||
return getError(rc.BAD_REQUEST, "Authblob was empty.")
|
||||
|
||||
user = getUserFromAuthblob(request.GET['authblob'], request.plugin)
|
||||
|
|
|
@ -138,7 +138,7 @@ def pluginAuthblob(request, pluginId):
|
|||
return render_to_response("settings/settings.html", d, RequestContext(request))
|
||||
|
||||
# has the user write access to the authblob?
|
||||
if not p.plugin.userCanWriteAuthblob or not request.POST.has_key("authblob"):
|
||||
if not p.plugin.userCanWriteAuthblob or not "authblob" in request.POST:
|
||||
d = getPluginDict(request)
|
||||
d['pluginerror'] = "Der Authblob darf für dieses Plugin nicht vom User verändert werden (oder der Authblob war kaputt)"
|
||||
return render_to_response("settings/settings.html", d, RequestContext(request))
|
||||
|
|
|
@ -25,7 +25,7 @@ class TransactionForm(forms.ModelForm):
|
|||
def clean(self):
|
||||
# needed to enforce TransactionTypes needsCheck "default value"
|
||||
cleaned_data = super(TransactionForm, self).clean()
|
||||
if cleaned_data.has_key("transactionType"):
|
||||
if "transactionType" in cleaned_data:
|
||||
self.instance.checked = not cleaned_data['transactionType'].needsCheck
|
||||
return cleaned_data
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ def overview(request):
|
|||
vform = VirtualTransactionForm()
|
||||
state = None
|
||||
payway = "payin"
|
||||
if request.method == 'POST' and request.POST.has_key('_formtype'):
|
||||
if request.method == 'POST' and '_formtype' in request.POST:
|
||||
if request.POST['_formtype'] == "normal":
|
||||
transaction = Transaction(user=request.user)
|
||||
form = TransactionForm(request.POST, instance=transaction)
|
||||
|
|
Loading…
Reference in New Issue