def _getZoneDB(self, zone, zf=None): from time import strftime self._currentDB = zone zName = zone.getName() zFile = zone.getFile() if zf is None: self._zf = ZoneFile() if self._zf.openZoneFile( zFile ) is False: try: open(zFile, 'w').close() except: return UI.Label('O arquivo não pôde ser acessado!') if self._zf.openZoneFile( zFile ) is False: return UI.Label('O arquivo não pôde ser aberto!') else: self._zf = zf labelTop0 = UI.Label ( text = "Zona: "+zName.upper() , bold=True ) labelTop1 = UI.Label ( text = "Arquivo: "+zFile ) # Buttons butSave = UI.Button( id = 'saveDB', text="Salvar DB", icon="/dl/core/ui/stock/save.png", onclick="form", form="frmEditDB") butCancel = UI.Button( id = 'cancelDB', text="Cancelar", icon="/dl/core/ui/stock/dialog-cancel.png") butAddDir = UI.Button( id = 'addDirective', text="Adicionar Diretiva", icon="/dl/core/ui/stock/add.png") butAddRec = UI.Button( id = 'addRecord', text="Adicionar Registro", icon="/dl/core/ui/stock/add.png") buttons = UI.VContainer( UI.HContainer( butAddDir, butAddRec ), UI.HContainer( butCancel, butSave ) ) #END:Buttons # DIRETIVAS bloco = UI.DT( width="100%" ) bloco.append( UI.DTR( UI.DTD( UI.Label(text='Diretivas:', bold=True), colspan = 4 ) ) ) d = self._zf.getDirectives() for i in d.keys(): bloco.append( UI.DTR( UI.DTD(UI.Label( text=i ),colspan=2), UI.Label( text=d[i] ), UI.HContainer( UI.TipIcon( icon='/dl/core/ui/stock/edit.png', id='editDirectiveField/%s'%i), text='Editar Diretiva' ), )) del d #END: DIRETIVAS # SOA bloco.append( UI.DTR( UI.DTD( UI.Label ( text="Registro de Autoridade:", bold=True ), colspan=4 ))) s = self._zf.getSOA() for i in s.keys(): bloco.append( UI.DTR( UI.DTD(UI.Label ( text=i ),colspan=2), UI.Label ( text=s[i] ), UI.HContainer( UI.TipIcon( icon='/dl/core/ui/stock/edit.png', id='editSOAField/%s'%i, text='Editar campo SOA' ), ))) del s #END: SOA #REGISTROS bloco.append( UI.DTR( UI.DTD( UI.Label ( text="Demais registros:", bold=True ), colspan=4 ))) r = self._zf.getRecords() text4Label = [] for i in r.keys(): text4Label.append("%s[§SEP§]%s[§SEP§]%s%s%s[§SEP§]%s" %\ (r[i]['Tipo'],r[i]['Nome'],r[i]['IP'],r[i]['HostName'], r[i]['Texto'], str(i)) ) text4Label.sort() for i in text4Label: sp = i.split('[§SEP§]') bloco.append( UI.DTR( UI.Label ( text=sp[0] ), UI.Label ( text=sp[1] ), UI.Label ( text=sp[2] ), UI.HContainer( UI.TipIcon( icon='/dl/core/ui/stock/delete.png', id=('delRecordField/%s'%sp[3]), text='Delete', msg='Remover' ) ) )) del r #END:REGISTROS block = UI.VContainer( labelTop0, labelTop1, bloco, buttons ) return UI.DTR( block )