update documentation about the webui

This commit is contained in:
Damien Churchill 2009-07-22 23:53:30 +00:00
parent aef0a4616f
commit 5ca119827b
9 changed files with 94 additions and 33 deletions

View File

@ -53,6 +53,9 @@ from deluge.ui.web.json_api import JSONComponent, export
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class Auth(JSONComponent): class Auth(JSONComponent):
"""
The component that implements authentification into the JSON interface.
"""
def __init__(self): def __init__(self):
super(Auth, self).__init__("Auth") super(Auth, self).__init__("Auth")
@ -61,8 +64,9 @@ class Auth(JSONComponent):
""" """
Creates a new session. Creates a new session.
:keyword login: str, the username of the user logging in, currently :keyword login: the username of the user logging in, currently \
only for future use. only for future use.
:type login: string
""" """
m = hashlib.md5() m = hashlib.md5()
m.update(login) m.update(login)
@ -87,7 +91,8 @@ class Auth(JSONComponent):
""" """
Change the password. Change the password.
:param new_password: str, the password to change to :param new_password: the password to change to
:type new_password: string
""" """
log.debug("Changing password") log.debug("Changing password")
d = Deferred() d = Deferred()
@ -106,9 +111,10 @@ class Auth(JSONComponent):
""" """
Check a session to see if it's still valid. Check a session to see if it's still valid.
:param session_id: str, the id for the session to remove :param session_id: the id for the session to remove
:type session_id: string
:returns: True if the session is valid, False if not. :returns: True if the session is valid, False if not.
:rtype: bool :rtype: booleon
""" """
d = Deferred() d = Deferred()
config = component.get("DelugeWeb").config config = component.get("DelugeWeb").config
@ -120,7 +126,8 @@ class Auth(JSONComponent):
""" """
Removes a session. Removes a session.
:param session_id: str, the id for the session to remove :param session_id: the id for the session to remove
:type session_id: string
""" """
d = Deferred() d = Deferred()
config = component.get("DelugeWeb").config config = component.get("DelugeWeb").config
@ -133,8 +140,10 @@ class Auth(JSONComponent):
""" """
Test a password to see if it's valid. Test a password to see if it's valid.
:param password: str, the password to test :param password: the password to test
:type password: string
:returns: a session id or False :returns: a session id or False
:rtype: string or False
""" """
config = component.get("DelugeWeb").config config = component.get("DelugeWeb").config
d = Deferred() d = Deferred()

View File

