本文整理汇总了Python中useless.db.midlevel.StatementCursor.fields方法的典型用法代码示例。如果您正苦于以下问题:Python StatementCursor.fields方法的具体用法?Python StatementCursor.fields怎么用?Python StatementCursor.fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类useless.db.midlevel.StatementCursor
的用法示例。
在下文中一共展示了StatementCursor.fields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BaseRelationalBrowser
# 需要导入模块: from useless.db.midlevel import StatementCursor [as 别名]
# 或者: from useless.db.midlevel.StatementCursor import fields [as 别名]
class BaseRelationalBrowser(ListNoteBook, HasDialogs):
def __init__(self, conn, maintable, pkey):
self.menu = make_menu(['insert', 'update', 'done'], self.pkey_command)
ListNoteBook.__init__(self)
self.conn = conn
self.main = StatementCursor(self.conn)
self.main.set_table(maintable)
self.pkey = pkey
self.dialogs = {}.fromkeys(['insert', 'update', 'delete'])
self.relations = {}
def reset_rows(self):
self.set_rows(self.main.select(order=self.pkey))
self.set_row_select(self.pkey_selected)
def pkey_selected(self, listbox, row, column, event):
print listbox.get_selected_data()[0][0]
def pkey_command(self, menuitem, command):
if command == 'insert':
if self.dialogs['insert'] is None:
dialog = dialogs.Entry('insert a %s' % self.pkey, name='insert')
dialog.set_ok(self.pkey_insert_ok)
dialog.set_cancel(self.destroy_dialog)
self.dialogs['insert'] = dialog
elif command == 'update':
dialogs.Message('need to set update to cascade in db')
elif command == 'done':
value = None
try:
value = self.listbox.get_selected_data()[0][0]
except IndexError:
dialogs.Message('need to select %s first' % self.pkey)
if value is not None:
dialogs.Message('ok, i am done.')
def append_relation(self, table, fields=[], fkeyname=None):
if table not in self.relations:
if not fields:
if fkeyname is None:
fkeyname = self.pkey
fields = [f for f in self.main.fields(table) if f != fkeyname]
if fkeyname is None:
fkeyname = self.pkey
self.relations[table] = fkeyname, fields
else:
raise Error, "relation already exists %s" % table