Ejemplo n.º 1
0
    def delete(self, id):
        plugin = s.query(DeactivatedPlugins).\
                filter(DeactivatedPlugins.id == id).first()
        s.delete(plugin)
        s.commit()

        c.http_referer = str(request.environ.get('HTTP_REFERER', ''))\
                         or str(request.params.get('came_from', ''))\
                         or url('/')
        redirect(url(c.http_referer))
Ejemplo n.º 2
0
    def create(self):
        new_deactivated = DeactivatedPlugins()
        new_deactivated.name = request.GET['name']
        s.add(new_deactivated)
        s.commit()

        c.http_referer = str(request.environ.get('HTTP_REFERER', ''))\
                         or str(request.params.get('came_from', ''))\
                         or url('/')
        redirect(url(c.http_referer))
Ejemplo n.º 3
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        # WSGIController.__call__ dispatches to the Controller method
        # the request is routed to. This routing information is
        # available in environ['pylons.routes_dict']

        # Plugin uploads
        c.plugin_manager, c.deactivated_plugins = plugins.load_plugins()

        # Plugin menu uploads
        c.plugin_menu = []
        for plugin in c.plugin_manager.getPluginsOfCategory("Menu"):
            c.plugin_menu.append(plugin.plugin_object.get_html_menu())

        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
Ejemplo n.º 4
0
def load_plugins():
    """ Load plugin for environment. See lib/base.py
    """
    # Create plugin manager
    manager = PluginManager()
    # Tell it the default place(s) where to find plugins
    manager.setPluginPlaces(["pylons_yapsy_plugin/plugins/"])
    # Define the various categories corresponding to the different
    # kinds of plugins you have defined
    manager.setCategoriesFilter({
        "Menu" : menu.Menu,
        "Inline" : inline.Inline,
        })

    manager.locatePlugins()

    # Deactivate plugin
    # Список деактивированных плагинов из БД
    deactivatedPlugins = [plugin.name for plugin in\
            s.query(DeactivatedPlugins).all()]

    # Список кандидатов на загрузку
    candidates = manager.getPluginCandidates()
    # Список деактивированных плагинов в формате yapsy
    deactivatedList = []

    for candidate in candidates:
        if candidate[2].name in deactivatedPlugins:
            deactivatedList.append(candidate)

    # Исключаем плагины которые указанны в БД
    for plugin in deactivatedList:
        manager.removePluginCandidate(plugin)

    # Load plugins
    manager.loadPlugins()

    return manager, [plugin[2] for plugin in deactivatedList]
Ejemplo n.º 5
0
def init_model(engine):
    """Call me before using any of the tables or classes in the model"""
    Session.configure(bind=engine)
Ejemplo n.º 6
0
 def getIdByName(self, name=''):
     id = s.query(DeactivatedPlugins.id).\
                 filter(DeactivatedPlugins.name==name).first()
     return id[0]