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

[python新手]使用webpy写demo,数据库建表的时候按以前的习惯使用了_id,在python文件中可以,在模板中使用提示:access to attribute '_id' is denied

  •  
  •   laomo · Sep 7, 2013 · 3639 views
    This topic created in 4820 days ago, the information mentioned may be changed or developed.
    5 replies  •  1970-01-01 08:00:00 +08:00
    mengzhuo
    mengzhuo
    Sep 7, 2013 via Android
    1
    不用就好了,啥ORM啊
    laomo
    laomo
    OP
    Sep 7, 2013
    2
    @mengzhuo webpy直接连接mysql,想问下 python 使用数据库建表的时候有什么规范吗,像这个推荐使用“id”,不要使用“_id”?
    chuangbo
    chuangbo
    Sep 7, 2013 via iPhone
    3
    webpy 为了安全禁止在模版里访问一切以下划线开头的变量和方法,因为下划线开头一般属于内部变量或内部方法,暴露不安全,算是一种约定吧
    yangzh
    yangzh
    Sep 7, 2013
    4
    补充楼上,“下划线开头一般属于内部变量或内部方法” 是 python 的约定。
    laomo
    laomo
    OP
    Sep 7, 2013
    5
    @chuangbo @yangzh 感谢2位,语言差异带来的问题,看来python使用数据库的话就是用类似id这种了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   971 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:01 · PVG 06:01 · LAX 14:01 · JFK 17:01
    ♥ Do have faith in what you're doing.