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):
   = name
            self.ignores = ignores or []
            self.version = version
            self._library_deps = set()
            self.known_resources = {}
        def __repr__(self):
            return "<UrlLibrary '%s'>" % (, )
        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'>" % (
  2. antti_haapala

    Not only that, but it should be possible to override a library on an application by application basis - for example to load jQuery from CDN for one project.

  3. Log in to comment