1. fanstatic
  2. fanstatic
  3. fanstatic
  4. Issues
Issue #25 new

CDN support

created an issue

resources should be able to declare their availability on various content delivery networks (perhaps using the mode mechanism).

Comments (2)

  1. Anonymous

    I needed the CDN functionality, so I wrote an extension to fanstatic. Maybe it is useful for you also.

    import fanstatic
    class UrlLibrary(fanstatic.Library):
        def __init__(self, name, ignores=None, version=None):
            self.name = name
            self.ignores = ignores or []
            self.version = version
            self._library_deps = set()
            self.known_resources = {}
        def __repr__(self):
            return "<UrlLibrary '%s'>" % (self.name, )
        def register(self, resource):
            if resource.url in self.known_resources:
                raise ConfigurationError(
                    'Resource path %s is already defined.' % resource.url)
            self.known_resources[resource.url] = resource
        def signature(self, recompute_hashes=False, version_method=None):
            return  ''
    class UrlResource(fanstatic.Resource):
        def __init__(self, library, url,
                    # Workaround for orders, because not all javascript in CDN will end with '.js'
    #        old_resource_file_existence_checking = fanstatic.core._resource_file_existence_checking
            #TODO: we can not get access to this data and function
            fanstatic.Resource.__init__(self, library, url, renderer=renderer, **kw)
            self.url = url
            self.order = fanstatic.core.inclusion_renderers['.js'][0]
            # Workaround for orders, because not all javascript in CDN will end with '.js'
        def render(self, library_url):
            return self.renderer(self.url)
        def __repr__(self):
            return "<UrlResource '%s' in library '%s'>" % (
                self.url, self.library.name)
  2. Log in to comment