Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
160
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
190
DevFest2014-Zhuhai-Polymer
zoomquiet
0
490
Other Decks in Technology
See All in Technology
OpenTelemetryのメトリクスをCloudWatchに送ってPromQLで見てみた
ota1022
0
130
Screen Lens - 今見てる画面を翻訳する
komagata
0
260
アプリログインとWeb認証基盤をつなぐ ASWebAuthenticationSession 作法
shimastripe
1
250
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
290
AI時代、データエンジニアが一番おもろい
genshun9
0
300
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
150
AIオーケストレーションを活用した 開発ワークフローの設計と実践
bqnq
0
160
薬剤師(ドメインエキスパート)と一緒に育てる薬局向けAIアシスタント
kakehashi
PRO
2
160
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
260
module Synths; end
asonas
1
130
消えない 動かない 効かない
yama3133
1
120
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
660
Featured
See All Featured
Visualization
eitanlees
152
17k
Are puppies a ranking factor?
jonoalderson
2
3.9k
Raft: Consensus for Rubyists
vanstee
141
7.7k
Scaling GitHub
holman
464
140k
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Color Theory Basics | Prateek | Gurzu
gurzu
0
460
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Navigating Weather and Climate Data
rabernat
0
510
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
New Earth Scene 8
popppiees
3
2.6k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
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.