コード例 #1
0
ファイル: Mailbox.py プロジェクト: rogeriofalcone/admin4
 def Check(self):
     ok = self.CheckValid(True, self.MailboxName,
                          xlt("Name cannot be empty"))
     ok = self.CheckValid(ok,
                          self.MailboxName.find('@') < 0,
                          xlt("Name may not include the @ character"))
     return ok
コード例 #2
0
  def OnAddMember(self, evt):
    lv=self['Members']

    res=self.GetServer().SearchSubConverted("(uid=*)", "uid cn displayName")

    candidates=[]
    for _dn, info in res:
      uid=info['uid'][0]
      name=info.get("displayName")
      if not name:
        name=info.get('cn')
      if name:
        name=name[0]
      if lv.FindItem(-1, uid) < 0:
        if uid == name:
          candidates.append(uid)
        else:
          candidates.append("%s %s" % (uid, name))
    candidates.sort(key=unicode.lower)
    
    dlg=wx.MultiChoiceDialog(self, xlt("Add member"), xlt("Add member to group"), candidates)
    if dlg.ShowModal() == wx.ID_OK:
      uids=[]
      for row in range(lv.GetItemCount()):
        uids.append(lv.GetItemText(row, 0))
      for i in dlg.GetSelections():
        cr=candidates[i].split()
        uid=cr[0]
        row=lv.AppendItem(-1, uid)
        lv.SetStringItem(row, 1, " ".join(cr[1:]))
        lv.SetItemData(row, -1)
        uids.append(uid)

      self.dialog.SetValue(self.memberUidOid, uids, self)
コード例 #3
0
ファイル: LoggingDialog.py プロジェクト: andreas-p/admin4
  def __init__(self, parentWin):
    adm.Dialog.__init__(self, parentWin, None, "LoggingDialog")
    _TimerOwner.__init__(self)
    
    self.Bind(wx.EVT_CLOSE, self.OnClose)
    self.Bind("Apply", self.OnApply)

    nb=self['notebook']
    panel=LoggingPanel(self, nb)
    nb.InsertPage(0, panel, xlt(panel.panelName))
    panel=QueryLoggingPanel(self, nb)
    nb.InsertPage(1, panel, xlt(panel.panelName))
    self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChange)
    
    self['LogLevelFile'].SetRange(0, len(self.loglevels)-1)
    self['LogLevelQuery'].SetRange(0, len(self.querylevels)-1)
    self.Bind("LogLevelFile LogLevelQuery", wx.EVT_COMMAND_SCROLL, self.OnLevel)

    self.LogLevelFile=self.loglevels.index(logger.loglevel)
    self.LogLevelQuery=self.querylevels.index(logger.querylevel)
    self.LogFileLog = logger.logfile
    self.LogFileQuery=logger.queryfile
    self.OnLevel()

    ah=AcceleratorHelper(self)
    ah.Add(wx.ACCEL_CTRL, 'C', self.BindMenuId(self.OnCopy))
    ah.Realize()
コード例 #4
0
ファイル: frame.py プロジェクト: sarkartanzil/admin4
 def registerToggles(self, toolbar, statusbar):
   """ have toolbar and/or statusbar toggle in viewmenu """
   
   if toolbar:  
     self.viewmenu.AddCheck(self.OnToggleToolBar, xlt("Toolbar"), xlt("Show or hide tool bar"), adm.config.Read("ToolbarShown", True, self))
   if statusbar:
     self.viewmenu.AddCheck(self.OnToggleStatusBar, xlt("Statusbar"), xlt("Show or hide status bar"), adm.config.Read("StatusbarShown", True, self))
コード例 #5
0
        def Check(self):
            for panel in self.panels:
                if hasattr(panel, "Check"):
                    if not panel.Check():
                        return False

            ok = True
            ok = self.CheckValid(ok, len(self.objectClasses),
                                 xlt("At least one objectClass needed."))
            if not self.node:
                rdn = self.rdn
                ok = self.CheckValid(ok, rdn, xlt("RDN needs to be given"))
                if rdn:
                    ok = self.CheckValid(ok,
                                         len(rdn.split('=')) == 2,
                                         xlt("Invalid RDN format: attr=value"))

            for attr in self.attribs.values():
                ok = self.CheckValid(
                    ok, not attr.empty
                    or attr.schema.syntax in ldapSyntax.EmptyAllowed,
                    xlt("Attribute \"%s\" may not be empty") % attr.name)
                if not ok:
                    #          logger.debug("non-empty: %s", attr.schema.syntax)
                    return False
            return ok
コード例 #6
0
class Schema(DatabaseObject):
    typename = xlt("Schema")
    shortname = xlt("Schema")
    refreshOid = "nsp.oid"

    @staticmethod
    def InstancesQuery(parentNode):
        sql = pgQuery("pg_namespace nsp")
        sql.AddCol(
            "nsp.oid, nspacl, nspname as name, pg_get_userbyid(nspowner) AS owner, description"
        )
        sql.AddLeft("pg_description des ON des.objoid=nsp.oid")
        sql.AddWhere("(nsp.oid=2200 OR nsp.oid > %d)" %
                     parentNode.GetServer().GetLastSysOid())
        sql.AddOrder("nspname")
        return sql

    def GetIcon(self):
        icons = []
        icons.append("Schema")
        oid = self.GetOid()
        if oid <= self.GetServer().GetLastSysOid() and oid != 2200:
            icons.append('pg')
        return self.GetImageId(icons)

    def GetProperties(self):
        if not len(self.properties):

            self.properties = [(xlt("Name"), self.name),
                               ("OID", self.info['oid']),
                               (xlt("Owner"), self.info['owner']),
                               (xlt("ACL"), self.info['nspacl'])]

            self.AddProperty(xlt("Description"), self.info['description'])
        return self.properties
コード例 #7
0
ファイル: Zone.py プロジェクト: andreas-p/admin4
 def Check(self):
   ok=True
   if not self.rds:
     ok=self.CheckValid(ok, self.Recordname, xlt(("Enter %s") % self.RecordNameStatic))
     if self.rdtype == rdatatype.CNAME:
       foundSame=self.node.cnames.get(self.Recordname)
       foundOther=self.node.hosts4.get(self.Recordname)
       if not foundOther:
         foundOther=self.node.hosts6.get(self.Recordname)
       if not foundOther:
         foundOther=self.node.ptrs.get(self.Recordname)
       if not foundOther:
         # SIG, NXT and KEY allowed
         foundOther=self.node.others.get(self.Recordname)
           
       ok=self.CheckValid(ok, not foundOther, xlt("CNAME collides with existing record"))
     else:
       foundSame=self.node.others.get(self.Recordname, {}).get(self.rdtype)
       # SIG, NXT and KEY: CNAME allowed
       foundCname=self.node.cnames.get(self.Recordname)
       ok=self.CheckValid(ok, not foundCname, xlt("Record collides with existing CNAME record"))
     ok=self.CheckValid(ok, not foundSame, xlt("Record of same type and name already exists"))
       
   ok=self.CheckValid(ok, timeToFloat(self.TTL), xlt("Please enter valid TTL value"))
   return ok
