PEATDB/PEATApp.py
def saveDB(self, event=None):
        """Save current changes, conflicts are handled here"""

        if self.DB.isChanged() == False:
            return
        #cache changed objects in case of conflict?
        import copy

        if self.username == '':
            tkMessageBox.showwarning("Set a user name",
                                     'You need to set a user name before saving.\n'
                                     'So that PEAT can log who made the change.')
            return

        def handleconflict(result):
            '''handle this inside db class??'''
            dialog.deactivate()
            if result == 'Discard':
                self.DB.abort()
                #self.DB.connection.sync()
                self.updateTable()
            elif result == 'Overwrite':
                #first cache changed objects, abort
                #and update then we try to apply users changes
                self.DB.abort()
                #self.DB.connection.sync()
                #reapply changes..
                for s in saved:
                    print s
                #result = self.DB.commit(user=self.username, note=comment)
                #if result == False:
                    #failed.. give up
            return

        askcomment = self.preferences.get('promptforlogcomments')
        comment = None
        if self.DB != None:
            if askcomment == True:
                comment = tkSimpleDialog.askstring('Log comment',
                                             'Enter a comment for the log',
                                             initialvalue='minor',
                                             parent=self.main)
            if comment == None:
                return
            result = self.DB.commit(user=self.username, note=comment)
            if result == False:
                #a conflict occured, we give user a choice
                dialog = Pmw.Dialog(self.main,
                          buttons = ('Discard My Changes', 'Overwrite', 'Cancel'),
                          defaultbutton = 'OK',
                          title = 'Conflict Error!',
                          command = handleconflict)
                w = Label(dialog.interior(),
                      text = 'A conflict occured, someone else has changed \n'
                             'the same record/field since you last synced the DB.\n'
                             'You can discard your changes OR overwrite with \n'
                             'your changes. Pressing cancel will take no action.',
                      background = '#FFFAF0',
                      width=50,
                      pady=10)
                w.pack(expand=1, fill=BOTH, padx=2, pady=2)
                dialog.activate(geometry='centerscreenalways')
        else:
            self.updateTable()
        self.updateStatusPane()
        self.updateChangelog()
        return
Save current changes, conflicts are handled here
Save current changes, conflicts are handled here
Save current changes conflicts are handled here
def saveDB(self, event=None):
        if self.DB.isChanged() == False:
            return
        import copy
        if self.username == '':
            tkMessageBox.showwarning("Set a user name",
                                     'You need to set a user name before saving.\n'
                                     'So that PEAT can log who made the change.')
            return
        def handleconflict(result):
            dialog.deactivate()
            if result == 'Discard':
                self.DB.abort()
                self.updateTable()
            elif result == 'Overwrite':
                self.DB.abort()
                for s in saved:
                    print s
            return
        askcomment = self.preferences.get('promptforlogcomments')
        comment = None
        if self.DB != None:
            if askcomment == True:
                comment = tkSimpleDialog.askstring('Log comment',
                                             'Enter a comment for the log',
                                             initialvalue='minor',
                                             parent=self.main)
            if comment == None:
                return
            result = self.DB.commit(user=self.username, note=comment)
            if result == False:
                dialog = Pmw.Dialog(self.main,
                          buttons = ('Discard My Changes', 'Overwrite', 'Cancel'),
                          defaultbutton = 'OK',
                          title = 'Conflict Error!',
                          command = handleconflict)
                w = Label(dialog.interior(),
                      text = 'A conflict occured, someone else has changed \n'
                             'the same record/field since you last synced the DB.\n'
                             'You can discard your changes OR overwrite with \n'
                             'your changes. Pressing cancel will take no action.',
                      background = '#FFFAF0',
                      width=50,
                      pady=10)
                w.pack(expand=1, fill=BOTH, padx=2, pady=2)
                dialog.activate(geometry='centerscreenalways')
        else:
            self.updateTable()
        self.updateStatusPane()
        self.updateChangelog()
        return
def saveDB ( self , event = None ) : if self . DB . isChanged ( ) == False : return import copy if self . username == '' : tkMessageBox . showwarning ( "Set a user name" , 'You need to set a user name before saving.\n' 'So that PEAT can log who made the change.' ) return def handleconflict ( result ) : '''handle this inside db class??''' dialog . deactivate ( ) if result == 'Discard' : self . DB . abort ( ) self . updateTable ( ) elif result == 'Overwrite' : self . DB . abort ( ) for s in saved : print s return askcomment = self . preferences . get ( 'promptforlogcomments' ) comment = None if self . DB != None : if askcomment == True : comment = tkSimpleDialog . askstring ( 'Log comment' , 'Enter a comment for the log' , initialvalue = 'minor' , parent = self . main ) if comment == None : return result = self . DB . commit ( user = self . username , note = comment ) if result == False : dialog = Pmw . Dialog ( self . main , buttons = ( 'Discard My Changes' , 'Overwrite' , 'Cancel' ) , defaultbutton = 'OK' , title = 'Conflict Error!' , command = handleconflict ) w = Label ( dialog . interior ( ) , text = 'A conflict occured, someone else has changed \n' 'the same record/field since you last synced the DB.\n' 'You can discard your changes OR overwrite with \n' 'your changes. Pressing cancel will take no action.' , background = '#FFFAF0' , width = 50 , pady = 10 ) w . pack ( expand = 1 , fill = BOTH , padx = 2 , pady = 2 ) dialog . activate ( geometry = 'centerscreenalways' ) else : self . updateTable ( ) self . updateStatusPane ( ) self . updateChangelog ( ) return
Save current changes, conflicts are handled here
Save current changes conflicts are handled here
"""Save current changes, conflicts are handled here""" #cache changed objects in case of conflict? '''handle this inside db class??''' #self.DB.connection.sync() #first cache changed objects, abort #and update then we try to apply users changes #self.DB.connection.sync() #reapply changes.. #result = self.DB.commit(user=self.username, note=comment) #if result == False: #failed.. give up #a conflict occured, we give user a choice
self
event