another question - same script - previous post "new to python - trouble with ..."

685
2
04-19-2011 01:46 PM
TerrySilveus
Occasional Contributor III
In my script (you can see it here http://forums.arcgis.com/threads/28628-new-to-python-trouble-with-error-trapping) I am opening a search cursor with a where clause and modifying an update cursor based on some content found in the search cursor.  Before that, I check to see if the field to modify is present, and if not I add it.  I'm seeing certain behavior and I need to understand if this is what is expected.

1) Running from WinPy, if I have the map document open with these datasets, then nothing happens.  No field addition, no update. (Understandable because the table is open)

2) Running as a script tool from within arcGIS, if I have the attribute table open, the field gets added, but not update of contents occur.

3) Running as script tool from within arcGIS, if I do not have the attribute table open, the field gets added and the contents of the field are updated.

My question is with what happens in 2 above.  I would think that it would have more of a problem adding the field than it would have updating a field if it exists.  And in 1 above, why would it behave any different with a table open and locked than the behavior seen in step 2.  I would think if a write were going to be denied because of locking issues, it would be denied in the same way for both scenarios.

Is the behavior I've observed typical locking behavior between python and arcGIS?
Tags (2)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus
From experience, either run the tool from Arctoolbox within an ArcMap (not a script outside of ArcToolbox while arcmap is running) or don't crank up Arcmap at all.
0 Kudos
TerrySilveus
Occasional Contributor III
I think that is what I am doing in 2 and 3 of my post.  I have my script in a toolbox and am running it from that tool box.  But the only way it completely works is if the attribute table is not open. It can be a layer in the TOC and turned on, but it cannot be open for viewing the attribute table.
0 Kudos