コード例 #8
0
ファイル: page.py プロジェクト: sarkartanzil/admin4
 def OnRefreshRate(self, evt=None):
   rr=self.RefreshRate
   if rr == self['RefreshRate'].GetMax():
     rr=0
     self.RefreshStatic=xlt("stopped")
   else:
     if rr > 19:
       rr = (rr-19)*300 +300
     elif rr > 15:
       rr = (rr-15)*60 + 60
     elif rr > 12:
       rr = (rr-12)*10 + 30
     elif rr > 8:
       rr = (rr-8)*5 +10
     elif rr > 6:
       rr = (rr-6)*2 +6
     
     if rr < 60:
       self.RefreshStatic=xlt("%d sec") % rr
     else:
       self.RefreshStatic=xlt("%d min") % (rr/60)
   if not evt or evt.GetEventType() == wx.wxEVT_SCROLL_THUMBRELEASE:
     adm.config.Write("RefreshRate", rr, self, self.panelName)
     self.refreshTimeout=rr
     self.StartTimer()    
コード例 #9
0
ファイル: ServerPages.py プロジェクト: rogeriofalcone/admin4
    def Check(self):
        if self.type == 'bool':
            self['value'].SetLabel(self.GetVal())
        ok = True
        ok = self.CheckValid(ok, self.canWrite,
                             xlt("Can save to instrumented servers only."))
        ok = self.CheckValid(ok, self.vals['context'] != 'internal',
                             xlt("Internal setting; cannot be edited."))

        try:
            minVal = float(self.vals['min_val'])
            try:
                ok = self.CheckValid(
                    ok,
                    float(self.value.GetValue()) >= minVal,
                    xlt("Must be %s or more") % self.vals['min_val'])
            except:
                ok = False
        except:
            pass

        try:
            maxVal = float(self.vals['max_val'])
            try:
                ok = self.CheckValid(
                    ok,
                    float(self.value.GetValue()) <= maxVal,
                    xlt("Must be %s or less") % self.vals['max_val'])
            except:
                ok = False
        except:
            pass

        return ok
コード例 #10
0
ファイル: Table.py プロジェクト: ed00m/admin4
  def Display(self, node, _detached):
    if node != self.lastNode:
      def _typename(row):
        n= [row['typename'], ['NULL', 'NOT NULL'][row['attnotnull']] ]
        default=row['adsrc']
        if default != None:
          if default == "nextval('%s_%s_seq'::regclass)" % (node.info['relname'], row['attname']):
            if n[0] == "integer":
              n[0] = "serial"
            elif n[0] == "bigint":
              n[0] = "bigserial"
            else:
              logger.debug("Unknown serial type %s for %s", n[0], default)
              n.append("DEFAULT")
              n.append(default)
          else:
            n.append("DEFAULT")
            n.append(default)
        return "  ".join(n)

      self.lastNode=node
      self.control.ClearAll()
      
      add=self.control.AddColumnInfo
      add(xlt("Name"), 20,         colname='attname')
      add(xlt("Type"), -1,         proc=_typename)
      self.RestoreListcols()

      node.populateColumns()
      icon=node.GetImageId('column')
      values=[]
      for col in node.columns:
        values.append( (col, icon))
      self.control.Fill(values, 'attname')
コード例 #11
0
 def OnAddGroup(self, evt):
     dlg = wx.TextEntryDialog(self, xlt("Enter group name"),
                              xlt("New server group"))
     rc = dlg.ShowModal()
     if rc == wx.ID_OK:
         groupName = dlg.GetValue()
         self.addGroup(groupName)
コード例 #12
0
ファイル: Zone.py プロジェクト: andreas-p/admin4
  def Display(self, node, _detached):
    if not node or node != self.lastNode:
      self.storeLastItem()
      if not self.prepare(node):
        return
      node=self.lastNode
      self.control.AddColumn(xlt("Name"), 10)
      self.control.AddColumn(xlt("Type"), 5)
      self.control.AddColumn(xlt("Values"), 40)
      self.control.AddColumn(xlt("TTL"), 5)
      self.RestoreListcols()

      for other in sorted(node.others.keys()):
        rdss=node.others[other]
        for rds in rdss.values():
          icon=node.GetImageId('other')
          dnstype=rdatatype.to_text(rds.rdtype)
          name=other
          for rd in rds:
            values=[]
            for slot in rd.__slots__:
              value=eval("rd.%s" % slot)
              if isinstance(value, list):
                if len(value) > 1:
                  logger.debug("Value list dimensions > 1: %s", str(value))
                value=" ".join(value)
                
              values.append("%s=%s" % (slot, value))
            self.control.AppendItem(icon, [name, dnstype, ", ".join(values), floatToTime(rds.ttl, -1)])
            icon=0
            name=""
            dnstype=""
      self.restoreLastItem()
コード例 #13
0
ファイル: Table.py プロジェクト: ed00m/admin4
  def Display(self, node, _detached):
    if node != self.lastNode:
      self.lastNode=node
      
      def _getDetails(row):
        info=[]
        if row['type'] == 'primarykey':
            info.append('PRIMARY')
        elif row['type'] == 'index':
          if row['indisunique']:
            info.append('UNIQUE')
        elif row['type'] == 'foreignkey':
          info.append(row['reftable'])
          info.append("(%s)" % ",".join(row['refcolnames']))
        elif row['type'] == 'check':
          pass
        return "".join(info)
      
      add=self.control.AddColumnInfo
      add(xlt("Name"), 10,         colname='fullname')
      add(xlt("Columns"), 15,      colname='colnames', proc=lambda x: ", ".join(x))
      add(xlt("Details"), 15,      proc=_getDetails)
      add(xlt("Description"), -1,  colname='description')
      self.RestoreListcols()

      node.populateConstraints()
      
      values=[]
      for con in node.constraints:
        icon = node.GetImageId(con['type'])
        values.append( (con, icon) )
      self.control.Fill(values, 'fullname')
