Bug ID Number |
NIM058538 |
Submitted | June 24, 2010 |
Last Modified | June 5, 2024 |
Applies to | No Product Found |
Version found | 10.0 Beta |
Version Fixed | 10.1 |
Status | Fixed
The bug has been fixed. See the Version Fixed and Additional Information, if applicable, for more information.
|
Description
The ArcPy mapping module provides a number of methods that allow changes to a layer's workspace path or data source. These methods include:
MapDocument.findAndReplaceWorkspacePaths
MapDocument.replaceWorkspaces
Layer.findAndReplaceWorkspacePath
Layer.replaceDataSource
Table.findAndReplaceWorkspacePath
Table.replaceDataSource
Replacing the SDE connection properties for layers is a supported workflow. However, in cases where a layer's SDE connection where the credentials (username & password) are in one state (saved/not saved) are being replaced with a connection with a different saved/not saved state, the new state is not honored.
For example, there may be a map with layers originally using an SDE connection where the credential are saved (there is no prompt to enter credentials when opening the map). Replace the layers with a SDE connection where the credentials are not saved. There is an expectation that the next time the map is opened there will be a prompt for credentials - the layer should now be using a connection where this information is not saved. Instead, there is still no prompt for credentials.
Cause
This is a known limitation at ArcGIS 10 when using a local path to the SDE connection file.
For example, the following code does not update credentials:
Code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Data\Sde Map.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Data\MyServer.sde",
r"C:\Data\MyServer Enter Credentials.sde")
mxd.saveACopy(r"C:\Data\Sde Map Output.mxd")
del mxd
Note:
Use bug NIM058538 when referencing this issue.
Workaround
Use a UNC path to point to the new sde connection files. For example:
Code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Data\Sde Map.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Data\MyServer.sde",
r"\\10FinalXp\Data\MyServer Enter Credentials.sde")
mxd.saveACopy(r"C:\Data\Sde Map Output.mxd")
del mxd
Steps to Reproduce