当前位置: 首页>>代码示例>>Python>>正文


Python midlevel.StatementCursor类代码示例

本文整理汇总了Python中useless.db.midlevel.StatementCursor的典型用法代码示例。如果您正苦于以下问题:Python StatementCursor类的具体用法?Python StatementCursor怎么用?Python StatementCursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StatementCursor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TraitAssigner

class TraitAssigner(BaseAssigner):
    def __init__(self, app, parent, profile):
        self.profile = Profile(app.conn)
        self.profile.set_profile(profile)
        BaseAssigner.__init__(self, app, parent,
                              name='TraitAssigner', udbuttons=True)
        self.connect(self, SIGNAL('okClicked()'), self.slotLaughAtMe)
        
    def initView(self):
        app = self.app
        self.db = app.db
        self.suite = self.profile.current.suite
        self.traits = StatementCursor(app.conn)
        self.traits.set_table('%s_traits'  % self.suite)
        
        ptrows = self.profile.get_trait_rows()
        pt = [r.trait for r in ptrows]
        all_trows = self.traits.select(fields=['trait'], order=['trait'])
        trows = [r for r in all_trows if r.trait not in pt]
        abox = self.listBox.availableListBox()
        sbox = self.listBox.selectedListBox()
        for row in ptrows:
            r = QListBoxText(sbox, row.trait)
            r.trait = row.trait
        for row in trows:
            r = QListBoxText(abox, row.trait)
            r.trait = row.trait

    def slotLaughAtMe(self):
        sbox = self.listBox.selectedListBox()
        traits = [sbox.item(n).trait for n in range(sbox.numRows())] 
        print 'laughing out loud', traits
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:32,代码来源:profile.py

示例2: __init__

 def __init__(self, conn, table, keyfield):
     StatementCursor.__init__(self, conn, name='AllTraits')
     self.set_table(table)
     self.textfiles = TextFileManager(conn)
     self._keyfield = keyfield
     self._jtable = '%s as s join textfiles as t ' % table
     self._jtable += 'on s.scriptfile = t.fileid' 
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:base.py

示例3: __init__

 def __init__(self, name='Manager'):
     CommandBoxWindow.__init__(self)
     self.cfg = PaellaConfig('database')
     self.dialogs = {}.fromkeys(['dbname', 'suitemanager'])
     apps = ['profiles', 'families', 'suitemanager', 'traitmanager', 'machines',
             'traits', 'tdiff', 'sdiff', 'fdiff', 'default_environment', 'clients',
             'browser']
     self.workspace = {}.fromkeys(apps)
     self.add_menu(dbcommands, 'database', self.database_command)
     self.add_menu(self.workspace.keys(), 'edit', self.edit_command)
     self.set_size_request(150,200)
     self.conn = None
     self.dbname = None
     self.dblist = ScrollCList()
     self.vbox.add(self.dblist)
     conn = PaellaConnection(self.cfg)
     cursor = StatementCursor(conn, 'quicky')
     self.dblist.set_rows(cursor.select(table='pg_database'))
     cursor.close()
     conn.close()
     self.tbar.add_button('profiles', 'profile manager', self.run_tbar)
     self.tbar.add_button('families', 'family manager', self.run_tbar)
     self.tbar.add_button('machines', 'machine manager', self.run_tbar)
     self.tbar.add_button('traits', 'trait manager', self.run_tbar)
     self.tbar.add_button('tdiff', 'template differ', self.run_tbar)
     self.tbar.add_button('sdiff', 'script differ', self.run_tbar)
     self.tbar.add_button('fdiff', 'family differ', self.run_tbar)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:27,代码来源:management.py

示例4: DpkgDb

class DpkgDb(object):
    def __init__(self, name, conn):
        object.__init__(self)
        self.name = name
        self.cmd = StatementCursor(conn, 'DpkgDb')

    def _table(self, table):
        return ujoin(self.name, table)

    def get_available(self, fields, **args):
        return self.cmd.getall(fields, self._table('available'), **args)
    def get_status(self, fields, **args):
        return self.cmd.getall(fields, self._table('status'), **args)

    def create(self, config):
        print 'making status'
        sttable = StatusTable(self._table('status'))
        create_and_insert(self.cmd, sttable, config.get_status())
        print 'making available'
        avtable = AvailableTable(self._table('available'))
        create_and_insert(self.cmd, avtable, config.get_available())
        print 'making filelist'
        fltable = FilelistTable(self._table('files'))
        mk_filelist_table(self.cmd, fltable, config.get_files())
        print 'making conffiles'
        cftable = FilelistTable(self._table('conffiles'))
        mk_filelist_table(self.cmd, cftable, config.get_conffiles())
        print 'making md5sums'
        mdtable = Md5sumsTable(self._table('md5sums'))
        mk_md5sums_table(self.cmd, mdtable, config.get_md5sums())
        print 'making current'
        cutable = Md5sumsTable(self._table('current'))
        mk_current_table(self.cmd, cutable, config.get_files())
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:33,代码来源:dpkgsql.py

示例5: add_new_mount

def add_new_mount(conn, name, mtpt, fstype, opts,
                  dump='0', pass_='0'):
    cursor = StatementCursor(conn)
    data = dict(mnt_name=name, mnt_point=mtpt,
                fstype=fstype, mnt_opts=opts,
                dump=dump)
    data['pass'] = pass_
    cursor.insert(table='mounts', data=data)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:8,代码来源:oldmain.py

示例6: __init__

 def __init__(self, conn):
     StatementCursor.__init__(self, conn)
     self.conn = conn
     self.set_table('profiles')
     self._traits = ProfileTrait(conn)
     self._env = ProfileEnvironment(conn)
     self._pfam = StatementCursor(conn)
     self._pfam.set_table('profile_family')
     self._fam = Family(conn)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:9,代码来源:main.py

