推荐学习书目
› 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
wdg8106
V2EX  ›  Python

关于 web 后台架构问题请教

  •  
  •   wdg8106 · Mar 4, 2016 · 2993 views
    This topic created in 3865 days ago, the information mentioned may be changed or developed.
    我现在做一个电商平台的网站,用的 tornado 框架,之前主要的思路就是先写一个 account 基类,然后不同的角色分别继承这个基类,比如 admin,customer,然后再继承这些子类实现具体的功能对应到每条路由,这样随着功能越来越多,基类函数里面的方法也越加越多,维护起来已经有点麻烦了。
    请问熟悉 tornado 或是一般 web 后台的前辈,后台结构怎么组织会比较好呢。
    或是有什么关于 python web 后台开发相关的书籍推荐下呢,我自己去琢磨下。
    悉心请教,先谢过了~~
    4 replies  •  2016-03-05 09:45:30 +08:00
    surfire91
        1
    surfire91  
       Mar 4, 2016
    感觉这是面向对象的范畴了
    sujin190
        2
    sujin190  
       Mar 4, 2016   ❤️ 1
    一般来说会分层吧,最后业务逻辑写在 RequestHandler 中挂接 url ,数据操作层,服务扩展,通用业务逻辑,业务层组合其他模块实现业务逻辑,每一层又可以单独扩展,比如数据操作层就可以扩展缓存、读写分离等等
    wdg8106
        3
    wdg8106  
    OP
       Mar 5, 2016
    @surfire91 之前看过一点设计模式说,大量的继承不是很好,但是我想不到更好的方法去组织代码...
    wdg8106
        4
    wdg8106  
    OP
       Mar 5, 2016
    @sujin190 多谢指教,暂时是只是做了简单的读写分离,数据操作和业务实际之前都是写在一起的没有区分开。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2126 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 00:39 · PVG 08:39 · LAX 17:39 · JFK 20:39
    ♥ Do have faith in what you're doing.