コード例 #14
0
ファイル: Samba.py プロジェクト: sarkartanzil/admin4
  def Go(self):
    self.initDomains()

    SpecificEntry.Go(self)
    if not self.sambaGroupMapping:
      return

    if self.dialog.node and self.sambaSid:
      ss=self.sambaSid.split('-')
      self.sambaRid = ss[7]
      self.sambaDomainSid='-'.join(ss[:-1])
      self.sambaDomainName = self.sambaDomainSid
      self.EnableControls("sambaDomainSid sambaRid ridGen", False)
      wkg=smbWellKnownGroups.get(self.sambaRid)
      if wkg:
        self.GroupTypeLabel=xlt("Well Known Group")
        self.GroupType=xlt(wkg)
      else:
        sgt=smbGroupTypes.get(self.dialog.GetAttrValue("sambaGroupType"))
        if sgt:
          self.GroupType=xlt(sgt)
        else:
          self.GroupType=xlt("Domain Group")
    else:
      self.dialog.SetValue("sambaGroupType", 2)
      self.GroupType=xlt("Domain Group")

    self.OnChangeDomain()
コード例 #15
0
ファイル: Zone.py プロジェクト: sarkartanzil/admin4
    def Check(self):
        ok = True
        if not self.rds:
            ok = self.CheckValid(ok, self.Recordname,
                                 xlt(("Enter %s") % self.RecordNameStatic))
            if self.rdtype == rdatatype.CNAME:
                foundSame = self.node.cnames.get(self.Recordname)
                foundOther = self.node.hosts4.get(self.Recordname)
                if not foundOther:
                    foundOther = self.node.hosts6.get(self.Recordname)
                if not foundOther:
                    foundOther = self.node.ptrs.get(self.Recordname)
                if not foundOther:
                    # SIG, NXT and KEY allowed
                    foundOther = self.node.others.get(self.Recordname)

                ok = self.CheckValid(
                    ok, not foundOther,
                    xlt("CNAME collides with existing record"))
            else:
                foundSame = self.node.others.get(self.Recordname,
                                                 {}).get(self.rdtype)
                # SIG, NXT and KEY: CNAME allowed
                foundCname = self.node.cnames.get(self.Recordname)
                ok = self.CheckValid(
                    ok, not foundCname,
                    xlt("Record collides with existing CNAME record"))
            ok = self.CheckValid(
                ok, not foundSame,
                xlt("Record of same type and name already exists"))

        ok = self.CheckValid(ok, timeToFloat(self.TTL),
                             xlt("Please enter valid TTL value"))
        return ok
コード例 #16
0
ファイル: Table.py プロジェクト: sarkartanzil/admin4
    def Display(self, node, _detached):
        if node != self.lastNode:
            self.lastNode = node

            def _getDetails(row):
                info = []
                if row['type'] == 'primarykey':
                    info.append('PRIMARY')
                elif row['type'] == 'index':
                    if row['indisunique']:
                        info.append('UNIQUE')
                elif row['type'] == 'foreignkey':
                    info.append(row['reftable'])
                    info.append("(%s)" % ",".join(row['refcolnames']))
                elif row['type'] == 'check':
                    pass
                return "".join(info)

            add = self.control.AddColumnInfo
            add(xlt("Name"), 10, colname='fullname')
            add(xlt("Columns"),
                15,
                colname='colnames',
                proc=lambda x: ", ".join(x))
            add(xlt("Details"), 15, proc=_getDetails)
            add(xlt("Description"), -1, colname='description')
            self.RestoreListcols()

            node.populateConstraints()

            values = []
            for con in node.constraints:
                icon = node.GetImageId(con['type'])
                values.append((con, icon))
            self.control.Fill(values, 'fullname')
コード例 #17
0
class Favourites(adm.Node):
  typename=xlt("Favourites")
  shortname=xlt("Favourites")
  defaultname=xlt("unsorted")
  def __init__(self, parentNode):
    super(Favourites, self).__init__(parentNode, xlt(Favourites.defaultname))
    
  @staticmethod
  def GetInstances(parentNode):
    if parentNode.GetServer().fav_table:
      return [Favourites(parentNode)]
    return None

  def DoRefresh(self):
    for treename, fil in self.treeitems.items():
      tree=adm.trees[treename]
      favitem=fil[0] # tree.Collapse(favitem)
      for child in self.childnodes[:]:
        itemlist=child.treeitems.get(treename)
        if itemlist:
          for item in itemlist:
            if tree.IsChild(item, favitem):
              tree.DeleteItem(item)
        self.removeChild(child)
      self.properties=[]
      
  def GetProperties(self):
    self.properties=[]
    self.PopulateChildren()
    for child in self.childnodes:
      self.properties.append( (child.name, child.comment, child.GetIcon()))
    return self.properties
コード例 #18
0
  def executeQuery(self, sql):
    self.output.SetEmpty()
    self.worker=None
    
    self.EnableMenu(self.datamenu, self.OnRefresh, False)
    self.EnableMenu(self.datamenu, self.OnCancelRefresh, True)
    
    self.startTime=localTimeMillis();
    self.worker=worker=self.tableSpecs.GetCursor().ExecuteAsync(sql)
    worker.start()
    
    self.SetStatus(xlt("Refreshing data..."));
    self.SetStatusText("", self.STATUSPOS_ROWS)

    self.pollWorker()

    self.EnableMenu(self.datamenu, self.OnCancelRefresh, False)
    self.EnableMenu(self.datamenu, self.OnRefresh, True)
  
    txt=xlt("%d rows") % worker.GetRowcount()
    if not self.notebook.GetSelection() and self.filter.LimitCheck and self.filter.LimitValue == worker.GetRowcount():
      txt += " LIMIT"
    self.SetStatusText(txt, self.STATUSPOS_ROWS)

    if worker.cancelled:
      self.SetStatus(xlt("Cancelled."));
      self.output.SetData(worker.GetResult())
    elif worker.error:
      errlines=worker.error.error.splitlines()
      self.output.SetEmpty()
      self.SetStatus(errlines[0]);
    else:
      self.SetStatus(xlt("OK."));
      
      self.output.SetData(worker.GetResult())
