@@ -97,7 +97,6 @@ def initInterface(pointer):
97
97
global iface
98
98
iface = wrapinstance (pointer , QgisInterface )
99
99
100
-
101
100
#######################
102
101
# PLUGINS
103
102
@@ -208,7 +207,7 @@ def startPlugin(packageName):
208
207
plugins [packageName ] = package .classFactory (iface )
209
208
except :
210
209
_unloadPluginModules (packageName )
211
- msg = QCoreApplication .translate ("Python" , "%s due an error when calling its classFactory() method" ) % errMsg
210
+ msg = QCoreApplication .translate ("Python" , "%s due to an error when calling its classFactory() method" ) % errMsg
212
211
showException (sys .exc_type , sys .exc_value , sys .exc_traceback , msg )
213
212
return False
214
213
@@ -218,7 +217,7 @@ def startPlugin(packageName):
218
217
except :
219
218
del plugins [packageName ]
220
219
_unloadPluginModules (packageName )
221
- msg = QCoreApplication .translate ("Python" , "%s due an error when calling its initGui() method" ) % errMsg
220
+ msg = QCoreApplication .translate ("Python" , "%s due to an error when calling its initGui() method" ) % errMsg
222
221
showException (sys .exc_type , sys .exc_value , sys .exc_traceback , msg )
223
222
return False
224
223
@@ -447,6 +446,57 @@ def wrapper(func):
447
446
return f
448
447
return wrapper
449
448
449
+ #######################
450
+ # SERVER PLUGINS
451
+ #
452
+ # TODO: move into server_utils.py ?
453
+
454
+ # list of plugin paths. it gets filled in by the QGIS python library
455
+ server_plugin_paths = []
456
+
457
+ # dictionary of plugins
458
+ server_plugins = {}
459
+
460
+ # list of active (started) plugins
461
+ server_active_plugins = []
462
+
463
+
464
+ # initialize 'serverIface' object
465
+ serverIface = None
466
+
467
+ def initServerInterface (pointer ):
468
+ from qgis .server import QgsServerInterface
469
+ from sip import wrapinstance
470
+ global serverIface
471
+ serverIface = wrapinstance (pointer , QgsServerInterface )
472
+
473
+
474
+
475
+ def startServerPlugin (packageName ):
476
+ """ initialize the plugin """
477
+ global server_plugins , server_active_plugins , serverIface
478
+
479
+ if packageName in server_active_plugins : return False
480
+ if packageName not in sys .modules : return False
481
+
482
+ package = sys .modules [packageName ]
483
+
484
+ errMsg = QCoreApplication .translate ("Python" , "Couldn't load server plugin %s" ) % packageName
485
+
486
+ # create an instance of the plugin
487
+ try :
488
+ server_plugins [packageName ] = package .serverClassFactory (serverIface )
489
+ except :
490
+ _unloadPluginModules (packageName )
491
+ msg = QCoreApplication .translate ("Python" , "%s due to an error when calling its serverClassFactory() method" ) % errMsg
492
+ showException (sys .exc_type , sys .exc_value , sys .exc_traceback , msg )
493
+ return False
494
+
495
+ # add to active plugins
496
+ server_active_plugins .append (packageName )
497
+ return True
498
+
499
+
450
500
#######################
451
501
# IMPORT wrapper
452
502
0 commit comments