2

I am trying to port my existing flask app into google app engine. After a lot of reading and solving issues, I came across a problem I am completely stuck with:

Upon starting the app on my local environment, I get this error message:

Short version:

{% extends "base.html" %}
OSError: [Errno 38] Function not implemented

How can this function not be implemented? It is part of flask/jinja2.

Longer version:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>
ERROR    2013-06-17 14:26:42,772 app.py:1306] Exception on / [GET]
Traceback (most recent call last):
  File "/home/kave/eclipse/F11/Engineering/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/kave/eclipse/F11/Engineering/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/kave/eclipse/F11/Engineering/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/kave/eclipse/F11/Engineering/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/kave/eclipse/F11/Engineering/f11_app/views.py", line 28, in index
    return render_template('index.html')
  File "/home/kave/eclipse/F11/Engineering/flask/templating.py", line 125, in render_template
    context, ctx.app)
  File "/home/kave/eclipse/F11/Engineering/flask/templating.py", line 107, in _render
    rv = template.render(context)
  File "/home/kave/eclipse/F11/Engineering/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/kave/eclipse/F11/Engineering/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/kave/eclipse/F11/Engineering/f11_app/templates/index.html", line 1, in top-level template code
    {% extends "base.html" %}
OSError: [Errno 38] Function not implemented
INFO     2013-06-17 14:26:42,799 server.py:593] default: "GET / HTTP/1.1" 500 291

Any idea what this could be? Many thanks

Houman
  • 64,245
  • 87
  • 278
  • 460
  • Can you show your templates? Looks like you use some function that is not visible from template context – Mikhail Kashkin Jun 17 '13 at 14:36
  • I am using mainly two functions: The classic url_for -> `` and `Flask-Assets` -> `{% assets "f11_js" %} {% endassets %}` – Houman Jun 17 '13 at 14:40
  • I never used assets before, but quick googling point me to this module http://webassets.readthedocs.org/en/latest/integration/jinja2.html make sure that you have installed in your local environment. – Mikhail Kashkin Jun 17 '13 at 14:44
  • @MikhailKashkin That is correct. I am using http://elsdoerfer.name/docs/flask-assets/ which is a wrapper for web-assets. I wonder if this is allowed/compatible with GAE. I think this is not allowed, since Flask-Assets needs to minify javascripts at runtime. GAE won't/can't allow that. So I wonder hwo do GAE users minify their css and js? Starting googeling again... :) – Houman Jun 17 '13 at 14:46
  • I looked into webasset documentation, generally you cann't use it on GAE. From what I understand it tries to compress static files and put result to static folder. On GAE your static files are hosted on different server. So quick solution will be remove `assets` dependensies. You can compress js/css files before upload to GAE. – Mikhail Kashkin Jun 17 '13 at 14:53
  • 1
    yes you are right. I have to scrap it. You can put this as an answer and I tick it. Now I need to find a good way to automate the minifying on GAE. Thanks – Houman Jun 17 '13 at 15:02
  • Aha, sure. Probably you can also rename title of this question to something related to `webassets` (and don't remove `flask` and `gae`). – Mikhail Kashkin Jun 17 '13 at 15:05

1 Answers1

4

This error appeard because Jinja doesn't know about tag assets used in template. Second problem is that project supposed to run on GAE with webasset python library. But by default it is not working, since webassets need output folder to store compressed static files and it is against GAE hosting logic.

Solution is simple: don't use webassets in realtime and compress static files before upload to GAE.

Mikhail Kashkin
  • 1,521
  • 14
  • 29