wiki:CodeSamples/Other/MaestroScripts/FeatureSourceFindAndReplace

This page is one of the MapGuide Community CodeSamples. Visit the CodeSamples page to view more!

This is a simple script to update all your layers featuresource from one to another (e.g. : all your layers feature source from dev environnement to production environnement) . It only change the source, you have to use the same schema in your environnements. It check if the layer featuresource match "oldF" then replace it with "newF"

How to use this script

  1. Launch MapGuide Maestro
  2. In the IronPython? console, click Run File
  3. Browse to replace_connection_utils.py and click Open to load this script

Once loaded, you will have the following functions available for you to use from the IronPython? console:

def UpdateLayersFeatureSchema(conn, folder, oldSchema, newSchema):
    """
    Modifies the featuresource of layerdefinition matching the old featureschema name
    """
def UpdateLayersFeatureSource(conn, folder, oldF, newF):
    """
    Modifies the featuresource of layerdefinition matching the old featuresource name
    """

Usage

conn = app.GetConnection('http://yourserver/mapserver2012 (v2.3.0.4202)')
UpdateLayersFeatureSource(conn,'Library://map/Layers/','Library://map/data/cnx_DEV.FeatureSource','Library://map/cnx_PROD.FeatureSource')
Last modified 4 years ago Last modified on Apr 4, 2014 2:29:46 AM

Attachments (1)

Download all attachments as: .zip