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))
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))
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()
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]
def init_model(engine): """Call me before using any of the tables or classes in the model""" Session.configure(bind=engine)
def getIdByName(self, name=''): id = s.query(DeactivatedPlugins.id).\ filter(DeactivatedPlugins.name==name).first() return id[0]