consolidate manager-componets

This commit is contained in:
Martijn Voncken 2008-03-21 18:31:27 +00:00
parent dcc10b7819
commit 0eaa0aca27
7 changed files with 96 additions and 231 deletions

View File

@ -1,20 +0,0 @@
0.5.7
SSL
torrent/add http-post for private sites
rename reannounce->update-tracker.
queued displays as seeding/downloading
0.5.7 advanced layout
fonts
fix auto-refresh-layout
buttons
hide 0.0 kbps like in gtk-ui
update-tracker.
0.6
prepare for cat:
filters on status (prepare for cat)
filters on tracker
categories
greasemonkey : private sites.

View File

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# #
# Copyright (C) Martijn Voncken 2007 <mvoncken@gmail.com> # Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -32,12 +32,24 @@
# #
""" """
register toolbar and menu items. deluge components.
future : required for plugin-api.
""" MenuManager:add torrent-menu-items and torrent-detail tabs.
from utils import logcall PageManager: add pages(urls)
from render import template PluginManager: deluge plugin manager
ConfigPageManager: add config pages(tabs)
These managers/components are accesible as:
from deluge import component from deluge import component
manager = component.get("ClassName")
"""
from deluge import component
import lib.newforms_plus as forms
from deluge.ui.client import aclient
from deluge import component, pluginmanagerbase
from deluge.configmanager import ConfigManager
class TOOLBAR_FLAGS: class TOOLBAR_FLAGS:
generic = 0 generic = 0
@ -54,6 +66,7 @@ class MenuManager(component.Component):
#register vars in template. #register vars in template.
from render import template
template.Template.globals["admin_pages"] = self.admin_pages template.Template.globals["admin_pages"] = self.admin_pages
template.Template.globals["detail_tabs"] = self.detail_tabs template.Template.globals["detail_tabs"] = self.detail_tabs
template.Template.globals["toolbar_items"] = self.toolbar_items template.Template.globals["toolbar_items"] = self.toolbar_items
@ -88,5 +101,77 @@ class MenuManager(component.Component):
del self.detail_tabs[i] del self.detail_tabs[i]
return return
__menu_manager = MenuManager() class PageManager(component.Component):
"""
web,py 0.2 mapping hack..
see deluge_webserver.py
"""
def __init__(self):
component.Component.__init__(self, "PageManager")
self.page_classes = {}
self.urls = []
def register_pages(self, url_list, class_list):
self.urls += url_list
self.page_classes.update(class_list)
def register_page(self, url, klass):
self.urls.append(url)
self.urls.append(klass.__name__)
self.page_classes[klass.__name__] = klass
def unregister_page(self, url):
raise NotImplemenetedError()
#self.page_classes[klass.__name__] = None
class PluginManager(pluginmanagerbase.PluginManagerBase,
component.Component):
def __init__(self):
component.Component.__init__(self, "WebPluginManager")
self.config = ConfigManager("webui.conf")
pluginmanagerbase.PluginManagerBase.__init__(
self, "webui.conf", "deluge.plugin.webui")
def start(self):
"""Start the plugin manager"""
# Update the enabled_plugins from the core
aclient.get_enabled_plugins(self._on_get_enabled_plugins)
def stop(self):
# Disable the plugins
self.disable_plugins()
def _on_get_enabled_plugins(self, enabled_plugins):
log.debug("Webui has these plugins enabled: %s", enabled_plugins)
self.config["enabled_plugins"] = enabled_plugins
# Enable the plugins that are enabled in the config and core
self.enable_plugins()
class ConfigPageManager(component.Component):
def __init__(self):
component.Component.__init__(self, "ConfigPageManager")
self.groups = []
self.blocks = forms.utils.datastructures.SortedDict()
def register(self, group, name, form):
if not group in self.groups:
self.groups.append(group)
form.group = group
self.blocks[name] = form
def unregister(self, name):
del self.blocks[name]
def register():
__plugin_manager = PluginManager()
__menu_manager = MenuManager()
__page_manager = PageManager()
__config_page_manager = ConfigPageManager()

View File

@ -1,58 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# You must obey the GNU General Public License in all respects for all of
# the code used other than OpenSSL. If you modify file(s) with this
# exception, you may extend this exception to your version of the file(s),
# but you are not obligated to do so. If you do not wish to do so, delete
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
from utils import logcall
from render import template
from deluge import component
import lib.newforms_plus as forms
class ConfigPageManager(component.Component):
def __init__(self):
component.Component.__init__(self, "ConfigPageManager")
self.groups = []
self.blocks = forms.utils.datastructures.SortedDict()
def register(self, group, name, form):
if not group in self.groups:
self.groups.append(group)
form.group = group
self.blocks[name] = form
def unregister(self, name):
del self.blocks[name]
__config_page_manager = ConfigPageManager()

