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

用Flask做注册功能,用户验证应该放在forms.py里面还是应该放在views.py里面?

  •  
  •   scarlex ·
    scarletsky · Mar 20, 2013 · 4258 views
    This topic created in 4942 days ago, the information mentioned may be changed or developed.
    譬如验证用户名、Email是否被使用这些...
    3 replies  •  1970-01-01 08:00:00 +08:00
    hbc
        1
    hbc  
       Mar 20, 2013   ❤️ 1
    forms
    humiaozuzu
        2
    humiaozuzu  
       Mar 20, 2013   ❤️ 2
    1 在 form 里面,好处是逻辑很清晰,但是会多做一次查询
    详细的见 wtforms 的 inline validator http://wtforms.simplecodes.com/docs/1.0.3/forms.html#in-line-validators

    2 在 dblogic 层做,利用数据库本身的特性,效率会得到提升。在 dblogic 层抛异常,view 里面捕捉异常返回错误

    最近和 @notedit 讨论过,目测没有误人子弟。。。
    scarlex
        3
    scarlex  
    OP
       Mar 21, 2013
    @humiaozuzu
    我也是看过wtforms的validator才想到这个问题的。
    感谢XD
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2419 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:35 · PVG 16:35 · LAX 01:35 · JFK 04:35
    ♥ Do have faith in what you're doing.