コード例 #19
0
    def Connect(self, parentWin):
        """
    Connect(parentWin) returns
    True: connected
    False: error
    None: aborted
    """
        self.connectException = None
        self.password = self.settings.get('password')
        self.user = self.settings.get('user')
        if not self.password and self.user:
            self.password, remember = adm.AskPassword(
                parentWin, xlt("Password for %s:" % self.user),
                xlt("Enter password for %(type)s \"%(name)s\"") % {
                    "type": self.typename,
                    "name": self.name
                }, True)
            if self.password == None:
                return None
            if remember:
                self.settings['password'] = self.password
                adm.config.storeServerSettings(self, self.settings)

        rc = self.DoConnect()
        return rc
コード例 #20
0
class ServerConfig(adm.Dialog):
  name=xlt("Server Configuration")
  help=xlt("Edit LDAP Server Configuration")

  def AddExtraControls(self, res):
    self.grid=wxpg.PropertyGrid(self)
    self.grid.SetMarginColour(wx.Colour(255,255,255))
    res.AttachUnknownControl("ValueGrid", self.grid)
    
    
  def Go(self):
    self.grid.Freeze()
    for key in Server.panelClassDefault:
      val=self.node.GetPanelClasses(key)
      property=wxpg.StringProperty(key, key, val)
#      bmp=self.GetBitmap(key)
#      if bmp:
#        self.grid.SetPropertyImage(property, bmp)  crashes?!?
      self.grid.Append(property)
    self.grid.Thaw()
    self.IdGeneratorStyle =  self.node.GetIdGeneratorStyle()
    self.sambaUnixIdPoolDN = self.node.GetSambaUnixIdPoolDN() 

  
  def GetChanged(self):
    return True
    
    
  def Check(self):
    if self.grid.IsEditorFocused():
      self.grid.CommitChangesFromEditor()
    return True
  
  def Save(self):
    pc={}
    for name in Server.panelClassDefault:
      property=self.grid.GetProperty(name)
      val=property.GetValue()
      if val:
        pc[name] = val 
    config={}
    config['panelClasses'] = pc
    config['idGeneratorStyle'] = self.IdGeneratorStyle
    config['sambaUnixIdPoolDN'] = self.sambaUnixIdPoolDN
    
    cfg=ServerConfigData(self.node)
    rc=cfg.Update(str(config))
    if rc:
      self.node.config=config
    return rc

  @staticmethod
  def CheckEnabled(node):
    return node.adminLdapDn != None


  @staticmethod
  def OnExecute(parentWin, node):
    dlg=ServerConfig(parentWin, node)
    return dlg.GoModal()
コード例 #21
0
ファイル: DataTool.py プロジェクト: sarkartanzil/admin4
    def OnDeleteRows(self, evt):
        rows = self.GetAllSelectedRows()
        try:
            rows.remove(len(self.table.rows))
        except:
            pass

        if True:  # askDeleteConfirmation
            if len(rows) > 1:
                msg = xlt("Delete selected %d rows?") % len(rows)
            else:
                msg = xlt("Delete selected row?")
            dlg = wx.MessageDialog(self, msg, xlt("Delete data"))
            if not dlg.ShowModal() == wx.ID_OK:
                return

        rows.sort()
        rows.reverse()
        rc = self.table.Delete(rows)
        if rc != len(rows):
            logger.debug("Rowcount %d after DELETE differs from expected %d",
                         rc, len(rows))
            self.GetParent().OnRefresh()
            return
        self.frame.SetStatusText(
            xlt("%d rows") % len(self.table.rows), self.frame.STATUSPOS_ROWS)
コード例 #22
0
ファイル: Server.py プロジェクト: andreas-p/admin4
  def GetProperties(self):
    if not self.properties:
      sec=self.settings['security']
      if sec.startswith('SSL'):
        pass
      elif sec.startswith('TLS'):
        if self.connection.tls:  sec="TLS"
        else:                    sec=xlt("unsecured connection")
        
      self.annotations=self.connection.GetAnnotations('')
        
      self.properties= [
         ( xlt("Name"),self.name),
         ( xlt("Protocol"), self.connection.PROTOCOL_VERSION),
         ( xlt("Address"), self.address),
         ( xlt("Security"), sec),
         ( xlt("Port"), self.settings["port"]),
         ( xlt("User"), self.user),
         ( xlt("Connected"), YesNo(self.IsConnected())),
         ( xlt("Autoconnect"), YesNo(self.settings.get('autoconnect'))),
         ]
      self.AddProperty("Server", self.connection.id.get('name'))
      self.AddProperty("Version", self.connection.id.get('version'))
      fs=self.annotations.Get('/freespace')
      if fs != None:
        self.AddSizeProperty(xlt("Free space"), float(fs)*1024)
              
#      if self.IsConnected():
#        self.AddChildrenProperty(list(self.connection.capabilities), xlt("Capabilities"), -1)
    return self.properties
コード例 #23
0
ファイル: Zone.py プロジェクト: sarkartanzil/admin4
    def Display(self, node, _detached):
        if not node or node != self.lastNode:
            self.storeLastItem()

            if not self.prepare(node):
                return
            node = self.lastNode
            self.control.AddColumn(xlt("Address"), 10)
            self.control.AddColumn(xlt("Target"), 30)
            self.control.AddColumn(xlt("TTL"), 5)
            self.RestoreListcols()

            icon = node.GetImageId('ptr')

            ips = []
            for ptr in node.ptrs.keys():
                rds = node.ptrs[ptr]
                name = DnsAbsName(ptr, node.partialZonename)
                try:
                    adr = DnsRevAddress(name)
                except:
                    adr = "%s <invalid>" % ptr
                ips.append((adr, rds[0].target, floatToTime(rds.ttl, -1)))

            for ip in sorted(ips, key=(lambda x: filledIp(x[0]))):
                self.control.AppendItem(icon, list(ip))

            self.restoreLastItem()
コード例 #24
0
ファイル: Mailbox.py プロジェクト: rogeriofalcone/admin4
        def Go(self):
            self['ACL'].CreateColumns(xlt("User"), xlt("ACL"), 15)
            self.oldAcl = {}

            if self.node:
                self.node.GetProperties()
                self.MailboxName = self.node.name
                self.FullPath = self.node.mailboxPath
                self.comment = self.node.annotations.Get('/comment')
                self.squat = self.node.annotations.Get(squatAnnotation,
                                                       'false') == 'true'

                if self.node.acl:
                    for user, acl in self.node.acl.items():
                        self.oldAcl[user] = acl
                        self['ACL'].AppendItem(-1, [user, acl])
                if self.node.quota:
                    sq = self.node.quota.get('STORAGE')
                    if sq:
                        if self.node.mailboxPath == sq[0]:
                            self.StorageQuota = prettySize(sq[2])
                        else:
                            self.RootStorageQuota = "%s (root=%s)" % (
                                prettySize(sq[2]), sq[0])

            self.SetUnchanged()
