AnsweredAssumed Answered

How to do Editor abort on AGOL REST endpoint

Question asked by don.morrison on Dec 5, 2019
Latest reply on Dec 16, 2019 by don.morrison

I have a python program does does a series of updates on a group of feature classes that it accesses via an ArcGIS online REST endpoint that proxies the request to my ArcGIS server. I want to be able to back out the updates if something goes wrong but I can't get it to work. I reduced the code as shown below. The code sets an initial value , performs 3 updates (each with a new cursor, since in my real code I have to make multiple passes over the data), then aborts the edit session. If I run this against a file geodatabase it works as expected where at the end the records have the "original value". However if I run it against the ArcGIS Online REST endpoint it ends up with the 2nd update ('Edited -2') - as if only the data updated by the last cursor was backed off.

 

I'm running this with arcpy that got installed with ArcPro (currently at 2.4.2)  and Python 3.6.8 and Advanced license.

 

import arcpy

 

 

workspace = 'https://utility.arcgis.com/usrsvcs/servers/383d3cf85e8a41e9b7e8a5e9e8bb90b9/rest/services/ROW_testing/ERC/FeatureServer'
fc = workspace + '/0'

 

# Set initial values
with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Original value'])

 

edit = arcpy.da.Editor(workspace)
edit.startEditing(True, False)
edit.startOperation()

 

with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Edited - 1'])
       
with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Edited - 2'])
               
with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Edited - 3'])        
       
edit.abortOperation()
edit.stopEditing(False)

Outcomes