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
Zoom.Quiet
August 18, 2014
Technology
380
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
200
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
180
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
150
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
150
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
150
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
170
PyCon2014China-Zhuhai-jeff
zoomquiet
0
160
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
180
DevFest2014-Zhuhai-Polymer
zoomquiet
0
480
Other Decks in Technology
See All in Technology
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.9k
【CEDEC2026】『GRANBLUE FANTASY: Relink - Endless Ragnarok』のバトル制作事例 ~最高のキャラゲーを目指して~
cygames
PRO
0
250
AIエージェントを前提としたプラットフォーム エンジニアリング:GKEで作るAgent-Ready Golden Path
legalontechnologies
PRO
2
220
TypeScript入門 2026
recruitengineers
PRO
3
560
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
20分でわかるセキュアAPI
nwiizo
2
250
オートロックマンションなのに、各部屋は施錠なし!? 攻撃者が組織内ネットワークで大暴れする理由 / The Front Door Is Locked, but the Rooms Are Wide Open: Why Attackers Move Freely Inside Enterprise Networks
nttcom
1
1.6k
【CEDEC2026】ゲームシナリオライターを支援するAIツール開発の実践 ― 設計とプロンプトの工夫 ―
cygames
PRO
1
790
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
220
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
4
1.5k
MIRU 2026 チュートリアル
keisuke198619
0
890
グローバル基準のSREは、運用現場でどう機能したか:成熟度アセスメントの実践 / SRE NEXT 2026
sorawatanabe
0
190
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
700
From π to Pie charts
rasagy
0
270
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
430
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
380
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.6k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
630
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
520
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
430
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
How to train your dragon (web standard)
notwaldorf
97
6.7k
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.