plcache.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:DCRM 作者: 82Flex 项目源码 文件源码
def create_cache(sizes, options):
    """
    Creates the cache for the given files
    """
    reset = options.get('reset', None)

    size_list = [size.strip(' ,') for size in sizes]

    if len(size_list) < 1:
        sizes = PhotoSize.objects.filter(pre_cache=True)
    else:
        sizes = PhotoSize.objects.filter(name__in=size_list)

    if not len(sizes):
        raise CommandError('No photo sizes were found.')

    print('Caching photos, this may take a while...')

    for cls in ImageModel.__subclasses__():
        for photosize in sizes:
            print('Cacheing %s size images' % photosize.name)
            for obj in cls.objects.all():
                if reset:
                    obj.remove_size(photosize)
                obj.create_size(photosize)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号