示例7: TraitsWindow

class TraitsWindow(DragListWindow):
    def __init__(self, conn, suite, name='TraitsWindow'):
        self.cmd = StatementCursor(conn, name=name)
        self.cmd.set_table(ujoin(suite, 'traits'))
        rows = self.cmd.select()
        packer = lambda x : rowpacker('trait', x)
        DragListWindow.__init__(self, '%s traits' % suite, packer, rows,
                        TARGETS.get('trait', suite), name=name)
        self.set_size_request(400, 300)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:9,代码来源:traitgen.py

示例8: _connect

 def _connect(self, dbname):
     if self.connections.has_key(dbname):
         dialogs.Message('connection already exists for %s' % dbname)
     else:
         conn = BaseConnection(user=self._dbuser, host=self._dbhost,
                               dbname=dbname, passwd=self._dbpasswd)
         self.connections[dbname] = conn
         cursor = StatementCursor(self.connections[dbname])
         rows = cursor.tables()
         tables = ScrollCList(rcmenu=self.table_edit_menu)
         tables.set_rows(rows, columns=['table'])
         self.append_page(tables, dbname)
         self.set_current_page(dbname)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:13,代码来源:base.py

示例9: TextFileBrowser

class TextFileBrowser(ListTextView):
    def __init__(self, conn, name='TextFileBrowser'):
        ListTextView.__init__(self, name=name)
        self.conn = conn
        self.cursor = StatementCursor(self.conn)
        self.cursor.set_table('textfiles')

    def reset_rows(self):
        self.set_rows(self.cursor.select(fields=['fileid']))
        self.set_row_select(self.fileid_selected)

    def fileid_selected(self, listbox, row, column, event):
        pass
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:13,代码来源:database.py

示例10: __init__

 def __init__(self, conn, maintable, reltable, pkey, fields):
     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.rel = StatementCursor(self.conn)
     self.rel.set_table(reltable)
     self.pkey = pkey
     self._fields = fields
     self.fields = [self.pkey] + self._fields
     self.reset_rows()
     self.dialogs = {}.fromkeys(['insert', 'update', 'delete'])
     self.relmenu = make_menu(['insert', 'update', 'delete'], self.relmenu_command)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:14,代码来源:simple.py

示例11: create_database

def create_database(cfg, default_traits):
    dsn = cfg.get_dsn()
    dsn['dbname'] = 'mishmash'
    conn = QuickConn(dsn)
    cmd = StatementCursor(conn, 'create_database')
    for table in cmd.tables():
        cmd.execute('drop table %s' %table)
    start_schema(conn, default_traits)
    make_suites(conn)
    cmd.execute(grant_public(cmd.tables()))
    cmd.execute(grant_public(['current_environment'], 'ALL'))
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:11,代码来源:paellascheme.py

示例12: find_missing_packages

 def find_missing_packages(self, traitxml):
     all_packages = []
     missing = []
     cursor = StatementCursor(self.conn)
     suite = traitxml.suite
     ptable = '%s_packages' % suite
     for package, action in traitxml.packages:
         if package not in all_packages:
             all_packages.append(package)
     for package in all_packages:
         try:
             row = cursor.select_row(table=ptable, clause=Eq('package', package))
         except NoExistError:
             missing.append(package)
     return missing
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:15,代码来源:main.py

示例13: MachinesElement

class MachinesElement(Element):
    def __init__(self, conn, machines=None):
        Element.__init__(self, "machines")
        self.conn = conn
        self.cursor = StatementCursor(self.conn)
        self.machines = []
        if machines is None:
            machines = self.cursor.select(table="machines", order="machine")
        else:
            clause = In("machine", machines)
            machines = self.cursor.select(table="machines", clause=clause, order="machine")
        for m in machines:
            machine_element = MachineElement(m.machine, m.machine_type, m.kernel, m.profile, m.filesystem)
            self.machines.append(machine_element)
            self.appendChild(machine_element)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:15,代码来源:xmlgen.py

示例14: MountsElement

class MountsElement(Element):
    def __init__(self, conn):
        Element.__init__(self, "mounts")
        self.conn = conn
        self.cursor = StatementCursor(self.conn)
        self.cursor.set_table("mounts")
        self.mounts = []
        rows = self.cursor.select(order="mnt_name")
        for r in rows:
            self.append_mount(r.mnt_name, r.mnt_point, r.fstype, r.mnt_opts, r.dump, r["pass"])

    def append_mount(self, mnt_name, mnt_point, fstype, mnt_opts, dump, pass_):
        mnt_element = MountElement(mnt_name, mnt_point, fstype, mnt_opts, dump, pass_)
        self.mounts.append(mnt_element)
        self.appendChild(mnt_element)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:15,代码来源:xmlgen.py

示例15: DisksElement

class DisksElement(Element):
    def __init__(self, conn, disks=None):
        Element.__init__(self, "disks")
        self.conn = conn
        self.cursor = StatementCursor(self.conn)
        if disks is None:
            disks = [r.diskname for r in self.cursor.select(table="disks", order="diskname")]
        self.disks = []
        for diskname in disks:
            disk_element = DiskElement(diskname)
            clause = Eq("diskname", diskname)
            partitions = self.cursor.select(table="partitions", clause=clause, order="partition")
            for p in partitions:
                disk_element.append_partition(p.partition, p.start, p.size, p.id)
            self.disks.append(disk_element)
            self.appendChild(disk_element)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:16,代码来源:xmlgen.py


注:本文中的useless.db.midlevel.StatementCursor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。