Differences between revisions 3 and 4
Revision 3 as of 2006-11-14 09:09:48
Size: 873
Editor: ZoomQuiet
Comment:
Revision 4 as of 2009-12-25 07:18:02
Size: 873
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
[[TableOfContents]] <<TableOfContents>>

TurboGears - ToolBox猫步

Contents

  1. catwalk

1. catwalk

  • catwalk 使用 sqlobject 调用数据库的资料,并可以按照数据显示,更新,及添加数据.(有点类似phpadmin)

它的实现方法让我很好奇,所以决定研究一下:)

./toolbox/catwalk/__init__.py
class CatWalk(object):

# ...
browse = Browse()

# ...
def extract_parameters(self,cols,values)
# cols 是数据库表中的各列
# extract_parametes() 把 cols 转化为各种对应类型的对象

# ...

./toolbox/catwalk/browse.py
class Browse(object):
def __getattr__(self,attrib):
"""Delegate basic methods to CatWalk"""
return getattr(self.catwalk,attrib)

# ...
Browse类通过__getattr__方法,得到CatWalk的属性

catwakj (last edited 2009-12-25 07:18:02 by localhost)