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


Python midlevel.StatementCursor类代码示例

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


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

示例1: __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']
     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,代码行数:26,代码来源:management.py

示例2: 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,代码来源:machine.py

示例3: 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

示例4: __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,代码来源:profile.py

示例5: PaellaProfiles

class PaellaProfiles(Element):
    def __init__(self, conn):
        Element.__init__(self, 'profiles')
        self.conn = conn
        self.stmt = StatementCursor(self.conn)
        self.env = ProfileEnvironment(self.conn)
        self.profiletraits = ProfileTrait(self.conn)
        self._profiles = {}
        for row in self.stmt.select(table='profiles', order='profile'):
            self._append_profile(row.profile, row.suite)
                
    def _append_profile(self, profile, suite):
        element = self.export_profile(profile, suite)
        self._profiles[profile] = element
        self.appendChild(self._profiles[profile])

    def export_profile(self, profile, suite=None):
        if suite is None:
            row = self.stmt.select_row(table='profiles',clause=Eq('profile', profile))
            suite = row['suite']
        suite = str(suite)
        profile = str(profile)
        self.env.set_profile(profile)
        element = ProfileElement(profile, suite)
        element.append_traits(self.profiletraits.trait_rows(profile))
        element.append_variables(self.env.get_rows())
        return element

    def insert_profile(self, profile):
        idata = {'profile' : profile.name,
                 'suite' : profile.suite}
        self.stmt.insert(table='profiles', data=idata)
        idata = {'profile' : profile.name,
                 'trait' : None,
                 'ord' : 0}
        for trait, ord in profile.traits:
            print trait, ord
            idata['trait'] = trait
            idata['ord'] = ord #str(ord)
            self.stmt.insert(table='profile_trait', data=idata)
        idata = {'profile' : profile.name,
                 'trait' : None,
                 'name' : None,
                 'value': None}
        for trait, name, value in profile.vars:
            idata['trait'] = trait
            idata['name'] = name
            idata['value'] = value
            self.stmt.insert(table='profile_variables', data=idata)

    def export_profiles(self, path):
        rows = self.stmt.select(fields='profile', table='profiles', clause=None)
        for row in rows:
            self.write_profile(row.profile, path)
        
    def write_profile(self, profile, path):
        xmlfile = file(join(path, '%s.xml' % profile), 'w')
        data = self.export_profile(profile)
        data.writexml(xmlfile, indent='\t', newl='\n', addindent='\t')
        xmlfile.close()
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:60,代码来源:profile.py

示例6: __init__

 def __init__(self, conn):
     self.conn = conn
     self.main = StatementCursor(self.conn, 'RepositoryMain')
     self.repos = StatementCursor(self.conn, 'Repository')
     self.repos.set_table('repository')
     self.sources = StatementCursor(self.conn, 'Sources')
     self.sources.set_table('sources')
     self.release = ReleaseCursor(self.conn)
     self.repsections = StatementCursor(self.conn, 'repos_section')
     self.repsections.set_table('repos_section')
     self.__init_db__()
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:11,代码来源:repos_base.py

示例7: _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,代码行数:12,代码来源:base.py

示例8: 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

示例9: __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,代码来源:base.py

示例10: 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

示例11: start_schema

def start_schema(conn):
    cursor = StatementCursor(conn, 'start_schema')
    tables, mapping = primary_tables()
    map(cursor.create_table, tables)
    priorities_table = mapping['priorities']
    insert_list(cursor, priorities_table.name, 'priority', PRIORITIES)
    insert_list(cursor, 'scriptnames', 'script', SCRIPTS)
    cursor.execute(grant_public([x.name for x in tables]))
    cursor.execute(grant_public(['current_environment'], 'ALL'))
    cursor.execute(grant_public(['partition_workspace'], 'ALL'))
    cursor.execute(plpgsql_delete_profile)
    cursor.execute(plpgsql_delete_trait)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:12,代码来源:paellascheme.py

示例12: __init__

 def __init__(self, conn):
     object.__init__(self)
     self.conn = conn
     self.cursor = StatementCursor(self.conn)
     self.current = None
     self.parent = SimpleRelation(self.conn, 'family_parent', 'family')
     self.env = Environment(self.conn, 'family_environment', 'family')
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:family.py

示例13: Family

class Family(object):
    def __init__(self, conn):
        object.__init__(self)
        self.conn = conn
        self.cursor = StatementCursor(self.conn)
        self.current = None
        self.parent = SimpleRelation(self.conn, 'family_parent', 'family')
        self.env = Environment(self.conn, 'family_environment', 'family')
        
    def set_family(self, family):
        self.current = family
        self.parent.set_current(family)
        self.env.set_main(family)
        
    def add_family(self, family, type='general'):
        pass

    def get_families(self, families=[]):
        rows = self.cursor.select(table='family_parent')
        graph = kjGraph([(r.family, r.parent) for r in rows])
        dfamilies = Set()
        for fam in families:
            dfamilies |= Set([fam]) | Set(graph.reachable(fam).items())
        return dfamilies

    def parents(self, family=None):
        if family is None:
            family = self.current
        self.parent.set_clause(family)
        rows = self.parent.cmd.select(fields=['parent'], order='parent')
        self.parent.reset_clause()
        return [x.parent for x in rows]
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:32,代码来源:family.py

示例14: DisksElement

class DisksElement(Element):
    def __init__(self, conn):
        Element.__init__(self, 'disks')
        self.conn = conn
        self.cursor = StatementCursor(self.conn)
        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

示例15: __set_suite_cursors__

 def __set_suite_cursors__(self, suite):
     self.traits = StatementCursor(self.conn, 'traits')
     self.traits.set_table(ujoin(suite, 'traits'))
     self.traitparent = TraitParent(self.conn, suite)
     self.traitpackage = TraitPackage(self.conn, suite)
     self.traittemplate = TraitTemplate(self.conn, suite)
     self.traitdebconf = TraitDebconf(self.conn, suite)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:profile.py


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