indico / indico/flask-pluginengine

How does it interact with Flask-Restful?

Open
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
24
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Hi! I decided to build an application using the Flask-Pluginengine architecture. I'm trying to create it as a RESTful service that feeds an Angular frontend. To build it I use the Flask Restful extension library to organize the code.

Currently I'm using this hacky version of my code to work with Plugins, but I'd like to know if there's a more proper way to integrate Flask-Restful and Flask-PluginEngine. Thanks for this amazing work!

App structure:

MainApp.py
plugins
-----test
---------setup.py
---------TestPlug.py

MainApp.py

#Import Flask library and dependencies.
from flask import Flask
#Import Flask Restful.
from flask_restful import Resource, Api, reqparse

#Import library to allow Plugin modules.
from flask_pluginengine import PluginFlask, PluginEngine

#Define a new flask App.
app = PluginFlask(__name__)
#Transform the App into a Restful instance.
api = Api(app)

#Initialize Flask plugin.
app.config['PLUGINENGINE_NAMESPACE'] = 'plugins'
app.config['PLUGINENGINE_PLUGINS'] = ['testplug']
#Load the Plugins available.
plugin_engine = PluginEngine(app=app)
plugin_engine.load_plugins(app)
active_plugins = plugin_engine.get_active_plugins(app=app).values()
print(active_plugins)

PluginCode called TestPlug.py

from flask_pluginengine import Plugin
from flask_app import Resource, api

class TestPlugin(Plugin):
    def get(self):
        print("It works!!!")

class TestPluginCode(Resource):
    def get(self):
        return "It works!!!"

api.add_resource(TestPluginCode, "/testplug")

Setup file for the plugin called setup.py

from setuptools import setup

setup(
        name='testPlugin',
        version='0.0.1',
        #Module that you'll be using.
        py_modules=['testplug'],
        entry_points={'plugins': {'testplug=TestPlug:TestPlugin'}}
        )

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the integration shown in MainApp.py and TestPlug.py, along with the plugin packaging in setup.py, then compare it with Flask-Restful's documented application setup. Done means identifying and documenting a supported integration approach, ideally with a working example that loads a plugin and exposes its resource through the API.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, flask, python
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.