RHpec0312

Update Cursor in SDE and  RuntimeError: start edit session

Discussion created by RHpec0312 on Mar 26, 2014
                        option = pythonaddins.MessageBox("Is this information correct? {}".format(viewlist[0]),"Question",4)
                        if option == "Yes":
                            entry = viewlist[0]
                            values = [entry[1],int(entry[2]),entry[3]]
                            edit = da.Editor(workspace)
                            edit.startEditing(False, True)
                            edit.startOperation()
                            print "Operation Started.  Is Editing? {}".format(edit.isEditing)
                           
                            with da.UpdateCursor(targetlayer,updatefields) as cursor:
                                    for row in cursor:
                                        row = values
                                        cursor.updateRow(row)

                            del cursor
                            del row
                            print "Cursor Cleared"

                            edit.stopOperation()
                            print "Operation Stopped.  Is Editing? {}".format(edit.isEditing)
                            edit.stopEditing(True)
                            print "Editing Stopped.  Is Editing? {}".format(edit.isEditing)




When in an editing session in ArcMap 10.2.1 I am running the update cursor on a feature that already has attributes in the fields I am updating (like from a template),  I receive

Operation Started.  Is Editing? True
Cursor Cleared
Operation Stopped.  Is Editing? True

Traceback (most recent call last):
  File "C:\Users\RHpec0312\AppData\Local\ESRI\Desktop10.2\AssemblyCache\{4DA62CAF-5C0F-4423-B752-82E1F84D8B4D}\Drops_addin.py", line 725, in onRectangle
    edit.stopEditing(True)
RuntimeError: start edit session


The attributes are updated in the attribute table but I am unable to save the edits.  Instead I receive an error about the geodatabase being in a closed state.  There is a little bit of information on the Editor Class Page that talks about initializing a cursor for each editing operation.  That cursors should not be used in multiple operations due to the state of the geodatabase being tied to the cursor.  Any help is greatly appreciated.

Richard

Outcomes