コード例 #25
0
ファイル: ServerPages.py プロジェクト: rogeriofalcone/admin4
    def Display(self, node, _detached):
        if node != self.lastNode:
            self.control.ClearAll()
            self.lastStats = None

            self.lastNode = node

            if node:
                if hasattr(node, "GetStatisticsQuery"):
                    icon = node.GetImageId('statistics')
                    self.control.AddColumn(xlt("Statistics"), 20)
                    self.control.AddColumn(xlt("Value"), -1)
                    rowset = node.ExecuteSet(node.GetStatisticsQuery())
                    for row in rowset:
                        for cn in row.colNames:
                            self.control.AppendItem(icon, [cn, row[cn]])

                elif hasattr(node, "GetStatistics"):
                    icon = node.GetImageId('database')
                    rowset = node.GetStatistics()
                    first = True
                    for cn in rowset.colNames:
                        if first:
                            first = False
                            self.control.AddColumn(cn, 12)
                        else:
                            self.control.AddColumn(cn, 8)
                    for row in rowset:
                        vals = []
                        for i in range(len(rowset.colNames)):
                            vals.append(row[i])
                        self.control.AppendItem(icon, vals)

            self.lastNode = node
コード例 #26
0
ファイル: SpecificEntry.py プロジェクト: ed00m/admin4
 def GetIdFromMax(self, objectClass, attrName):
   if self.GetServer().GetIdGeneratorStyle():
     # using SambaUnixIdPool
     dn=self.GetServer().GetSambaUnixIdPoolDN()
     if not dn:
       if hasattr(self.dialog, "sambaDomainName"):
         dn=self.smbDomains.get(self.dialog.sambaDomainName)
         if not dn:
           res=self.GetServer().SearchSubConverted(["objectClass=sambaDomain", "sambaDomainName=%s" % self.dialog.sambaDomainName ])
           if res:
             dn=res[0][0]
             self.smbDomains[self.dialog.sambaDomainName] = dn
       else:
         self.dialog.SetStatus(xlt("Either sambaUnixIdPoolDN must be configured or a samba domain specified."))
         return
     if dn:
       res=ConvertResult(self.GetConnection().SearchBase(dn, "(objectClass=sambaUnixIdPool)", attrName))
       if res:
         id=int(res[0][1].get(attrName.lower())[0])
         self.dialog.SetValue(attrName, id)
         self.GetConnection().Modify(dn, {attrName: id+1})
         return True
       else:
         self.dialog.SetStatus(xlt("Couldn't read %s from %s") % (attrName, dn))
         return False
   else:
     # using max+1 method
     maxId=0
     res=self.GetServer().SearchSubConverted(["objectClass=%s" % objectClass, "%s=*" % attrName], attrName)
     for _dn, info in res:
       uid=int(info[attrName][0])
       maxId = max(maxId, uid)
     self.dialog.SetValue(attrName, maxId+1)
     self.dialog.SetStatus("Generated %(attr)s from highest used %(attr)s" % {"attr": attrName})
   return False
コード例 #27
0
ファイル: Server.py プロジェクト: sarkartanzil/admin4
    def GetProperties(self):
        if not self.properties:
            sec = self.settings['security']
            if sec.startswith('SSL'):
                pass
            elif sec.startswith('TLS'):
                if self.connection.tls: sec = "TLS"
                else: sec = xlt("unsecured connection")

            self.annotations = self.connection.GetAnnotations('')

            self.properties = [
                (xlt("Name"), self.name),
                (xlt("Protocol"), self.connection.PROTOCOL_VERSION),
                (xlt("Address"), self.address),
                (xlt("Security"), sec),
                (xlt("Port"), self.settings["port"]),
                (xlt("User"), self.user),
                (xlt("Connected"), YesNo(self.IsConnected())),
                (xlt("Autoconnect"), YesNo(self.settings.get('autoconnect'))),
            ]
            self.AddProperty("Server", self.connection.id.get('name'))
            self.AddProperty("Version", self.connection.id.get('version'))
            fs = self.annotations.Get('/freespace')
            if fs != None:
                self.AddSizeProperty(xlt("Free space"), float(fs) * 1024)


#      if self.IsConnected():
#        self.AddChildrenProperty(list(self.connection.capabilities), xlt("Capabilities"), -1)
        return self.properties
コード例 #28
0
ファイル: ServerPages.py プロジェクト: rogeriofalcone/admin4
    def DoInstrument(server):
        if server.version >= 8.1 and server.version < 9.4:
            if not server.GetValue('adminpack'):
                if server.GetValue('adminpack-extension'):
                    server.GetCursor().ExecuteSingle(
                        "CREATE EXTENSION adminpack")
                else:
                    cursor = server.GetCursor()
                    cursor.ExecuteSingle("""
                CREATE OR REPLACE FUNCTION pg_catalog.pg_file_write(text, text, bool)
                RETURNS bigint
                AS '$libdir/adminpack', 'pg_file_write'
                LANGUAGE C VOLATILE STRICT;
                
                CREATE OR REPLACE FUNCTION pg_catalog.pg_file_rename(text, text, text)
                RETURNS bool
                AS '$libdir/adminpack', 'pg_file_rename'
                LANGUAGE C VOLATILE;
                
                CREATE OR REPLACE FUNCTION pg_catalog.pg_file_unlink(text)
                RETURNS bool
                AS '$libdir/adminpack', 'pg_file_unlink'
                LANGUAGE C VOLATILE STRICT;
                """)

            if not server.GetValue('postgresql.auto.conf'):
                cursor = server.GetCursor()
                cursor.ExecuteSingle(
                    "SELECT pg_file_write('postgresql.auto.conf', %s, false)" %
                    quoteValue(InstrumentConfig.autoconfHeader, cursor))

            if server.GetValue('admin4.instrumentation') != 'ok':
                dataDir = server.GetValue("data_directory")
                autoconfPath = "%s/postgresql.auto.conf" % dataDir
                cfgFile = server.GetValue('config_file')

                if cfgFile.startswith(dataDir):
                    cfgFile = cfgFile[len(dataDir) + 1:]
                    cursor = server.GetCursor()
                    cfg = cursor.ExecuteSingle(
                        "SELECT pg_read_file('%s', 0, 999999)" % cfgFile)

                    if not cfg.strip().endswith("include '%s'" % autoconfPath):
                        cfg += "\n\n# Admin4 config file\ninclude '%s'\n" % autoconfPath
                        cursor.ExecuteSingle("""
                SELECT pg_file_unlink('%(cfg)s.bak');
                SELECT pg_file_write('%(cfg)s.tmp', %(content)s, false);
                SELECT pg_file_rename('%(cfg)s.tmp', '%(cfg)s', '%(cfg)s.bak');
                SELECT pg_reload_conf();
                """ % {
                            'cfg': cfgFile,
                            'content': quoteValue(cfg, cursor)
                        })
                else:
                    wx.MessageBox(
                        xlt("""The main configuration file cannot be modified automatically because it is not located in the data directory.\nPlease edit %s and append the line \"include '%s\' \" at the very end."""
                            ) % (cfgFile, autoconfPath),
                        xlt("Please modify %s manually") %
                        cfgFile.split('/')[-1])
        return True
