推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
JunyuMu
V2EX  ›  Python

web 应用如何支持插件?

  •  
  •   JunyuMu ·
    JunyuMu · Feb 10, 2016 via Android · 3285 views
    This topic created in 3884 days ago, the information mentioned may be changed or developed.
    最近在用 Flask 写一个 web 应用,想让它支持插件拓展,就类似于 WordPress 那样的,但是没有头绪。求指点。😭
    7 replies  •  2016-02-25 21:49:06 +08:00
    lizheming
        1
    lizheming  
       Feb 11, 2016   ❤️ 1
    就是挂钩子,在代码的每个地方标识上一个动作,然后插件对这个动作进行登记注册,动作名为键,插件对应的主函数为值。程序运行到这的时候查找这个动作有没有对应注册过的函数,如果有的话就依顺序运行就好了。
    JunyuMu
        2
    JunyuMu  
    OP
       Feb 11, 2016
    @lizheming 谢谢。之前都没有接触过钩子的概念,所以不是很清楚。
    sheng9632
        3
    sheng9632  
       Feb 11, 2016   ❤️ 1
    @JunyuMu
    wordpress 是用钩子实现的,可以看看 eventDispatcher(应该没错,嗯 是的)
    phithon
        4
    phithon  
       Feb 12, 2016
    关注一下,有没有谁用 flask 的做过类似项目,项目可以加载插件什么的
    glasslion
        5
    glasslion  
       Feb 12, 2016
    julyclyde
        6
    julyclyde  
       Feb 18, 2016
    前几周分析了一个叫 sentry 的软件,学习了它的插件机制
    http://julyclyde.org/?p=490
    JunyuMu
        7
    JunyuMu  
    OP
       Feb 25, 2016
    @phithon 同求啊 T T
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   908 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 19:59 · PVG 03:59 · LAX 12:59 · JFK 15:59
    ♥ Do have faith in what you're doing.