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
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
Oracle AI Databaseデータベース・サービス: BaseDB/ExaDB-Dの可用性
oracle4engineer
PRO
1
1k
最新技術に積極チャレンジ!EKS共通基盤のこれまでとこれから
daitak
0
270
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.3k
The Django UUID Story - DjangoCon US 2026
pauloxnet
0
350
Data Hubグループ 紹介資料
sansan33
PRO
0
3.2k
顧客の要望は2次情報である 〜アンテナを張るFDEの構造論〜
noriakioji
5
1.1k
[ホンマでっか SRE] あなたはなぜ SRE に?
_awache
0
550
どんな手を使っても絶対間に合わせるスケジューラ
asari194617
0
1.5k
Point Cloud as a Foreign Language for Multi-modal Large Language Model
takmin
0
340
Guerilla InnerSource in enterprises, during the AI hype
onenashev
PRO
0
130
AWSとGitHub Actionsの責任境界と 組織で安全に使用する取り組み
nealle
1
240
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.3k
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
500
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Docker and Python
trallard
47
4.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Leo the Paperboy
mayatellez
8
2.2k
The untapped power of vector embeddings
frankvandijk
2
1.8k
Embracing the Ebb and Flow
colly
88
5.2k
Product Roadmaps are Hard
iamctodd
55
12k
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.