コード例 #29
0
ファイル: LoggingDialog.py プロジェクト: sarkartanzil/admin4
    def __init__(self, parentWin):
        adm.Dialog.__init__(self, parentWin, None, "LoggingDialog")
        _TimerOwner.__init__(self)

        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind("Apply", self.OnApply)

        nb = self['notebook']
        panel = LoggingPanel(self, nb)
        nb.InsertPage(0, panel, xlt(panel.panelName))
        panel = QueryLoggingPanel(self, nb)
        nb.InsertPage(1, panel, xlt(panel.panelName))
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChange)

        self['LogLevelFile'].SetRange(0, len(self.loglevels) - 1)
        self['LogLevelQuery'].SetRange(0, len(self.querylevels) - 1)
        self.Bind("LogLevelFile LogLevelQuery", wx.EVT_COMMAND_SCROLL,
                  self.OnLevel)

        self.LogLevelFile = self.loglevels.index(logger.loglevel)
        self.LogLevelQuery = self.querylevels.index(logger.querylevel)
        self.LogFileLog = logger.logfile
        self.LogFileQuery = logger.queryfile
        self.OnLevel()

        ah = AcceleratorHelper(self)
        ah.Add(wx.ACCEL_CTRL, 'C', self.BindMenuId(self.OnCopy))
        ah.Realize()
コード例 #30
0
ファイル: Zone.py プロジェクト: andreas-p/admin4
  def Display(self, node, _detached):
    if not node or node != self.lastNode:
      self.storeLastItem()
      
      if not self.prepare(node):
        return
      node=self.lastNode
      self.control.AddColumn(xlt("Address"), 10)
      self.control.AddColumn(xlt("Target"), 30)
      self.control.AddColumn(xlt("TTL"), 5)
      self.RestoreListcols()

      icon=node.GetImageId('ptr')
      
      ips=[]
      for ptr in node.ptrs.keys():
        rds=node.ptrs[ptr]
        name=DnsAbsName(ptr, node.partialZonename)
        try:
          adr=DnsRevAddress(name)
        except:
          adr="%s <invalid>" % ptr
        ips.append( (adr, rds[0].target, floatToTime(rds.ttl, -1)))

      for ip in sorted(ips, key=(lambda x: filledIp(x[0]))):
        self.control.AppendItem(icon, list(ip))
      
      self.restoreLastItem()
コード例 #31
0
ファイル: Role.py プロジェクト: sarkartanzil/admin4
class Role(adm.Node):
    typename = xlt("Role")
    shortname = xlt("Role")

    @staticmethod
    def GetInstances(parentNode):
        instances = []
        set = parentNode.GetConnection().GetCursor().ExecuteSet("""
      SELECT rolname as name, *,
        (SELECT array_agg(rolname) FROM pg_roles r JOIN pg_auth_members m on r.oid=m.member WHERE m.roleid=u.oid) AS members,
        (SELECT array_agg(rolname) FROM pg_roles r JOIN pg_auth_members m on r.oid=m.roleid WHERE m.member=u.oid) AS memberof
        FROM pg_roles u ORDER BY rolname""")
        if set:
            for row in set:
                if not row:
                    break
                instances.append(Role(parentNode, row['name'], row.getDict()))
        return instances

    def __init__(self, parentNode, name, info):
        super(Role, self).__init__(parentNode, name)
        self.info = info

    def GetIcon(self):
        icons = []
        if self.info['members']:
            icons.append("Group")
        else:
            icons.append("User")
        return self.GetImageId(icons)

    def GetProperties(self):
        if not len(self.properties):

            self.properties = [
                (xlt("Name"), self.name, self.GetImageId('Role')),
                ("OID", self.info['oid']),
                (xlt("Can Login"), YesNo(self.info['rolcanlogin'])),
                (xlt("Superuser"), YesNo(self.info['rolsuper'])),
                (xlt("Catalog Update"), YesNo(self.info['rolcatupdate'])),
                (xlt("Create DB"), YesNo(self.info['rolcreatedb'])),
                (xlt("Create Role"), YesNo(self.info['rolcreaterole'])),
                (xlt("Inherits rights"), YesNo(self.info['rolinherit'])),
            ]
            until = self.info['rolvaliduntil']
            if not until or until.year == 9999:
                until = xlt("never")
            else:
                until = prettyDate(until)
            self.properties.append((xlt("Expires"), until))

            self.AddChildrenProperty(self.info['memberof'], xlt("Member of"),
                                     self.GetImageId("Group"))
            self.AddChildrenProperty(self.info['members'], xlt("Members"),
                                     self.GetImageId("User"))
            self.AddChildrenProperty(self.info['rolconfig'], xlt("Variables"),
                                     -1)

        return self.properties
コード例 #32
0
ファイル: QueryTool.py プロジェクト: ed00m/admin4
 def OnAddSnippet(self, evt):
   sql=self.getSql()
   if sql:
     dlg=wx.TextEntryDialog(self, xlt("Snippet name"), xlt("Add snippet"))
     if dlg.ShowModal() == wx.ID_OK:
       name=dlg.GetValue()
       self.snippets.AppendSnippet(name, sql)
       self.SetStatus(xlt("Snipped stored."))
コード例 #33
0
ファイル: Server.py プロジェクト: andreas-p/admin4
 def Check(self):
   ok=True
   if not self.node:
     ok=self.CheckValid(ok, self.Hostname, xlt("Host name cannot be empty"))
     ok=self.CheckValid(ok, not adm.config.existsServer(self, self.HostName), xlt("Host name already in use"))
   ok=self.CheckValid(ok, self.HostAddress, xlt("Host address cannot be empty"))
   ok=self.CheckValid(ok, self.Port, xlt("Port cannot be 0"))
   return ok
