web2py 与每个环境的配置
web2py 是否支持按环境(开发、登台、生产等)进行开箱即用的配置?类似于 Grails 和 Ruby on Rails。
我阅读/浏览了官方书籍,但找不到任何内容。
Does web2py support, out of the box, configuration per environment (development, staging, production, etc.)? Something similar to Grails and Ruby on Rails.
I read/skimmed through official book but could not find anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
web2py 开发人员认为这不是一个好方法。
我们不相信开发和生产之间有明显的区别。
例如,如果应用程序存在错误,则该错误始终会被记录和记录,从不向用户显示,仅向管理员显示。
此外,web2py 根本没有配置文件,因为应用程序应该是可移植的,而不会破坏设置。
然而,您可以以比 Rails 或 Django 允许的更复杂的方式管理不同的环境。这是因为模型不是导入的,而是根据每个请求执行的。您可以添加自己的条件来在运行时检测环境。例如:
您可以了解如何将其推广到更复杂的条件。当然,您可以将 settings['development']=True 或 False 设置为常量,这与 Rails 等效。
The web2py developers do not believe that is a good approach.
We do not believe in the sharp distinction between development and production.
For eaxmple, if an app has a bug, the bug is always recorded and logged, never shown to the user, only shown to the administrator.
Moreover web2py does not have a configuration file at all because apps should be portable without mangling with settings.
Yet you can manage different environments and in a more sophisticated way than Rails or Django allows. That is because models are not imported but executed at every request. You add your own conditions to detect the environment at runtime. For example:
You can see how to generalize this to more complex conditions. Of course you can make settings['development']=True or False constant, which is the Rails equivalent way of doing it.