I have defined the workspace, started and stopped the edit session, but afterwards, I am getting the Runtime Error (Objects in this class cannot be updated outside an edit session). The layer "CGD. ROAD_LOCATIONS" is versioned.
arcpy.env.workspace = r"\\Pas215q4\User Connection\GS-0001.database.windows.net(1).sde"
edit = arcpy.da.Editor(arcpy.env.workspace)
field = ['SECTION_ID']
found_values = defaultdict(set)
with arcpy.da.UpdateCursor("CGD.ROAD_LOCATIONS", field, "[OBJECTID] > 944861") as cursor:
for row in cursor:
for i, column in enumerate(field):
if row[i] in found_values[column]:
for column, value in zip(field, row):
When running this it breaks in (“for row in cursor”), and I am getting the following error message,
Traceback (most recent call last):
File "P:\Create_Assets.py", line 152, in <module>
File " P:\Create_Assets.py", line 52, in main
for row in cursor:
RuntimeError: Objects in this class cannot be updated outside an edit session [CGD. ROAD_LOCATIONS]
No issue with the indentation, maybe I have missed the proper indent here as I am typing it manually. No issue with the script while running from the admin account, but other user accounts is experiencing the run-time issue.
Great to have your suggestions on how to solve this issue please.
No issue with the script while running from the admin account, but other user accounts is experiencing the run-time issue.
strongly indicates there is a permissions issue happening, whether by design or a defect.
If non-admin users try the workflow manually in the application, do they get the same error?
If non-admin users try the workflow manually in the application, do they get the same error? Yes.
The users have full access to the .sde feature class ("CGD.ROAD_LOCATIONS") and versioning completed. So, I believe there is little chance of permission issue. Do you think there might be some other reasons?
If it works for admin users and not regular users whether using ArcPy or the GUI, it is permissions related. The question is whether there is a workflow issue or defect. Without knowing a bit more about the overall workflow, e.g., versioning steps before you get to the functional code part above, I can't offer much on that front. I would suggest you have your DBA look at the database logs because there may be errors showing up there that could point you in the right direction.