@ -40,6 +40,9 @@ from deluge import common
_ = lambda x: gettext.gettext(x).decode("utf-8") _ = lambda x: gettext.gettext(x).decode("utf-8")
class Template(MakoTemplate): class Template(MakoTemplate):
"""
A template that adds some built-ins to the rendering
"""
builtins = { builtins = {
"_": _, "_": _,

View File

@ -1,4 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
"""
Script to go through the javascript files and dynamically generate gettext.js
"""
import os import os
import re import re

View File

@ -68,8 +68,10 @@ def export(auth_level=AUTH_LEVEL_DEFAULT):
Decorator function to register an object's method as an RPC. The object Decorator function to register an object's method as an RPC. The object
will need to be registered with an `:class:RPCServer` to be effective. will need to be registered with an `:class:RPCServer` to be effective.
:param func: function, the function to export :param func: the function to export
:param auth_level: int, the auth level required to call this method :type func: function
:keyword auth_level: the auth level required to call this method
:type auth_level: int
""" """
global AUTH_LEVEL_DEFAULT global AUTH_LEVEL_DEFAULT
@ -254,8 +256,10 @@ class JSON(resource.Resource, component.Component):
Registers an object to export it's rpc methods. These methods should Registers an object to export it's rpc methods. These methods should
be exported with the export decorator prior to registering the object. be exported with the export decorator prior to registering the object.
:param obj: object, the object that we want to export :param obj: the object that we want to export
:param name: str, the name to use, if None, it will be the class name of the object :type obj: object
:param name: the name to use, if None, it will be the class name of the object
:type name: string
""" """
name = name or obj.__class__.__name__ name = name or obj.__class__.__name__
name = name.lower() name = name.lower()
@ -289,6 +293,11 @@ HOSTS_INFO = 4
FILES_KEYS = ["files", "file_progress", "file_priorities"] FILES_KEYS = ["files", "file_progress", "file_priorities"]
class WebApi(JSONComponent): class WebApi(JSONComponent):
"""
The component that implements all the methods required for managing
the web interface.
"""
def __init__(self): def __init__(self):
super(WebApi, self).__init__("Web") super(WebApi, self).__init__("Web")
self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS) self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS)
@ -297,7 +306,8 @@ class WebApi(JSONComponent):
""" """
Return the information about a host Return the information about a host
:param host_id: str, the id of the host :param host_id: the id of the host
:type host_id: string
:returns: the host information :returns: the host information
:rtype: list :rtype: list
""" """
@ -310,7 +320,8 @@ class WebApi(JSONComponent):
""" """
Connect the client to a daemon Connect the client to a daemon
:param host_id: str, the id of the daemon in the host list :param host_id: the id of the daemon in the host list
:type host_id: string
:returns: the methods the daemon supports :returns: the methods the daemon supports
:rtype: list :rtype: list
""" """
@ -329,7 +340,7 @@ class WebApi(JSONComponent):
The current connection state. The current connection state.
:returns: True if the client is connected :returns: True if the client is connected
:rtype: bool :rtype: booleon
""" """
d = Deferred() d = Deferred()
d.callback(client.connected()) d.callback(client.connected())
@ -350,10 +361,12 @@ class WebApi(JSONComponent):
""" """
Gather the information required for updating the web interface. Gather the information required for updating the web interface.
:param keys: list, the information about the torrents to gather :param keys: the information about the torrents to gather
:param filter_dict: dict, the filters to apply when selecting torrents. :type keys: list
:param filter_dict: the filters to apply when selecting torrents.
:type filter_dict: dictionary
:returns: The torrent and ui information. :returns: The torrent and ui information.
:rtype: dict :rtype: dictionary
""" """
ui_info = { ui_info = {
"torrents": None, "torrents": None,
@ -421,9 +434,10 @@ class WebApi(JSONComponent):
""" """
Gets the files for a torrent in tree format Gets the files for a torrent in tree format
:param torrent_id: string, the id of the torrent to retrieve. :param torrent_id: the id of the torrent to retrieve.
:type torrent_id: string
:returns: The torrents files in a tree :returns: The torrents files in a tree
:rtype: dict :rtype: dictionary
""" """
main_deferred = Deferred() main_deferred = Deferred()
d = client.core.get_torrent_status(torrent_id, FILES_KEYS) d = client.core.get_torrent_status(torrent_id, FILES_KEYS)
@ -435,9 +449,10 @@ class WebApi(JSONComponent):
""" """
Download a torrent file from a url to a temporary directory. Download a torrent file from a url to a temporary directory.
:param url: str, the url of the torrent :param url: the url of the torrent
:type url: string
:returns: the temporary file name of the torrent file :returns: the temporary file name of the torrent file
:rtype: str :rtype: string
""" """
tmp_file = os.path.join(tempfile.gettempdir(), url.split("/")[-1]) tmp_file = os.path.join(tempfile.gettempdir(), url.split("/")[-1])
@ -452,7 +467,8 @@ class WebApi(JSONComponent):
""" """
Return information about a torrent on the filesystem. Return information about a torrent on the filesystem.
:param filename: str, the path to the torrent :param filename: the path to the torrent
:type filename: string
:returns: :returns:
{ {
"filename": the torrent file "filename": the torrent file
@ -461,6 +477,7 @@ class WebApi(JSONComponent):
"files": the files the torrent contains "files": the files the torrent contains
"info_hash" the torrents info_hash "info_hash" the torrents info_hash
} }
:rtype: dictionary
""" """
d = Deferred() d = Deferred()
try: try:
@ -509,6 +526,9 @@ class WebApi(JSONComponent):
def get_host_status(self, host_id): def get_host_status(self, host_id):
""" """
Returns the current status for the specified host. Returns the current status for the specified host.
:param host_id: the hash id of the host
:type host_id: string
""" """
main_deferred = Deferred() main_deferred = Deferred()
@ -551,12 +571,12 @@ class WebApi(JSONComponent):
return main_deferred return main_deferred
@export @export
def stop_daemon(self, connection_id): def stop_daemon(self, host_id):
""" """
Stops a running daemon. Stops a running daemon.
:param connection_id: str, the hash id of the connection :param host_id: the hash id of the host
:type host_id: string
""" """
main_deferred = Deferred() main_deferred = Deferred()
host = self.get_host(connection_id) host = self.get_host(connection_id)
@ -589,10 +609,14 @@ class WebApi(JSONComponent):
""" """
Adds a host to the list. Adds a host to the list.
:param host: str, the hostname :param host: the hostname
:param port: int, the port :type host: string
:param username: str, the username to login as :param port: the port
:param password: str, the password to login with :type port: int
:keyword username: the username to login as
:type username: string
:keyword password: the password to login with
:type password: string
""" """
d = Deferred() d = Deferred()
@ -621,8 +645,8 @@ class WebApi(JSONComponent):
""" """
Removes a host for the list Removes a host for the list
:param connection_Id: str, the hash id of the connection :param host_id: the hash id of the host
:type host_id: string
""" """
d = Deferred() d = Deferred()
host = self.get_host(connection_id) host = self.get_host(connection_id)

View File

@ -49,13 +49,18 @@ class PluginManager(PluginManagerBase, Component):
PluginManagerBase.__init__(self, "web.conf", "deluge.plugin.web") PluginManagerBase.__init__(self, "web.conf", "deluge.plugin.web")
def start(self): def start(self):
"""Start up the plugin manager""" """
Start up the plugin manager
"""
# Update the enabled plugins from the core # Update the enabled plugins from the core
d = client.core.get_enabled_plugins() d = client.core.get_enabled_plugins()
d.addCallback(self._on_get_enabled_plugins) d.addCallback(self._on_get_enabled_plugins)
def stop(self): def stop(self):
"""
Stop the plugin manager
"""
self.disable_plugins() self.disable_plugins()
def update(self): def update(self):

View File

@ -25,6 +25,8 @@ Modules
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
:glob:
modules/common modules/*
modules/config modules/*/*
modules/*/*/*

View File

@ -0,0 +1,5 @@
:mod:`deluge.ui.web.auth`
=========================
.. automodule:: deluge.ui.web.auth
:members:

View File

@ -0,0 +1,5 @@
:mod:`deluge.ui.web.common`
===========================
.. automodule:: deluge.ui.web.common
:members:

View File

@ -0,0 +1,5 @@
:mod:`deluge.ui.web.json_api`
=============================
.. automodule:: deluge.ui.web.json_api
:members: