GAE:Flask / webassets在{%extends" base.html" %} [英] GAE: Flask/webassets throws an expection on {% extends "base.html" %}

查看:215
本文介绍了GAE:Flask / webassets在{%extends" base.html" %}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将现有的应用程序移植到Google应用程序引擎中。经过大量的阅读和解决问题,我遇到了一个问题,我完全坚持:

在我的本地环境启动应用程序时,我收到此错误消息:

短版

  { %扩展base.html%} 
OSError:[Errno 38]函数未执行

这个函数怎么不能实现?这是烧瓶/ jinja2的一部分。



更长的版本:
$ b

 <!DOCTYPE HTML PUBLIC -  // W3C // DTD HTML 3.2 Final // EN> 
< title> 500内部伺服器错误< / title>
< h1>内部伺服器错误< / h1>
< p>服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序出现错误。< / p>
ERROR 2013-06-17 14:26:42,772 app.py:1306] / [GET]
Traceback(最近一次调用最后一次):
文件/ home / kave / eclipse / F11 / Engineering / flask / app.py,第1687行,在wsgi_app
response = self.full_dispatch_request()
文件/ home / kave / eclipse / F11 / Engineering / flask / py,第1360行,在full_dispatch_request
rv = self.handle_user_exception(e)
文件/home/kave/eclipse/F11/Engineering/flask/app.py,第1358行,在full_dispatch_request
rv = self.dispatch_request()
文件/home/kave/eclipse/F11/Engineering/flask/app.py,第1344行,在dispatch_request
返回self.view_functions [rule。 (** req.view_args)
文件/home/kave/eclipse/F11/Engineering/f11_app/views.py,第28行,索引
返回render_template('index.html' )
文件/home/kave/eclipse/F11/Engineering/flask/templating.py,第125行,在render_template
上下文中,ctx.app)
文件/ home / kave /月食/ F11 /工程/ FL请求/ templating.py,第107行,在_render
rv = template.render(context)
文件/home/kave/eclipse/F11/Engineering/jinja2/environment.py,行969 ,在render
中返回self.environment.handle_exception(exc_info,True)
在handle_exception $ b $中的文件/home/kave/eclipse/F11/Engineering/jinja2/environment.py,第742行b重新生成(exc_type,exc_value,tb)
顶级模板代码
{%}中的文件/home/kave/eclipse/F11/Engineering/f11_app/templates/index.html扩展base.html%}
OSError:[Errno 38]函数未实现
INFO 2013-06-17 14:26:42,799 server.py:593]默认值:GET / HTTP / 1.1 500 291

不知道这可能是什么?非常感谢

解决方案

由于Jinja不知道标签 assets 在模板中使用。第二个问题是该项目应该在GAE上运行,使用 webasset python库。但默认情况下,它不工作,因为 webassets 需要输出文件夹来存储压缩的静态文件,而且这是违反GAE托管逻辑。解决方法很简单:不要实时使用 webassets 并在上传到GAE之前压缩静态文件。

p>

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

解决方案

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.

这篇关于GAE:Flask / webassets在{%extends&quot; base.html&quot; %}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