The example of creating a plugin

Directory with plugins for installed application: /var/www/geomongo/plugins.

To create a plugin you have to:

  • create a directory the name of which should be written by latin lowercase letters, words should be divided by underscores;
  • create empty file  in order for this directory could be python-package;
  • create file with two functions getPluginInfo() and getPluginResources().

getPluginInfo() returns the information about the plugin;  getPluginResources() is the dictionary which contains couples ‘link’: Resource’s derived class.


Let there are two classes-resource that we want to turn into a plugin.
 from flask.ext.restful import Resource
 class TestResource1(Resource):
   def get(self):
     return 'test_resource_1'
from flask.ext.restful import Resource
class TestResource2(Resource):
   def get(self):
     return 'test_resource_2'

It’s necessary to connect both classes in

# required hack in order for resource of plugin could be visible (
from test_resource_1 import TestResource1
from test_resource_2 import TestResource2

and create mandatory functions for the plugin:

def getPluginResources():
    result = {'res1': TestResource1, 'res2':TestResource2}  
    return result

def getPluginInfo():
    info = 'This plugin was creating for present plugins feature. The function getPluginResources is for return TestResource1 and TestResource2 '
    return info

Then you have to create the directory /var/www/geomongo/plugins/test_plugin and place into it files,, and empty file

Next, you need to restart the web server to run the plugins up.

   sudo service apache2 restart

After that, the plugins will be available at:



ShareShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VKEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *