Example #1
0
    def read(self, request, vendor, name, version):

        operator = get_object_or_404(CatalogueResource, type=2, vendor=vendor, short_name=name, version=version)
        # For now, all operators are freely accessible/distributable
        # if not operator.is_available_for(request.user):
        #    return HttpResponseForbidden()

        mode = request.GET.get('mode', 'classic')

        key = get_operator_cache_key(operator, get_current_domain(request), mode)
        cached_response = cache.get(key)
        if cached_response is None:
            options = operator.json_description
            js_files = options['js_files']

            base_url = get_absolute_reverse_url('wirecloud.showcase_media', kwargs={
                'vendor': operator.vendor,
                'name': operator.short_name,
                'version': operator.version,
                'file_path': operator.template_uri
            }, request=request)

            xhtml = generate_xhtml_operator_code(js_files, base_url, request, process_requirements(options['requirements']), mode)
            cache_timeout = 31536000  # 1 year
            cached_response = CacheableData(xhtml, timeout=cache_timeout, content_type='application/xhtml+xml; charset=UTF-8')

            cache.set(key, cached_response, cache_timeout)

        return cached_response.get_response()
Example #2
0
    def read(self, request, vendor, name, version):

        operator = get_object_or_404(CatalogueResource, type=2, vendor=vendor, short_name=name, version=version)
        if not operator.is_available_for(request.user):
            return HttpResponseForbidden()

        key = '_operator/' + operator.local_uri_part
        cached_response = cache.get(key)
        if cached_response is None:
            options = json.loads(operator.json_description)
            js_files = options['js_files']

            base_url = operator.template_uri
            if not base_url.startswith(('http://', 'https://')):
                base_url = get_absolute_reverse_url('wirecloud_catalogue.media', kwargs={
                    'vendor': operator.vendor,
                    'name': operator.short_name,
                    'version': operator.version,
                    'file_path': operator.template_uri
                }, request=request)

            xhtml = generate_xhtml_operator_code(js_files, base_url, request)
            cache_timeout = 31536000  # 1 year
            cached_response = CacheableData(xhtml, timeout=cache_timeout, mimetype='application/xhtml+xml; charset=UTF-8')

            cache.set(key, cached_response, cache_timeout)

        return cached_response.get_response()
Example #3
0
    def read(self, request, vendor, name, version):

        operator = get_object_or_404(CatalogueResource,
                                     type=2,
                                     vendor=vendor,
                                     short_name=name,
                                     version=version)
        # For now, all operators are freely accessible/distributable
        #if not operator.is_available_for(request.user):
        #    return HttpResponseForbidden()

        mode = request.GET.get('mode', 'classic')

        key = get_operator_cache_key(operator, get_current_domain(request),
                                     mode)
        cached_response = cache.get(key)
        if cached_response is None:
            options = json.loads(operator.json_description)
            js_files = options['js_files']

            base_url = operator.template_uri
            if not base_url.startswith(('http://', 'https://')):
                base_url = get_absolute_reverse_url('wirecloud.showcase_media',
                                                    kwargs={
                                                        'vendor':
                                                        operator.vendor,
                                                        'name':
                                                        operator.short_name,
                                                        'version':
                                                        operator.version,
                                                        'file_path':
                                                        operator.template_uri
                                                    },
                                                    request=request)

            xhtml = generate_xhtml_operator_code(
                js_files, base_url, request,
                process_requirements(options['requirements']), mode)
            cache_timeout = 31536000  # 1 year
            cached_response = CacheableData(
                xhtml,
                timeout=cache_timeout,
                content_type='application/xhtml+xml; charset=UTF-8')

            cache.set(key, cached_response, cache_timeout)

        return cached_response.get_response()
Example #4
0
    def read(self, request, vendor, name, version):

        operator = get_object_or_404(CatalogueResource, type=2, vendor=vendor, short_name=name, version=version)
        options = json.loads(operator.json_description)
        js_files = options['js_files']

        base_url = operator.template_uri
        if not base_url.startswith(('http://', 'https://')):
            base_url = get_absolute_reverse_url('wirecloud_catalogue.media', kwargs={
                'vendor': operator.vendor,
                'name': operator.short_name,
                'version': operator.version,
                'file_path': operator.template_uri
            }, request=request)

        xhtml = generate_xhtml_operator_code(js_files, base_url, request)

        return HttpResponse(xhtml, mimetype='application/xhtml+xml; charset=UTF-8')