View File

@ -34,6 +34,7 @@ import locale
from deluge.configmanager import ConfigManager from deluge.configmanager import ConfigManager
import pkg_resources import pkg_resources
from deluge.ui.client import sclient from deluge.ui.client import sclient
import components
# Initialize gettext # Initialize gettext
locale.setlocale(locale.LC_MESSAGES, '') locale.setlocale(locale.LC_MESSAGES, '')
@ -49,12 +50,7 @@ gettext.install("deluge",
pkg_resources.resource_filename( pkg_resources.resource_filename(
"deluge", "i18n")) "deluge", "i18n"))
components.register() #after gettext!!
#self registering components:
import plugin_manager #registers as "WebPluginManager"
import menu_manager #registers as "MenuManager"
import config_page_manager #registers as "ConfigPageManager"
import page_manager #registers as "PageManager"
from debugerror import deluge_debugerror from debugerror import deluge_debugerror
from render import render from render import render

View File

@ -1,69 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
# Copyright (C) Martijn Voncken 2007 <mvoncken@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# You must obey the GNU General Public License in all respects for all of
# the code used other than OpenSSL. If you modify file(s) with this
# exception, you may extend this exception to your version of the file(s),
# but you are not obligated to do so. If you do not wish to do so, delete
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
#
from deluge import component
class PageManager(component.Component):
"""
web,py 0.2 mapping hack..
see deluge_webserver.py
"""
def __init__(self):
component.Component.__init__(self, "PageManager")
self.page_classes = {}
self.urls = []
def register_pages(self, url_list, class_list):
self.urls += url_list
self.page_classes.update(class_list)
def register_page(self, url, klass):
self.urls.append(url)
self.urls.append(klass.__name__)
self.page_classes[klass.__name__] = klass
def unregister_page(self, url):
raise NotImplemenetedError()
#self.page_classes[klass.__name__] = None
__page_manager = PageManager()

View File

@ -1,69 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# You must obey the GNU General Public License in all respects for all of
# the code used other than OpenSSL. If you modify file(s) with this
# exception, you may extend this exception to your version of the file(s),
# but you are not obligated to do so. If you do not wish to do so, delete
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
#
from deluge import component, pluginmanagerbase
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
from deluge.ui.client import aclient as client
class PluginManager(pluginmanagerbase.PluginManagerBase,
component.Component):
def __init__(self):
component.Component.__init__(self, "WebPluginManager")
self.config = ConfigManager("webui.conf")
pluginmanagerbase.PluginManagerBase.__init__(
self, "webui.conf", "deluge.plugin.webui")
def start(self):
"""Start the plugin manager"""
# Update the enabled_plugins from the core
client.get_enabled_plugins(self._on_get_enabled_plugins)
def stop(self):
# Disable the plugins
self.disable_plugins()
def _on_get_enabled_plugins(self, enabled_plugins):
log.debug("Webui has these plugins enabled: %s", enabled_plugins)
self.config["enabled_plugins"] = enabled_plugins
# Enable the plugins that are enabled in the config and core
self.enable_plugins()
__plugin_manager = PluginManager()

View File

@ -54,5 +54,5 @@ menu.register_toolbar_item("queue_up",_("Up"), "queue-up.png" ,TB.torrent_list,
menu.register_toolbar_item("queue_down",_("Down"), "queue-down.png" ,TB.torrent_list, "POST","/torrent/queue/down/", True) menu.register_toolbar_item("queue_down",_("Down"), "queue-down.png" ,TB.torrent_list, "POST","/torrent/queue/down/", True)
menu.register_toolbar_item("details",_("Details"), "details.png" ,TB.torrent, "GET","/torrent/info/", True) menu.register_toolbar_item("details",_("Details"), "details.png" ,TB.torrent, "GET","/torrent/info/", True)
menu.register_toolbar_item("move",_("Move"), "move.png" ,TB.torrent_list,"POST","/torrent/move/", True) menu.register_toolbar_item("move",_("Move"), "move.png" ,TB.torrent_list,"POST","/torrent/move/", True)
menu.register_toolbar_item("reannounce",_("Reannounce"), "view-refresh.png" ,TB.torrent_list, "POST","'/torrent/reannounce/", False) menu.register_toolbar_item("reannounce",_("Reannounce"), "view-refresh.png" ,TB.torrent_list, "POST","/torrent/reannounce/", False)
menu.register_toolbar_item("recheck",_("Recheck"), "view-refresh.png" ,TB.torrent_list, "POST","'/torrent/recheck/", False) menu.register_toolbar_item("recheck",_("Recheck"), "view-refresh.png" ,TB.torrent_list, "POST","/torrent/recheck/", False)