northlat, westlng = float(northlat), float(westlng) except AssertionError, err: logging.error(err.args[0]) return try: google_data = { 'key': constants.google_maps_apikey, 'zoom': zoom, 'center': centerpoint, 'size': widthxheight, 'sensor':'false', 'format':'png', } mapimage = MapImage.all().filter('user =', user).get() if not mapimage: mapimage = MapImage() mapimage.user = user def reset_map_image(mapimage_param, centerlat_param, centerlng_param, northlat_param, westlng_param, zoom_param, height_param, width_param, google_data_param): mapimage_param.tiles_remaining = len(range(0, width_param, 256)) * len(range(0, height_param, 256)) mapimage_param.centerlat = centerlat_param mapimage_param.centerlng = centerlng_param mapimage_param.northlat = northlat_param mapimage_param.westlng = westlng_param mapimage_param.zoom = zoom_param mapimage_param.height = height_param mapimage_param.width = width_param mapimage_param.static_url = "http://maps.google.com/maps/api/staticmap?" + urllib.urlencode(google_data_param) mapimage_param.img = None mapimage_param.put() db.run_in_transaction(reset_map_image, mapimage, centerlat, centerlng, northlat, westlng, zoom, height, width, google_data) for offset_x_px in range(0, width, 256):