Skip to content
Permalink
Browse files

Added serve python plugins

  • Loading branch information
elpaso committed Oct 9, 2014
1 parent 98cab97 commit f2608b308fb844affbe30eef5935e13ce42c5a58
Showing with 53 additions and 3 deletions.
  1. +53 −3 python/utils.py
@@ -97,7 +97,6 @@ def initInterface(pointer):
global iface
iface = wrapinstance(pointer, QgisInterface)


#######################
# PLUGINS

@@ -208,7 +207,7 @@ def startPlugin(packageName):
plugins[packageName] = package.classFactory(iface)
except:
_unloadPluginModules(packageName)
msg = QCoreApplication.translate("Python", "%s due an error when calling its classFactory() method") % errMsg
msg = QCoreApplication.translate("Python", "%s due to an error when calling its classFactory() method") % errMsg
showException(sys.exc_type, sys.exc_value, sys.exc_traceback, msg)
return False

@@ -218,7 +217,7 @@ def startPlugin(packageName):
except:
del plugins[packageName]
_unloadPluginModules(packageName)
msg = QCoreApplication.translate("Python", "%s due an error when calling its initGui() method" ) % errMsg
msg = QCoreApplication.translate("Python", "%s due to an error when calling its initGui() method" ) % errMsg
showException(sys.exc_type, sys.exc_value, sys.exc_traceback, msg)
return False

@@ -447,6 +446,57 @@ def wrapper(func):
return f
return wrapper

#######################
# SERVER PLUGINS
#
# TODO: move into server_utils.py ?

# list of plugin paths. it gets filled in by the QGIS python library
server_plugin_paths = []

# dictionary of plugins
server_plugins = {}

# list of active (started) plugins
server_active_plugins = []


# initialize 'serverIface' object
serverIface = None

def initServerInterface(pointer):
from qgis.server import QgsServerInterface
from sip import wrapinstance
global serverIface
serverIface = wrapinstance(pointer, QgsServerInterface)



def startServerPlugin(packageName):
""" initialize the plugin """
global server_plugins, server_active_plugins, serverIface

if packageName in server_active_plugins: return False
if packageName not in sys.modules: return False

package = sys.modules[packageName]

errMsg = QCoreApplication.translate("Python", "Couldn't load server plugin %s" ) % packageName

# create an instance of the plugin
try:
server_plugins[packageName] = package.serverClassFactory(serverIface)
except:
_unloadPluginModules(packageName)
msg = QCoreApplication.translate("Python", "%s due to an error when calling its serverClassFactory() method") % errMsg
showException(sys.exc_type, sys.exc_value, sys.exc_traceback, msg)
return False

# add to active plugins
server_active_plugins.append(packageName)
return True


#######################
# IMPORT wrapper

0 comments on commit f2608b3

Please sign in to comment.
You can’t perform that action at this time.