return url, url def delete_file(file_path): from urlparse import urlsplit from settings import bos_client, const path = urlsplit(file_path).path _, bucket_name, object_name = path.split("/", 2) object_name = "/" + object_name bos_client.delete_object(bucket_name, object_name) ############################################ ## memcache ############################################ from settings import const, ENABLE_MEMCACHE if ENABLE_MEMCACHE: from bae_memcache.cache import BaeMemcache from tools import fail_safe_func # bind memcache to BAE memcache = BaeMemcache(const.CACHE_ID, const.CACHE_ADDR, const.CACHE_USER, const.CACHE_PASS) memcache.flush_all = lambda: None memcache.set = fail_safe_func(memcache.set)
def delete_file(file_path): from urlparse import urlsplit from sae.storage import Bucket res = urlsplit(file_path) hostname, path = res.hostname, res.path bucket_name = hostname.split(".", 1)[0].split("-")[-1] _, object_name = path.split("/", 1) bucket = Bucket(bucket_name) bucket.delete_object(object_name) ############################################ ## memcache ############################################ from settings import ENABLE_MEMCACHE if ENABLE_MEMCACHE: import pylibmc from tools import fail_safe_func memcache = pylibmc.Client() memcache.flush_all = fail_safe_func(memcache.flush_all) memcache.set = fail_safe_func(memcache.set)
from urlparse import urlsplit from sae.storage import Bucket res = urlsplit(file_path) hostname, path = res.hostname, res.path bucket_name = hostname.split(".", 1)[0].split("-")[-1] _, object_name = path.split("/", 1) bucket = Bucket(bucket_name) bucket.delete_object(object_name) ############################################ ## memcache ############################################ from settings import ENABLE_MEMCACHE if ENABLE_MEMCACHE: import pylibmc from tools import fail_safe_func memcache = pylibmc.Client() memcache.flush_all = fail_safe_func(memcache.flush_all) memcache.set = fail_safe_func(memcache.set)
return url, url def delete_file(file_path): from urlparse import urlsplit from settings import BAE_BCS path = urlsplit(file_path).path _, bucket_name, object_name = path.split("/", 2) object_name = "/" + object_name bucket = BAE_BCS.bucket(bucket_name) bcs_obj = bucket.object(object_name) bcs_obj.delete() ############################################ ## memcache ############################################ from settings import const, ENABLE_MEMCACHE if ENABLE_MEMCACHE: from bae_memcache.cache import BaeMemcache from tools import fail_safe_func # bind memcache to BAE memcache = BaeMemcache(const.CACHE_ID, const.CACHE_ADDR, const.CACHE_USER, const.CACHE_PASS) memcache.flush_all = lambda: None memcache.set = fail_safe_func(memcache.set)