コード例 #34
0
 def OnAddSnippet(self, evt):
   sql=self.getSql()
   if sql:
     dlg=wx.TextEntryDialog(self, xlt("Snippet name"), xlt("Add snippet"))
     if dlg.ShowModal() == wx.ID_OK:
       name=dlg.GetValue()
       self.snippets.AppendSnippet(name, sql)
       self.SetStatus(xlt("Snipped stored."))
コード例 #35
0
 def OnFileInsert(self, evt):
     sql = self.readFile(xlt("Insert SQL from file"))
     if sql:
         self.editor.ReplaceSelection(sql)
         self.SetStatus(
             xlt("%d characters inserted from %s") %
             (len(sql), self.fileManager.currentFile))
         self.updateMenu()
コード例 #36
0
 def Go(self):
     self.ConfirmDeletes = adm.confirmDeletes
     self.Proxy = adm.proxy
     self['UpdateCheckPeriod'].Append([(1, xlt("daily")),
                                       (7, xlt('weekly')),
                                       (30, xlt('monthly')),
                                       (0, xlt('never'))])
     self.UpdateCheckPeriod = adm.updateCheckPeriod
コード例 #37
0
ファイル: _ldap.py プロジェクト: andreas-p/admin4
  def __init__(self, node):
    self.lastError=None
    self.wasConnected=False
    self.ldap=None
    self.node=node
    self.subschema=None
    self.base=None

    ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
    ldap.set_option(ldap.OPT_REFERRALS,0)


    if node.settings['security'] == "ssl":
      protocol="ldaps"
    else:
      protocol="ldap"
    uri="%s://%s:%d" % (protocol, node.settings['host'], node.settings['port'])

    try:
      spot="Connect"
      self.ldap=ldap.ldapobject.SimpleLDAPObject(uri)

      if node.settings['security'] == "tls":
        spot="StartTLS"
        self.ldap.start_tls_s()

      ldap.timeout=node.timeout
  
      spot=xlt("OptReferrals")
      self.ldap.set_option(ldap.OPT_REFERRALS,0)
      
      user=node.settings['user']
      spot=xlt("Bind")
      if user:
        self.ldap.simple_bind_s(user, node.password)
      else:
        self.ldap.simple_bind_s("", "")
    except Exception as e:
      self.ldap=None
      self.lastError = str(e)
      raise adm.ConnectionException(self.node, spot, self.lastError)

    try:
      result=self.ldap.search_s("", ldap.SCOPE_BASE, "(objectClass=*)", ['*','+'] )
      self.base=result[0][1]

      try:
        subschemaDN=self.base['subschemaSubentry'][0]

#        result=self.ldap.search_s(subschemaDN, ldap.SCOPE_BASE, "(objectClass=*)", ['*','+'] )
        result=self.ldap.search_s(subschemaDN, ldap.SCOPE_BASE, "(objectClass=*)",  ['ldapSyntaxes', 'attributeTypes', 'objectclasses', 'matchingRules', 'matchingRuleUse'] )
        self.subschema=ldap.schema.SubSchema(result[0][1])
      except Exception as e:
        logger.debug("Didn't get subschema: %s", str(e))
        pass
    except Exception as e:
      logger.debug("Didn't get config: %s", str(e))
      pass
コード例 #38
0
 def GetInfo(self):
     if self.IsConnected():
         le = self.GetLastError()
         if le:
             return xlt("Connection error: %s") % le
         else:
             return xlt("connected")
     else:
         return xlt("not connected")
コード例 #39
0
ファイル: Samba.py プロジェクト: sarkartanzil/admin4
class SambaDomain(SpecificEntry):
  name=xlt("Samba Domain")
  shortname=xlt("Domain")
  icon="SambaDomain"
  canClasses="sambaDomain"


  def Go(self):
    SpecificEntry.Go(self)
コード例 #40
0
ファイル: GenericEntry.py プロジェクト: saydulk/admin4
 def OnGridRightClick(self, evt):
     property = self.grid.GetSelection()
     if property:
         oid = property.GetName()
         if oid:
             name = self.dialog.attribs[oid].name
             cm = Menu(self.dialog)
             cm.Add(self.OnDelAttrs, xlt("Remove %s") % name, xlt('Remove attribute "%s"') % name)
             cm.Popup(evt)
コード例 #41
0
ファイル: Mailbox.py プロジェクト: ed00m/admin4
 def OnExecute(parentWin, node):
   dlg=wx.TextEntryDialog(parentWin, xlt("New mailbox path"), xlt("Move mailbox %s") % node.mailboxPath)
   dlg.SetValue(node.mailboxPath)
   if dlg.ShowModal() == wx.ID_OK:
     newPath=dlg.GetValue()
     rc=node.GetConnection().RenameMailbox(node.mailboxPath, newPath)
     if rc:
       node.parentNode.Refresh()
   return False
コード例 #42
0
ファイル: Table.py プロジェクト: sarkartanzil/admin4
class RowCount:
    name = xlt("Count")
    help = xlt("Count rows in table")

    @staticmethod
    def OnExecute(_parentWin, node):
        node.rowcount = node.ExecuteSingle("SELECT COUNT(1) FROM ONLY %s" %
                                           node.NameSql())
        return True
コード例 #43
0
ファイル: node.py プロジェクト: andreas-p/admin4
 def GetInfo(self):
   if self.IsConnected():
     le=self.GetLastError()
     if le:
       return xlt("Connection error: %s") % le
     else:
       return xlt("connected")
   else:
     return xlt("not connected")
コード例 #44
0
 def Check(self):
   ok=True
   if not self.node:
     ok=self.CheckValid(ok, self.Hostname, xlt("Host name cannot be empty"))
     ok=self.CheckValid(ok, not adm.config.existsServer(self, self.HostName), xlt("Host name already in use"))
   ok=self.CheckValid(ok, self.HostAddress, xlt("Host address cannot be empty"))
   ok=self.CheckValid(ok, self.Port, xlt("Port cannot be 0"))
   ok=self.CheckValid(ok, self.LdapBase, xlt("Ldap Base cannot be empty"))
   return ok
