style fix: use with with open, os.path.join for pathes

This commit is contained in:
Thomas Waldmann 2013-09-29 01:59:47 +02:00
parent 26a911824d
commit 0a297b04ee

View File

@ -24,7 +24,8 @@ def UpdateIpView(request):
af = dns.inet.af_for_address(ipaddr)
key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6'
request.session[key] = ipaddr
image_data = open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb").read()
with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f:
image_data = f.read()
return HttpResponse(image_data, mimetype="image/png")