def storeGridPositions(self, grid, module=None, name='Grid'): if not module: module=grid name=self.getName("ColumnWidths", module, name) colWidths=evalAsPython(self.Read(name, "{}"), {}) for i in range(grid.GetNumberCols()): colname=grid.GetColLabelValue(i) width=grid.GetColSize(i) colWidths[colname] = width self.Write(name, colWidths)
def storeGridPositions(self, grid, module=None, name='Grid'): if not module: module = grid name = self.getName("ColumnWidths", module, name) colWidths = evalAsPython(self.Read(name, "{}"), {}) for i in range(grid.GetNumberCols()): colname = grid.GetColLabelValue(i) width = grid.GetColSize(i) colWidths[colname] = width self.Write(name, colWidths)
def Read(self): result=self.server.connection.SearchOne(self.server.dn, "cn=%s" % self.rdn()) for dn, entry in result: if dn: self.server.adminLdapDn=dn val=entry[self.attrib] config=evalAsPython(val[0]) if config != None: return config else: logger.debug("Couldn't pythonize '%s[0]'", val) return {}
def restoreGridPositions(self, grid, module=None, name='Grid'): if ignoreStoredPositions: return if not module: module=grid name=self.getName("ColumnWidths", module, name) colWidths=evalAsPython(self.Read(name, "{}"), {}) for i in range(grid.GetNumberCols()): colname=grid.GetColLabelValue(i) width=colWidths.get(colname) if width: grid.SetColSize(i, width)
def restoreGridPositions(self, grid, module=None, name='Grid'): if ignoreStoredPositions: return if not module: module = grid name = self.getName("ColumnWidths", module, name) colWidths = evalAsPython(self.Read(name, "{}"), {}) for i in range(grid.GetNumberCols()): colname = grid.GetColLabelValue(i) width = colWidths.get(colname) if width: grid.SetColSize(i, width)
def Read(self, name, default="", obj=None, subname=None): """ Read(name, default="", obj=None) Read a config value <name> config name might be decorated with <obj> module name """ val=super(Config, self).Read(self.Decorate(name, obj, subname)) if not val: return default if not isinstance(default, StringType): py=evalAsPython(val) if py != None: val=py else: logger.debug("Couldn't pythonize '%s'", val) if val == None: return default return val
def Read(self, name, default="", obj=None, subname=None): """ Read(name, default="", obj=None) Read a config value <name> config name might be decorated with <obj> module name """ val = super(Config, self).Read(self.Decorate(name, obj, subname)) if not val: return default if not isinstance(default, StringType): py = evalAsPython(val) if py != None: val = py else: logger.debug("Couldn't pythonize '%s'", val) if val == None: return default return val
def OnPresetSelect(self, evt): preset=self.FilterPreset.strip() if not preset: return query=pgQuery(self.dialog.querypreset_table, self.dialog.server.GetCursor()) query.AddCol('querylimit') query.AddCol('filter') query.AddCol('sort') query.AddCol('display') query.AddCol('sql') query.AddWhere('dbname', self.tableSpecs.dbName) query.AddWhere('tabname', self.tableSpecs.tabName) query.AddWhere('presetname', preset) res=query.Select() for row in res: limit=row['querylimit'] filter=row['filter'] sort=evalAsPython(row['sort']) display=evalAsPython(row['display']) sql=row['sql'] if limit: self.LimitCheck=True self.OnLimitCheck() self.LimitValue=limit else: self.LimitCheck=False if sql: self.dialog.editor.SetText(sql) if sort: sc=self['SortCols'] sc.Clear() cols=self.tableSpecs.colNames[:] for col in sort: if col.endswith(' DESC'): colpure=col[:-5] else: colpure=col if colpure in cols: id=sc.Append(col) sc.Check(id, True) cols.remove(colpure) sc.AppendItems(cols) if display: dc=self['DisplayCols'] dc.Clear() cols=self.tableSpecs.colNames[:] for col in display: if col in cols: id=dc.Append(col) dc.Check(id, True) cols.remove(col) dc.AppendItems(cols) if filter: self.FilterCheck=True self.OnFilterCheck() self.FilterValue.SetText(filter) self.OnFilterValidate(evt) else: self.FilterCheck=False break # only one row, hopefully self.OnPresetChange(evt)