Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ZHGDG_HOA.9_Py的困惑和突破
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Zoom.Quiet
August 18, 2014
Technology
370
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ZHGDG_HOA.9_Py的困惑和突破
https://plus.google.com/events/con5s3ensppq7vtf59aeffme8oo
Zoom.Quiet
August 18, 2014
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
190
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
180
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
150
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
140
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
140
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
160
PyCon2014China-Zhuhai-jeff
zoomquiet
0
150
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
170
DevFest2014-Zhuhai-Polymer
zoomquiet
0
480
Other Decks in Technology
See All in Technology
LayerX コーポレートエンジニアリング室におけるサプライチェーンセキュリティへの取り組み / Supply Chain Security at LayerX Corporate Engineering
yuyatakeyama
3
860
アラート調査向けAIエージェントの本番導入とその後/AI Agents for Alert Investigation: Production Deployment and After
taddy_919
1
240
5分でわかるDuckDB Quack
chanyou0311
4
260
IaC コードを資産へ:AWS CDK 社内ライブラリと横断展開 / aws-summit-japan-2026
gotok365
10
1.6k
時期が悪い!それでもRaspberry Piを買って遊んで活用するには / 20260627-osc26do-rpi-jikigawarui
akkiesoft
1
890
2026-06-24_人とAIの責務分離に基づく開発プロセスの提案.pdf
takahiromatsui
0
240
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
150
AIをフル活用してオンコール機能のプロトタイプを2日で作った話 / Building an AI-Powered On-Call Prototype in Just Two Days
nari_ex
0
140
組織における AI-DLC 実践
askul
0
140
Agile and AI Redmine Japan 2026
hiranabe
4
500
データレイクの「見えない問題」を可視化する
sansantech
PRO
1
220
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
2
430
Featured
See All Featured
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
750
YesSQL, Process and Tooling at Scale
rocio
174
15k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
440
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
The untapped power of vector embeddings
frankvandijk
2
1.8k
A Tale of Four Properties
chriscoyier
163
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
740
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Mind Mapping
helmedeiros
PRO
1
260
Transcript
Python Web Dev 的困惑与突破 http://laiyonghao.com 2014.8.16
who?
who? 赖勇浩
9+年
geme->webgame->web
彩票 电话、自助终端、互联网 创业者
珠三角技术沙龙 创始人、组委
PyCon China 2011、2012、2013
库、框架、程序、插件
库 重用、减量
框架 制定规范
程序 功能、服务
插件 扩展 功能、服务
插件的麻烦 机制、协议
框架对插件机制的支持
None
subapplications
blog.py import web urls = (
"", "reblog", "/(.*)", "blog" ) class reblog: def GET(self): raise web.seeother('/') class blog: def GET(self, path): return "blog " + path app_blog = web.application(urls, locals())
main.py import web import blog urls =
( "/blog", blog.app_blog, "/(.*)", "index" ) class index: def GET(self, path): return "hello " + path app = web.application(urls, locals()) if __name__ == "__main__": app.run()
Blueprints
simple_page.py from flask import Blueprint, render_template, abort from
jinja2 import TemplateNotFound simple_page = Blueprint('simple_page', __name__, template_folder='templates') @simple_page.route('/', defaults={'page': 'index'}) @simple_page.route('/<page>') def show(page): try: return render_template('pages/%s.html' % page) except TemplateNotFound: abort(404)
main.py from flask import Flask from yourapplication.simple_page import
simple_page app = Flask(__name__) app.register_blueprint(simple_page)
INSTALLED_APPS
settings.py INSTALLED_APPS = [ 'anthology.apps.GypsyJazzConfig',
# ... ]
Extensible applications
main.py if __name__ == '__main__':
config.scan('someotherpackage') config.add_view('mypackage.views.myview', name='myview')
Overriding Views def configure_views(config): config.add_view('theoriginalapp.views.theview',
name='theview') --------------------------------------------------- from pyramid.config import Configurator from originalapp import configure_views if __name == '__main__': config = Configurator() config.include(configure_views) config.add_view('theoverrideapp.views.theview', name='theview')
困惑 这么多优秀的框架,为什么 Python不像PHP那么流行?
谁为Python代言?
谁为Python代言?
谁为PHP代言?
None
wordpress的成功 解决方案、插件
大胆的设想 Python缺的不是框架,是解决方 案。
解决方案的特点
解决方案的特点 是个方案 能解决问题(业务需求)
那,来个业务需求? 建个站?
None
None
每当世界陷入混乱…… 新的英雄应运而生。
WA,天生哇哇哇! 但WA不是英雄,只是一个
WA Flask based 动态装卸的插件机制
从业务中来 企业建站 微信公众号建设 电话、互联网销售彩票
setup.py entry_points=""" #
-*- Entry points: -*- [wa.plugin] wa_admin=wa.plugins.admin.pluginimpl:PluginImpl """,
plugin interface class PluginInterface(object): def
__init__(self, config): self._config = config def blueprints(self): ''' Return all blueprints this plugin contained. ''' raise NotImplemented()
get/scan plugin(s) import pkg_resources class PluginFinder(object):
def __init__(self, group, name=None):… def all_plugins(self, filter=None): if filter: for i in pkg_resources.iter_entry_points(self._group, self._name): if filter(i): yield i.load() else: … def plugin(self, prj, name): return pkg_resources.load_entry_point(prj, self._group, name)
plugin impl from flask import Blueprint from wa.plugin
import PluginInterface admin = Blueprint('admin', __name__, static_folder='../static’, template_folder='../templates') class PluginImpl(PluginInterface): def __init__(self, config): PluginInterface.__init__(self, config) def blueprints(self): return [ (index, {'url_prefix':'/index'}), ]
settings.py WA_ENTRY_PLUGIN = 'wa_admin'
实例1
实例2
早期版本 https://github.com/laiyonghao/wa
广告
谢谢大家! end.