コード例 #45
0
ファイル: LoggingDialog.py プロジェクト: andreas-p/admin4
 def __init__(self, dlg, notebook):
   LogPanel.__init__(self, dlg, notebook, "Logging")
   self.SetOwner(dlg)
   add=self.control.AddColumnInfo
   add(xlt("Timestamp"), "2014-01-01 20:00:00", colname='timestamp')
   add(xlt("Text"), 50, colname='text')
   add(xlt("Traceback"), 20, colname='tb')
   self.RestoreListcols()
   self.logIndex=0
   self.insertPosition=-1 # 0: start, -1: end
コード例 #46
0
ファイル: Update.py プロジェクト: andreas-p/admin4
 def run(self):
   update=OnlineUpdate()
   if update.IsValid():
     adm.updateInfo=update
     if update.UpdateAvailable():
       wx.CallAfter(self.frame.OnUpdate)
   elif update.exception:
     wx.CallAfter(wx.MessageBox,
                  xlt("Connection error while trying to retrieve update information from the update server.\nCheck network connectivity and proxy settings!"), 
                  xlt("Communication error"), wx.ICON_EXCLAMATION)
コード例 #47
0
ファイル: Group.py プロジェクト: ed00m/admin4
 def __init__(self, dlg, notebook, resname=None):
   SpecificEntry.__init__(self, dlg, notebook, resname)
   self.memberUidOid=self.GetServer().GetOid("memberUid")
   self.Bind("AddMember", self.OnAddMember)
   self.Bind("DelMember", self.OnDelMember)
   self.Bind("GenerateGid", self.OnGenerate)
   lv=self['Members']
   lv.AddColumn(xlt("User Id"), 20)
   lv.AddColumn(xlt("Description"))
   lv.Bind(wx.EVT_LIST_COL_END_DRAG, self.OnListColResize)
   lv.Bind(wx.EVT_MOTION, self.OnMouseMove)
コード例 #48
0
ファイル: frame.py プロジェクト: ed00m/admin4
  def OnDelete(self, evt):
    node=self.tree.GetNode()
    if node and hasattr(node, "Delete"):
      if not adm.ConfirmDelete(xlt("Delete \"%s\"?") % node.name, xlt("Deleting %s") % node.typename):
        return

      if node.Delete():
        node.RemoveFromTree()
        self.SetStatus(xlt("%s \"%s\" deleted.") % (node.typename, node.name))
      else:
        self.SetStatus(xlt("%s \"%s\" NOT deleted: %s.") % (node.typename, node.name, node.GetServer().GetLastError()))
コード例 #49
0
ファイル: QueryTool.py プロジェクト: ed00m/admin4
 def saveFile(self, proc):    
   try:
     ok=proc(self, self.editor.GetText(), self.filePatterns, xlt("Save SQL Query"))
     if ok:
       self.SetStatus(xlt("Saved SQL query to %s") % self.fileManager.filename)
       self.sqlChanged=False
       self.updateMenu() 
     else:
       self.StatusText(xlt("Nothing saved"))
   except:
     self.SetStatus(xlt("Failed to save to %s") % self.fileManager.filename)
コード例 #50
0
ファイル: _sqlgrid.py プロジェクト: ed00m/admin4
  def GetValue(self, row, col):
    val=self.getValue(row, col)
#    if self.GetColDef(col).category == 'B':
#      return bool(val)
      
    if val == None:   return ""
    else:
      if isinstance(val, bool):
        if val: return xlt("true")
        else:   return xlt("false")
      return val
コード例 #51
0
ファイル: controlcontainer.py プロジェクト: ed00m/admin4
  def __init__(self, parentWin, node, parentNode=None):
    CheckedDialog.__init__(self, parentWin, node)
    if parentNode:
      self.parentNode=parentNode

    self.refreshNode=None

    if self.node:
      self.SetTitle(xlt("Properties of %s \"%s\"") % (self.node.typename, self.node.name))
    elif parentNode:
      self.SetTitle(xlt("New %s") % parentNode.typename)
    self.Bind('OK', wx.EVT_BUTTON, self.OnOK)
コード例 #52
0
ファイル: Entry.py プロジェクト: ed00m/admin4
 def OnExecute(parentWin, node):
   rdn=node.name.split('=')
   dlg=wx.TextEntryDialog(parentWin, xlt("rename to %s=") % rdn[0], xlt("Rename %s \"%s\"") % (node.typename, rdn[1]))
   dlg.SetValue(rdn[1])
   if dlg.ShowModal() == wx.ID_OK:
     newname=dlg.GetValue()
     if newname != rdn[1]:
       newrdn="%s=%s" % (rdn[0], newname)
       node.GetConnection().Rename(node.dn, newrdn)
       node.name=newrdn
       return True
   return False
コード例 #53
0
ファイル: Schema.py プロジェクト: andreas-p/admin4
  def GetProperties(self):
    if not len(self.properties):

      self.properties = [
        (xlt("Name"),           self.name),
        (  "OID" ,              self.info['oid']),
        (xlt("Owner"),          self.info['owner']),
        (xlt("ACL"),            self.info['nspacl'])
      ]

      self.AddProperty(xlt("Description"), self.info['description'])
    return self.properties
コード例 #54
0
ファイル: ServerPages.py プロジェクト: ed00m/admin4
 def Check(self):
   if self.type == 'bool':
     self['value'].SetLabel(self.GetVal())
   ok=True
   ok=self.CheckValid(ok, self.canWrite, xlt("Can save to instrumented servers only."))
   ok=self.CheckValid(ok, self.vals['context'] != 'internal', xlt("Internal setting; cannot be edited."))
   minVal=self.vals['min_val']
   ok=self.CheckValid(ok, minVal==None or self.value.GetValue() >=minVal, xlt("Must be %s or more") % minVal)
   maxVal=self.vals['max_val']
   ok=self.CheckValid(ok, maxVal==None or self.value.GetValue() <=maxVal, xlt("Must be %s or less") % maxVal)
   
   return ok
コード例 #55
0
ファイル: DataTool.py プロジェクト: andreas-p/admin4
  def OnLabelRightClick(self, evt):
    if evt.Row >= 0:
      self.SelectRow(evt.Row, evt.ControlDown())
      rows=self.GetAllSelectedRows()
      try:  rows.remove(len(self.table.rows))
      except: pass

      if self.tableSpecs.keyCols and rows:
        cm=Menu(self.GetParent())
        if len(rows) > 1: cm.Add(self.OnDeleteRows, xlt("Delete rows"))
        else:             cm.Add(self.OnDeleteRows, xlt("Delete row"))
        cm.Popup(evt)