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
laomo
V2EX  ›  Python

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

  •  
  •   laomo · 2013-09-07 09:13:04 +08:00 · 2885 次点击
    这是一个创建于 3905 天前的主题,其中的信息可能已经有所发展或是发生改变。
    5 条回复    1970-01-01 08:00:00 +08:00
    mengzhuo
        1
    mengzhuo  
       2013-09-07 09:22:31 +08:00 via Android
    不用就好了,啥ORM啊
    laomo
        2
    laomo  
    OP
       2013-09-07 09:26:13 +08:00
    @mengzhuo webpy直接连接mysql,想问下 python 使用数据库建表的时候有什么规范吗,像这个推荐使用“id”,不要使用“_id”?
    chuangbo
        3
    chuangbo  
       2013-09-07 11:54:20 +08:00 via iPhone
    webpy 为了安全禁止在模版里访问一切以下划线开头的变量和方法,因为下划线开头一般属于内部变量或内部方法,暴露不安全,算是一种约定吧
    yangzh
        4
    yangzh  
       2013-09-07 16:15:28 +08:00
    补充楼上,“下划线开头一般属于内部变量或内部方法” 是 python 的约定。
    laomo
        5
    laomo  
    OP
       2013-09-07 16:20:58 +08:00
    @chuangbo @yangzh 感谢2位,语言差异带来的问题,看来python使用数据库的话就是用类似id这种了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1293 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 23:54 · PVG 07:54 · LAX 16:54 · JFK 19:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.