Python Pyramid 简明教程
Python Pyramid - Cookiecutter
到目前为止,我们已通过手动执行路由配置、添加视图和使用模板构建了 Pyramid 应用程序。 Cookiecutter 提供了一种生成 Pyramid 项目结构的便捷替代方法。它是一个命令行实用程序,使用某些预定义的项目模板。然后可以对项目进行微调,以适应用户可能具有的特定要求。
We have so far built the Pyramid application by manually performing the route configuration, adding the views and using the templates. Cookiecutter offers a convenient alternative to generate a Pyramid project structure. It is a command-line utility that uses certain predefined project templates. The project can then be fine-tuned to accommodate specific requirements that the user may have.
Cookiecutter 创建的 Python 项目是 Python 包。可以进一步定制默认的应用程序逻辑。如此创建的项目结构极其可扩展,易于分发。
The Python project created by Cookiecutter is a Python package. The default application logic can be further customized. The project structure so created is extremely extensible and is easy to distribute.
Cookiecutter 实用程序由 Audrey Feldroy 开发。它适用于 Python >=3.7 版本。可以利用 Python、JavaScript、Ruby、CoffeeScript、RST、Markdown、CSS、HTML 语言或脚本在项目模板中生成项目。Github 托管了许多预建的项目模板,可以使用其中的任何一个。
The Cookiecutter utility is developed by Audrey Feldroy. It works on Python versions >=3.7. The project templates in Python, JavaScript, Ruby, CoffeeScript, languages or RST, Markdown, CSS, HTML scripts can be used to generate a project. Github hosts a number of pre-built project templates, any of which can be used.
由 cookiecutter 模板生成的项目是一个跨平台包。Cookiecutter 项目生成完全自动化,你不必为此编写任何代码。Cookiecutter 命令一经调用,它会读取正在使用的模板,并提示用户为设置参数选择适当的值。首先,使用 PIP 安装程序安装 Cookiecutter。
The project built from cookiecutter template is a cross-platform package. Cookiecutter project generation is completely automated and you don’t have to write any code for it. Once the cookiecutter command is invoked, it reads the template being used and prompts the user to choose appropriate values for the settings parameters. To begin with, install Cookiecutter with PIP installer.
pip install cookiecutter
若要验证是否正确安装了 Cookiecutter,请运行
To verify if Cookiecutter is correctly installed, run
>>> import cookiecutter
>>> cookiecutter.__version__
'1.7.3'