Python Web Development in Practice cover

Python Web Development in Practice

No rating yet
Word count
616 words
Chapters
15
ISBN
9787121297335

Tags

Summary

Python Web Development in Practice is a hands-on technical book by Dong Weiming, a senior product development engineer at Douban, written for real-world engineering. Rather than serving as a syntax manual for a single framework, the book organizes its content around the lifecycle of a web product—from inception to maturity, from simple to complex, from fundamentals to advanced topics—presenting the complete path of a website project from development to launch.

It begins with technology selection: why use Python for web development, the historical choice between Python 2 and Python 3, and a comparison of mainstream and niche web frameworks along with selection principles. It then moves on to development environment setup, covering VirtualBox, Vagrant, and Docker for building environments, as well as package management and virtual environment practices with pip and the virtualenv family. The main body uses Flask as its throughline, progressing from routing, templates, blueprints, and pluggable views to MySQL, SQLAlchemy ORM, contexts, and LocalProxy, then extending into the Flask ecosystem of extensions such as signals, Flask-Script, Flask-Migrate, Flask-WTF, Flask-Security, Flask-RESTful, and Flask-Admin.

Engineering and production-side content forms the heart of the book: RESTful API design guidelines and Ajax; the WSGI protocol, Nginx deployment, Memcached, Redis, MongoDB, and lessons from large-scale website architecture; Supervisor, Fabric, SaltStack, Ansible, Sentry, and monitoring systems with StatsD/Graphite/Grafana; unittest, doctest, py.test, mock, and continuous integration; Beanstalkd, RabbitMQ, Celery message queues and asynchronous tasks; service-oriented practices with Thrift and Douban's PIDL; log MapReduce with DPark and data reporting with Pandas; as well as IPython, Jupyter Notebook, concurrent programming, advanced Python syntax, and code quality toolchains.

Many of the examples in the book come from real production practices at Douban, making it well suited for connecting fragmented Python knowledge into a complete web engineering skill set.

Editor's review

很多 Python Web 书停在「会用框架写个博客」,这本书问的是另一个问题:一个网站真正上线,需要多少人、多少工具、多少条暗线?作者董伟明在豆瓣负责读书、电影、音乐等产品线,把豆瓣十年里数百名工程师踩过的坑,拎成了十五个章节。 它的稀缺之处在于「全流程」:环境与依赖管理、Flask 主体与扩展生态、REST 设计、Nginx + WSGI 部署、缓存与 NoSQL、进程管理与配置管理、错误收集与监控、测试与持续集成、消息队列与 Celery、服务化、数据处理。这条线走完,读者拿到的不只是 API 手册,而是一张关于「Web 工程长什么样」的地图。 书里不少内容是别处少见的:豆瓣开源的 Libmc 与缓存更新策略、豆瓣 PIDL 服务化实践、用 DPark 做日志 PV/UV 分析、Libmc 与 Flask 的搭配、Kenshin 监控、Flake8 扩展开发等,都带着鲜明的一线气味。也正因如此,它天然适合作为「读完入门书之后怎么办」的那块跳板——先有一门语言的手感,再来这里看工程怎么落地。 需要提醒的是,本书 2016 年出版,示例基于 Python 2/3 共存时代的工具链,pip、virtualenv、Flask 生态、Celery、py.test 等都已迭代多年。把它当架构教科书和选型地图读,价值依旧;把命令逐条照抄,则要配合官方文档做版本替换。

Who it's for

A good fit for

  • 已掌握 Python 基础语法、想系统了解 Web 工程全貌的开发者
  • 用 Flask 做过小项目,想补齐部署、监控、测试链路的后端工程师
  • 以 Python 为工作语言的运维工程师与运维开发工程师
  • 希望了解豆瓣等大型站点架构与选型思路的技术人员
  • 需要一份 Web 项目技术选型参考清单的技术负责人

Not a good fit for

  • 完全没有编程基础的零起点读者,书里默认已有 Python 手感
  • 只想学 Django 官方教程式写法的纯入门者
  • 寻求 2016 年后新版本框架实操(如 Flask 2.x/3.x)的读者
  • 只想找前端或 UI 设计内容的设计师

Reading tips

  1. 先读第1、2章与第15章,建立「选型—环境—项目结构」的整体框架,再回填中间章节。
  2. 第3、4章务必对照代码敲一遍,但把 pip、virtualenv 等命令替换为当前官方推荐写法。
  3. 第6至11章可当作技术选型地图按需查阅,遇到监控、服务化等概念先建立轮廓,用时再深入。
  4. 把书中示例当作工程思路而非可运行代码,配合 GitHub 上的勘误与示例仓库、以及各工具官方文档一起读。

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. Chapter 1 Getting Started with Python Web Development
  2. Chapter 2 Preparing for Web Development
  3. Chapter 3 Flask Web Development
  4. Chapter 4 Advanced Flask Development
  5. Chapter 5 REST and Ajax
  6. Chapter 6 Website Architecture
  7. Chapter 7 System Administration
  8. Chapter 8 Testing and Continuous Integration
  9. Chapter 9 Message Queues and Celery
  10. Chapter 10 Service Orientation
  11. Chapter 11 Data Processing
  12. Chapter 12 Helper Tools
  13. Chapter 13 Concurrent Programming in Python
  14. Chapter 14 Advanced Python
  15. Chapter 15 Web Development Project Practice

FAQ

这本书适合零基础学 Python 的人读吗?
不太适合。书中默认读者已有 Python 语法基础,并直接进入 Flask、ORM、消息队列、部署等话题,没有语言入门铺垫。零基础读者建议先完成一本 Python 入门书并动手写过小脚本,再回来读这本。
这本书主要讲 Django 还是 Flask?
主讲 Flask。第3、4章系统覆盖 Flask 的路由、模板、蓝图、上下文以及 Flask-Script、Flask-Migrate、Flask-Security、Flask-RESTful 等扩展;Django 只在第1章框架选型对比中简要提及。
2016 年出版,现在读会不会过时?
部分内容会过时。书中大量命令基于当年的 Python 2/3 共存工具链,pip、virtualenv、Flask、Celery、py.test 等都已有较大变化。但 Nginx 部署、缓存策略、监控体系、服务化架构、代码质量的思路仍有参考价值,建议当作架构地图读,具体操作对照最新官方文档。
作者的实战背景是什么?
董伟明曾任豆瓣高级产品开发工程师,负责豆瓣读书、电影、音乐、东西等产品线,从 2011 年起接触 Python,经历运维、运维开发到 Web 开发,并给 IPython、pip 及 Python 标准库贡献过代码,书中不少案例来自豆瓣的真实实践。
书中内容有配套资源和勘误吗?
据出版方与公开资料,本书配有勘误表和示例代码,可获取于 GitHub(作者账号 dongweiming)。由于年代较久,示例代码运行前需按当前依赖版本做调整,建议以官方文档为准。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category