Changeset 193

Show
Ignore:
Timestamp:
Thu Sep 7 16:22:30 2006
Author:
Brian
Message:

Fix errors discovered in server testing.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • server/trunk/update/client/Share Changes with Server.py

    r191 r193  
    34 34 # 060831 - prevent deprecation message in log file; check for server ip address  
    35 35 # 060903 - fix de-dup of column types; adjust foreign keys in report's SelectValue  
      36 # 060907 - fix error in LocalRowsAdded(); put get & send inside of try/finally;  
      37 #           if multiple gets use server ids from first get when finding local changes  
    36 38  
    37 39 debug = 1  
     
    59 61     import xmlrpclib  
    60 62  
      63     global server_prior_nextid  
      64  
    61 65     server_address = Data.Other.get('ServerAddress')  # or "http://192.168.0.6:8001"  
    62 66     if not server_address:  
     
    111 115         old_nextID, new_nextID = SplitOldNew(Data.NextID)  
    112 116         for k, v in new_nextID.iteritems():  
    113               old = old_nextID.get(k) or 0  
      117             old = old_nextID.get(k) or 1  
    113 117             if old < v:  
    114 118                 count += v - old  
     
    582 586         # send changes  
    583 587         try: # how many retries  
      588             if debug: print "sent this:", parms, local_changes  
    584 589             result, version = server.commit_changes(parms, local_changes)  
      590             if debug: print "received this:", result, version  
    585 591             if result == []:  
    586 592                 if debug: print "That went well!"  
     
    622 628  
    623 629     answer = dlg.Update(10, "Getting updates from server")  
      630     try:  
    624 631  
    625       if not GetData():  
    626           if debug: print "Couldn't get data from server"  
    627           # return  
    628       else:  # we got the data  
    629           answer = dlg.Update(50, "Sending update to server")  
    630           while LocalRowsAdded():  # new report rows (probably)  
    631               if debug: print "Local rows added %d" % LocalRowsAdded()  
    632               if not GetData():  # repeat until we don't add any more rows in response to server  
    633                   if debug: print "Couldn't get data on repeat"  
    634                   return  
    635           if not SendData():  
    636               if debug: print "Couldn't send data to server"  
      632         if not GetData():  
      633             if debug: print "Couldn't get data from server"  
    637 634             # return  
    638           else: # we sent the data  
    639               answer = dlg.Update(80, "Updating the display")  
    640               pass  
    641       # Data.SetUndo("Commit")  # Can't do this until after our changes are sent to the server  
    642                               # PROBLEM - don't want risk adding rows until aftter  
    643                               # OK?? Adjusting report rows at the end of GetData  
    644                               # oops. Set undo won't update the display unless it thinks something has changed!  
    645       # not adjusting rows, because that was already done after applying changes from server  
      635         else:  # we got the data  
      636             save_server_prior = server_prior_nextid.copy()  # save original server prior (set by GetData)  
      637             repeatcount = 0  
      638             answer = dlg.Update(50, "Sending update to server")  
      639             while LocalRowsAdded():  # new report rows (probably)  
      640                 repeatcount += 1  
      641                 if repeatcount > 10: print "repeatcount = 10"; return  
      642                 if debug: print "Local rows added %d" % LocalRowsAdded()  
      643                 if not GetData():  # repeat until we don't add any more rows in response to server  
      644                     if debug: print "Couldn't get data on repeat"  
      645                     return  
      646             server_prior_nextid = save_server_prior  # use the values set by first GetData  
      647             if not SendData():  
      648                 if debug: print "Couldn't send data to server"  
      649                 # return  
      650             else: # we sent the data  
      651                 answer = dlg.Update(80, "Updating the display")  
      652                 pass  
      653         # Data.SetUndo("Commit")  # Can't do this until after our changes are sent to the server  
      654                                 # PROBLEM - don't want risk adding rows until aftter  
      655                                 # OK?? Adjusting report rows at the end of GetData  
      656                                 # oops. Set undo won't update the display unless it thinks something has changed!  
      657         # not adjusting rows, because that was already done after applying changes from server  
      658  
      659     finally:  
      660         answer = dlg.Update(100, "Complete")  
      661         dlg.Destroy()  
      662  
      663     if debug: print "start final clean up"  
    646 664     Data.UndoStack = []  
    647 665     Data.RedoStack = []  
     
    649 667     Data.ChangedCalendar = True  # force all calculations (just in case)  
    650 668     Data.Recalculate()  # this also refreshes the reports  
    651    
    652       answer = dlg.Update(100, "Complete")  
    653       dlg.Destroy()  
      669     if debug: print "end final clean up"  
    654 670  
    655 671     # NOTE - not really undoable, should clear undo stack,