cyberdelia / manifesto

Pluggable cache manifest for Django

Home Page:https://manifesto.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not like unicode arrays

darkpixel opened this issue · comments

class StaticManifest(Manifest):
    def cache(self):
        return [
            u'/static/blah.js',
        ]

    def network(self):
        return [u'test1', u'test2']

    def fallback(self):
        return [
            ('/', '/offline.html'),
        ]

The first access of the manifest works correctly. The second attempt crashes with:

Environment:

Request Method: GET
Request URL: http://localhost:8000/manifest.appcache

Django Version: 1.4
Python Version: 2.7.3

Traceback:
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/django/views/generic/base.py" in view
  48.             return self.dispatch(request, *args, **kwargs)
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
  69.         return handler(request, *args, **kwargs)
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/django/views/generic/base.py" in get
  123.         context = self.get_context_data(**kwargs)
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/manifesto/views.py" in get_context_data
  16.             'revision': manifest.revision,
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/manifesto/__init__.py" in revision
  84.         revision = [manifest.revision() for manifest in self.manifests]
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/manifesto/manifest.py" in revision
  19.         return sha_constructor(bencode(revision)).hexdigest()[:7]
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/bencode/__init__.py" in bencode
  130.     encode_func[type(x)](x, r)
File "/home/aaron/.virtualenvs/ticketapp/local/lib/python2.7/site-packages/bencode/__init__.py" in encode_list
  101.         encode_func[type(i)](i, r)

Exception Type: KeyError at /manifest.appcache
Exception Value: <type 'unicode'>

It's a limitation in bencode, if you have more time than me to find a workaround (mostly passing smart_str when needed), I will happily merge your pull-request.