Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate works but generate_all doesn't #3

Open
meric opened this issue Dec 31, 2012 · 3 comments
Open

generate works but generate_all doesn't #3

meric opened this issue Dec 31, 2012 · 3 comments

Comments

@meric
Copy link
Contributor

meric commented Dec 31, 2012

I've had trouble with the generate_all method. Any ideas? generate(template) works, however.

Django version 1.5b2, using settings 'sagesse.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/conf/__init__.py", line 52, in __getattr__
    self._setup(name)
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/conf/__init__.py", line 130, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/Eric/Projects/sagesse/sagesse/settings.py", line 135, in <module>
    print env.jsjinja.generate_all()
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/jsjinja/__init__.py", line 35, in generate_all
    return ';'+';\n'.join(map(self.generate,templates))+';'
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/jsjinja/__init__.py", line 26, in generate
    source, fn, _ = self.environment.loader.get_source(self.environment,filename)
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/site-packages/jinja2/loaders.py", line 240, in get_source
    return source.decode(self.encoding), filename, uptodate
  File "/Users/Eric/Projects/sagesse-env/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)

UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 3131: invalid start byte

Here is the folder structure:

Screen Shot 2012-12-31 at 1 41 15 PM

The code:

import jinja2
env = jinja2.Environment(extensions=['jsjinja.ext.JsJinjaExtension',],
    loader=jinja2.PackageLoader('sagesse', 'templates'))

env.jsjinja.lib(minified=True)
print env.jsjinja.generate_all()
@syrusakbary
Copy link
Owner

Maybe is because the join (in generate_all method) is not a unicode string... I will fix this soon!

@syrusakbary
Copy link
Owner

I've investigated this bug. Seems to be caused by the codification of the template file.

@syrusakbary
Copy link
Owner

Can you try to render the template via jinja2 only?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants