前端框架选型是企业提升开发效率与用户体验的关键因素
657
2022-10-21
谈论Python的Pyramid Web应用程序启动器
Talk Python's Pyramid Web App Starter
An opinionated Cookiecutter template for creating Pyramid web applications starting way further down the development chain. This cookiecutter template will create a new Pyramid web application with the following benefits and more:
Factored and organized: This code was generalized out of a large, professional web applicationMaster layout template: Comes pre-configured with a master layout template. Navigation, CSS, js, etc is factored into a single template file and is reused across all viewsChameleon language: This template uses the chameleon template language (the cleanest template language for Python - we did say opinionated right?)Pyramid Handlers: Code is factored into handler / controller classes. You have the full power of object-oriented programming immediately availableSecure user management: The app comes with full user management. Users can register, log in and out, and reset passwords. We use the passlib package for secure user storage using best practices SQLAlchemy data access: Comes with SQLAlchemy ORM preconfigured using sqliteBootstrap and modern design: As you can see from the screenshot below, the app comes with bootstrap and fontawesome. It uses a free, open-source theme and images used under CC-Attribution.Logging with LogBook: A logging system for Python that replaces the standard library’s logging module. It was designed with both complex and simple applications in mind and the idea to make logging funRuntime error monitoring with Rollbar: Rollbar adds runtime notifications and detailed error tracking and it comes pre-configured in this templateMailing list integration: Comes with Mailchimp integration. Just enter your API key and list ID to start collecting and managing users for your mailing listOutbound email with templates: The app has a set of static HTML files with placeholders that are loaded by the outbound email system and populated with user dataBower static resource management: Most templates are based on out-of-date files (css templates, js, etc.). This template uses bower for it's static files. This means a single CLI command will get you the latest everything.Fast pages that are never stale: Every static resource is referenced with our own cache busting system. This means you can use extremely aggressive caching for performance on static files yet they immediately invalidate upon changesBuilt-in CMS: The site supports loading landing pages and other static content from the database while still supporting the common look and feel.Comes with an entire online course: This template is built from the final project in Python for Entrepreneurs, a 20 hour course on building professional web apps in Python and Pyramid from Talk Python Training
What you get
Here's a screenshot of the home page. You also get much more as you navigate other sections of the web app.
Here's the project folder structure:
Usage
To use this template you just run the single command:
cookiecutter https://github.com/mikeckennedy/cookiecutter-pyramid-talk-python-starter
Answer the cookiecutter prompts (notice how smart defaults are suggested anywhere possible):
[Note: Once you have run cookiecutter with the full URL, it is cached locally and can be run with just the template name.]
You will need to install Cookiecutter first:
pip3 install --user cookiecutter
(Use pip command for Python 3 on Windows)
Compare to Pyramid's standard templates
The Pyramid web framework offers a handful of nice starter templates. They have recently moved to Cookiecutter as the primary way to scaffold new Pyramid web applications.
There are a few existing templates but they are built to be bare bones and less opinionated so they are broadly applicable. They are:
pyramid-cookiecutter-starter
URL dispatch for routing and either Jinja2, Chameleon, or Mako for templating
pyramid-cookiecutter-alchemy
SQLite for persistent storage, SQLAlchemy for an ORM, URL dispatch for routing, and Jinja2 for templating.
pyramid-cookiecutter-zodb
ZODB for persistent storage, traversal for routing, and Chameleon for templating
Pyramid cookiecutters released under the Pylons Project differ from each other on a number of axes:
the persistence mechanism they offer (no persistence mechanism, SQLAlchemy with SQLite, or ZODB)the mechanism they use to map URLs to code (URL dispatch or traversal)templating libraries (Jinja2, Chameleon, or Mako)
Want to go deeper? Take the course
If this web app is interesting to you and you'd like to dig way deeper into all of these topics, we have a 20-hour online course that goes into detail in each area of the app and more.
Visit the course page
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~