Changes between Initial Version and Version 1 of CodeSamples/Other/MaestroScripts/FeatureSourceFindAndReplace


Ignore:
Timestamp:
Apr 4, 2014, 2:25:30 AM (10 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodeSamples/Other/MaestroScripts/FeatureSourceFindAndReplace

    v1 v1  
     1[[PageOutline]]
     2
     3This page is one of the !MapGuide Community CodeSamples.  Visit the CodeSamples page to view more!
     4
     5This 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"
     6
     7=== How to use this script ===
     8
     9 1. Launch MapGuide Maestro
     10 2. In the '''IronPython''' console, click '''Run File'''
     11 3. Browse to '''replace_connection_utils.py''' and click '''Open''' to load this script
     12
     13Once loaded, you will have the following functions available for you to use from the IronPython console:
     14
     15{{{
     16#!python
     17def UpdateLayersFeatureSource(conn, folder, oldF, newF):
     18    """
     19    Modifies the featuresource of layerdefinition matching the old featuresource name
     20    """
     21}}}
     22
     23=== Usage ===
     24{{{
     25#!python
     26conn = app.GetConnection('http://yourserver/mapserver2012 (v2.3.0.4202)')
     27UpdateLayersFeatureSource(conn,'Library://map/Layers/','Library://map/data/cnx_DEV.FeatureSource','Library://map/cnx_PROD.FeatureSource')
     28}}}