PEATDB/PEATApp.py
def saveAs(self):
        """Save a local copy of the DB, if the DB is remote, this acts as a local
           backup, but may take some time to get the data from the server, need to
           warn user before we start"""
        if self.DB == None:
            return
        size = round(self.DB.getSize()/1024,1)
        if size > 30:
            answer = tkMessageBox.askyesno("DB Save Warning",
                                       'This Database is %s MB in size.\n'
                                       'Are you sure you want to save locally?' %size)
            if answer == False:
                return

        import copy
        filename=tkFileDialog.asksaveasfilename(defaultextension='.fs',
                                   initialdir=os.getcwd(),
                                   filetypes=[("zodb fs","*.fs"),("All files","*.*")])
        if filename:
            if os.path.exists(filename):
                for i in ['.lock','.index','']:
                    os.remove(filename+i)
            newDB = PDatabase(local=filename)
            #show progress dialog
            from Dialogs import PEATDialog
            pb=PEATDialog(self.master, option='progressbar',
                                          message='Getting records..')
            pb.update_progress(0)
            total = len(self.DB.getRecs())
            count=0
            for r in self.DB.getRecs():
                rec = copy.deepcopy(self.DB.data[r])
                newDB.add(r, record=rec)
                count+=1
                pb.update_progress(float(count)/float(total)*100.0)
            pb.close()
            for m in self.DB.meta.keys():
                newDB.meta[m] = copy.deepcopy(self.DB.meta[m])
            #newDB.cellcache = copy.deepcopy(self.DB.cellcache)
            newDB.commit()
            newDB.close()
            self.recordEvent('Saved current DB as %s' %filename)
        return
Save a local copy of the DB, if the DB is remote, this acts as a local
           backup, but may take some time to get the data from the server, need to
           warn user before we start
Save a local copy of the DB, if the DB is remote, this acts as a local
backup, but may take some time to get the data from the server, need to
warn user before we start
Save a local copy of the DB if the DB is remote this acts as a local backup but may take some time to get the data from the server need to warn user before we start
def saveAs(self):
        if self.DB == None:
            return
        size = round(self.DB.getSize()/1024,1)
        if size > 30:
            answer = tkMessageBox.askyesno("DB Save Warning",
                                       'This Database is %s MB in size.\n'
                                       'Are you sure you want to save locally?' %size)
            if answer == False:
                return
        import copy
        filename=tkFileDialog.asksaveasfilename(defaultextension='.fs',
                                   initialdir=os.getcwd(),
                                   filetypes=[("zodb fs","*.fs"),("All files","*.*")])
        if filename:
            if os.path.exists(filename):
                for i in ['.lock','.index','']:
                    os.remove(filename+i)
            newDB = PDatabase(local=filename)
            from Dialogs import PEATDialog
            pb=PEATDialog(self.master, option='progressbar',
                                          message='Getting records..')
            pb.update_progress(0)
            total = len(self.DB.getRecs())
            count=0
            for r in self.DB.getRecs():
                rec = copy.deepcopy(self.DB.data[r])
                newDB.add(r, record=rec)
                count+=1
                pb.update_progress(float(count)/float(total)*100.0)
            pb.close()
            for m in self.DB.meta.keys():
                newDB.meta[m] = copy.deepcopy(self.DB.meta[m])
            newDB.commit()
            newDB.close()
            self.recordEvent('Saved current DB as %s' %filename)
        return
def saveAs ( self ) : if self . DB == None : return size = round ( self . DB . getSize ( ) / 1024 , 1 ) if size > 30 : answer = tkMessageBox . askyesno ( "DB Save Warning" , 'This Database is %s MB in size.\n' 'Are you sure you want to save locally?' % size ) if answer == False : return import copy filename = tkFileDialog . asksaveasfilename ( defaultextension = '.fs' , initialdir = os . getcwd ( ) , filetypes = [ ( "zodb fs" , "*.fs" ) , ( "All files" , "*.*" ) ] ) if filename : if os . path . exists ( filename ) : for i in [ '.lock' , '.index' , '' ] : os . remove ( filename + i ) newDB = PDatabase ( local = filename ) from Dialogs import PEATDialog pb = PEATDialog ( self . master , option = 'progressbar' , message = 'Getting records..' ) pb . update_progress ( 0 ) total = len ( self . DB . getRecs ( ) ) count = 0 for r in self . DB . getRecs ( ) : rec = copy . deepcopy ( self . DB . data [ r ] ) newDB . add ( r , record = rec ) count += 1 pb . update_progress ( float ( count ) / float ( total ) * 100.0 ) pb . close ( ) for m in self . DB . meta . keys ( ) : newDB . meta [ m ] = copy . deepcopy ( self . DB . meta [ m ] ) newDB . commit ( ) newDB . close ( ) self . recordEvent ( 'Saved current DB as %s' % filename ) return
Save a local copy of the DB, if the DB is remote, this acts as a local
backup, but may take some time to get the data from the server, need to
warn user before we start
Save a local copy of the DB if the DB is remote this acts as a local backup but may take some time to get the data from the server need to warn user before we start
"""Save a local copy of the DB, if the DB is remote, this acts as a local
           backup, but may take some time to get the data from the server, need to
           warn user before we start""" #show progress dialog #newDB.cellcache = copy.deepcopy(self.DB.cellcache)
self