Objects in this class cannot be updated outside an edit session

17049
5
Jump to solution
02-07-2014 06:53 AM
JordanParfitt
Occasional Contributor
I keeping getting the "Objects in this class cannot be updated outside an edit session" error message. I can't figure out why because it seems to be I'm opening an edit session. Is there a step I'm missing?

Thank you in advance.


 arg_sdeDEV_sde = "Database Connections\\arg@sdeDEV.sde" ARG_ACCESS_OPENING = "Database Connections\\arg@sdeDEV.sde\\ARG.DistributionSystem\\ARG.ACCESS_OPENING" ACCESS_OPENING_Layer = "ACCESS_OPENING_Layer" Reconcile_Versions_Log = ""   # Process: Make Feature Layer tempEnvironment0 = arcpy.env.workspace arcpy.env.workspace = "Database Connections\\arg@sdeDEV.sde" arcpy.env.overwriteOutput = True arcpy.MakeFeatureLayer_management(ARG_ACCESS_OPENING, ACCESS_OPENING_Layer, "", arg_sdeDEV_sde, "OBJECTID OBJECTID VISIBLE NONE;OPEN_TYPE OPEN_TYPE VISIBLE NONE;REC_INFO_NAME REC_INFO_NAME VISIBLE NONE") arcpy.env.workspace = tempEnvironment0  # Process: Start Edit edit = arcpy.da.Editor(arcpy.env.workspace) edit.startEditing(True, False) edit.startOperation()  # Process: Select and Update Data cursor = arcpy.UpdateCursor(ARG_ACCESS_OPENING) for row in cursor:     row.setValue("STRUCTURE_ID", row.getValue("ENCLOSURE_ID"))     cursor.updateRow(row)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JordanParfitt
Occasional Contributor
I created a new SDE connection with the default version pointing to the version I wanted to edit, eliminating the need to change versions pro grammatically. Hope this helps someone else.

-Jordan

View solution in original post

5 Replies
NeoGeo
by
Occasional Contributor III
startEditing ({with_undo}, {multiuser_mode})
for with_undo, start session without an undo/redo stack for versioned data
for multiuser_mod, use False for unversioned data

If your sde layer is versioned, you might try
edit.startEditing(False, True)
0 Kudos
JordanParfitt
Occasional Contributor
When I do edit.startEditing(False, True) it breaks on that same line and I get the error "Operation only allowed by the owner of the version [SDE.DEFAULT]"

It's almost like it's not changing the version when I execute this:

# Process: Change Version
arcpy.ChangeVersion_management(ACCESS_OPENING_Layer, "TRANSACTIONAL", "ARG.ARG_PARENT", "")
0 Kudos
JordanParfitt
Occasional Contributor
I should mention this is my new code, I added the change version piece:



# Set the necessary product code
import arceditor

# Import arcpy module
import arcpy
arg_sdeDEV_sde = "Database Connections\\arg@sdeDEV.sde"
ARG_ACCESS_OPENING = "Database Connections\\arg@sdeDEV.sde\\ARG.DistributionSystem\\ARG.ACCESS_OPENING"
ACCESS_OPENING_Layer = "ACCESS_OPENING_Layer"
Reconcile_Versions_Log = ""

# Process: Make Feature Layer
tempEnvironment0 = arcpy.env.workspace
arcpy.env.workspace = "Database Connections\\arg@sdeDEV.sde"
arcpy.env.overwriteOutput = True
arcpy.MakeFeatureLayer_management(ARG_ACCESS_OPENING, ACCESS_OPENING_Layer, "", arg_sdeDEV_sde, "OBJECTID OBJECTID VISIBLE NONE;OPEN_TYPE OPEN_TYPE VISIBLE NONE;REC_INFO_NAME REC_INFO_NAME VISIBLE NONE")
arcpy.env.workspace = tempEnvironment0

# Process: Change Version
arcpy.ChangeVersion_management(ACCESS_OPENING_Layer, "TRANSACTIONAL", "ARG.ARG_PARENT", "")

# Process: Start Edit
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing(False, True)
edit.startOperation()

# Process: Select and Update Data
cursor = arcpy.UpdateCursor(ARG_ACCESS_OPENING)
for row in cursor:
    row.setValue("STRUCTURE_ID", row.getValue("ENCLOSURE_ID"))
    cursor.updateRow(row)
0 Kudos
JordanParfitt
Occasional Contributor
I created a new SDE connection with the default version pointing to the version I wanted to edit, eliminating the need to change versions pro grammatically. Hope this helps someone else.

-Jordan
JoshuaBixby
MVP Esteemed Contributor

Reply moved and started as a new question since issue isn't ArcPy or Python related.

0 Kudos