コード例 #1
0
ファイル: render.py プロジェクト: subc/anchovy
def _replace_image_loader(swf_name, replace_images, animation_type, is_redberry=False):
    """
    Flash埋め込み用画像を読み込む
    replace_images = {'key': instance of Image} ==> {'key': raw_data}
    """
    if not replace_images:
        return {}

    result = {}
    for key, image in replace_images.items():
        if isinstance(image, (Image, Image2)):
            object_key = get_animation_param_name(swf_name, animation_type, key)
            if object_key:
                if animation_type in ["swf", "reel"]:
                    result[object_key] = image.media

                if animation_type in ["html"]:
                    if is_redberry:
                        if isinstance(image, Image):
                            result[object_key] = get_device_name() + "/" + image.path
                        elif isinstance(image, Image2):
                            result[object_key] = image.reactive_path
                    else:
                        result[object_key] = image.url

                    if not image.is_exists and not getattr(image, "dummy_image", None):
                        raise ImageDoesNotExist(image.url)

    return result
コード例 #2
0
def _replace_image_loader(swf_name,
                          replace_images,
                          animation_type,
                          is_redberry=False):
    """
    Flash埋め込み用画像を読み込む
    replace_images = {'key': instance of Image} ==> {'key': raw_data}
    """
    if not replace_images:
        return {}

    result = {}
    for key, image in replace_images.items():
        if isinstance(image, (Image, Image2)):
            object_key = get_animation_param_name(swf_name, animation_type,
                                                  key)
            if object_key:
                if animation_type in ['swf', 'reel']:
                    result[object_key] = image.media

                if animation_type in ['html']:
                    if is_redberry:
                        if isinstance(image, Image):
                            result[object_key] = \
                                get_device_name() + '/' + image.path
                        elif isinstance(image, Image2):
                            result[object_key] = image.reactive_path
                    else:
                        result[object_key] = image.url

                    if not image.is_exists and not getattr(
                            image, 'dummy_image', None):
                        raise ImageDoesNotExist(image.url)

    return result
コード例 #3
0
ファイル: views.py プロジェクト: subc/anchovy
    def get(self, request, *args, **kwargs):
        path = kwargs.get("path").split("/")
        filename = path.pop(-1)
        path = os.path.join(MOCK_BASE_PATH, get_device_name(request.device.is_featurephone), *path)
        t, origin = loader.find_template(filename, [path])

        context = {"card": ObjectMock(pk=33), "player_card": ObjectMock(pk=33), "player": ObjectMock(pk=str(33))}
        context.update(get_template_article_keys(os.path.join(path, filename)))
        return HttpResponse(t.render(RequestContext(request, context)))
コード例 #4
0
    def get(self, request, *args, **kwargs):
        path = kwargs.get('path').split('/')
        filename = path.pop(-1)
        path = os.path.join(MOCK_BASE_PATH,
                            get_device_name(request.device.is_featurephone),
                            *path)
        t, origin = loader.find_template(filename, [path])

        context = {
            'card': ObjectMock(pk=33),
            'player_card': ObjectMock(pk=33),
            'player': ObjectMock(pk=str(33))
        }
        context.update(get_template_article_keys(os.path.join(path, filename)))
        return HttpResponse(t.render(RequestContext(request, context)))