| 1 | [[PageOutline]] |
| 2 | |
| 3 | This page is one of the !MapGuide Community CodeSamples. Visit the CodeSamples page to view more! |
| 4 | |
| 5 | 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" |
| 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 | |
| 13 | Once loaded, you will have the following functions available for you to use from the IronPython console: |
| 14 | |
| 15 | {{{ |
| 16 | #!python |
| 17 | def 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 |
| 26 | conn = app.GetConnection('http://yourserver/mapserver2012 (v2.3.0.4202)') |
| 27 | UpdateLayersFeatureSource(conn,'Library://map/Layers/','Library://map/data/cnx_DEV.FeatureSource','Library://map/cnx_PROD.FeatureSource') |
| 28 | }}} |