V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2013-03-20 23:46:31 +08:00 · 3195 次点击
    这是一个创建于 4055 天前的主题,其中的信息可能已经有所发展或是发生改变。
    譬如验证用户名、Email是否被使用这些...
    3 条回复    1970-01-01 08:00:00 +08:00
    hbc
        1
    hbc  
       2013-03-20 23:49:35 +08:00   ❤️ 1
    forms
    humiaozuzu
        2
    humiaozuzu  
       2013-03-20 23:58:50 +08:00   ❤️ 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
       2013-03-21 00:15:31 +08:00
    @humiaozuzu
    我也是看过wtforms的validator才想到这个问题的。
    感谢XD
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1308 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:55 · PVG 01:55 · LAX 10:55 · JFK 13:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.