The challenge with the del row, rows is that it is outside the loop and the layer is locked at that point. I ended up creating a Line number array first, the performing the del row, rows and referencing the array during the loop.
rows = arcpy.SearchCursor("Points")
# Get a list of all the line numbers that we need to have transformers moved back onto the line
x=0
LineIDList = []
for row in rows:
if row.getValue("line_id") not in LineIDList:
x=x+1
LineIDList.append(row.getValue("line_id"))
print str(x) + " Lines to have points that have been moved"
try:
del row
except:
print arcpy.GetMessages(2)
try:
del rows
except:
print arcpy.GetMessages(2)
#now actually move those points
for count in range(0,x):
for lyr in arcpy.mapping.ListLayers(mxd):
lyrname = lyr.name
#for what ever reason, you can not use an = in the next statement
if lyr.name in ["AllLines"]:
#print "LINENUMBER = '" + LineIDList[count] + "'"
lyr.definitionQuery = "LINENUMBER = '" + LineIDList[count] + "'"
if lyr.name in ["Points"]:
lyr.definitionQuery = "line_id = '" + LineIDList[count] + "'"
try:
snapEnv = ["AllLines", "EDGE", "2 Meters"]
arcpy.Snap_edit("Points", [snapEnv])
#print "Got Snapped"
except:
print arcpy.GetMessages(2)