pydanny / dj-libcloud

Adds easy python 3 and 2.7 support to Django for management of static assets.
BSD 3-Clause "New" or "Revised" License
53 stars 4 forks source link

NotImplementedError: get_object_cdn_url() not implemented for this driver #12

Closed audreyfeldroy closed 10 years ago

audreyfeldroy commented 10 years ago

Apparently, libcloud's S3StorageDriver class does not implement the get_object_cdn_url() method. I could not find it in https://github.com/apache/libcloud/blob/95b6a68adb5cbbe071d9da509484146cff6c5626/libcloud/storage/drivers/s3.py

You can see an example of the get_object_cdn_url() method in libcloud's CloudFilesStorageDriver (for Rackspace Cloudfiles) class at https://github.com/apache/libcloud/blob/d69adbd886965c7b176b9713cdad2f954d041c3c/libcloud/storage/drivers/cloudfiles.py#L298

The error:

Template error:
In template /vagrant/created/templates/base.html, error at line 26
   get_object_cdn_url not implemented for this driver

   26 :     <link href=" {% static 'css/project.css' %} " rel="stylesheet">

The traceback:

Traceback:
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  137.                 response = response.render()
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/response.py" in render
  105.             self.content = self.rendered_content
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  82.         content = template.render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  78.             return node.render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  78.             return node.render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  78.             return node.render(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/templatetags/static.py" in render
  106.         url = self.url(context)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py" in url
  12.         return staticfiles_storage.url(path)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/djlibcloud/storage.py" in url
  169.         url = self.driver.get_object_cdn_url(obj)
File "/home/vagrant/.env/local/lib/python2.7/site-packages/libcloud/storage/base.py" in get_object_cdn_url
  296.             'get_object_cdn_url not implemented for this driver')

Exception Type: NotImplementedError at /
Exception Value: get_object_cdn_url not implemented for this driver

Is there a way we could work around this by constructing the URL some other way in dj-libcloud?

audreyfeldroy commented 10 years ago

Pull request https://github.com/apache/libcloud/pull/80 implemented get_object_cdn_url(), but it was closed in favor of a different change.

tecywiz121 commented 10 years ago

Sorry, I'm a little confused. How are we supposed to use S3 (or google cloud storage in my case) now?

pydanny commented 10 years ago

@tecywiz121 We haven't had a chance to look into it yet. If you find a fix for this issue, please submit a pull request.

pydanny commented 10 years ago

This should be fixed per https://github.com/pydanny/dj-libcloud/commit/8663cb9567ab4e9c87ffc4a57991490ccae7cfb9