diff mbox

[Branch,~linaro-validation/lava-server/trunk] Rev 344: Merge HeadlesExtension and documentation update

Message ID 20120209170711.14470.14185.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Zygmunt Krynicki Feb. 9, 2012, 5:07 p.m. UTC
Merge authors:
  Zygmunt Krynicki (zkrynicki)
Related merge proposals:
  https://code.launchpad.net/~linaro-validation/lava-server/production/+merge/92190
  proposed by: Zygmunt Krynicki (zkrynicki)
  review: Approve - Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 344 [merge]
tags: release-0.9.1
committer: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
branch nick: trunk
timestamp: Thu 2012-02-09 18:04:37 +0100
message:
  Merge HeadlesExtension and documentation update
added:
  doc/reference.rst
modified:
  doc/changes.rst
  doc/extending.rst
  doc/index.rst
  doc/installation.rst
  lava_server/__init__.py
  lava_server/bread_crumbs.py
  lava_server/extension.py


--
lp:lava-server
https://code.launchpad.net/~linaro-validation/lava-server/trunk

You are subscribed to branch lp:lava-server.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-server/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'doc/changes.rst'
--- doc/changes.rst	2012-01-19 19:32:06 +0000
+++ doc/changes.rst	2012-02-09 02:54:55 +0000
@@ -1,10 +1,21 @@ 
 Version History
 ***************
 
+.. _version_0.9.1:
+
+Version 0.9.1
+=============
+
+* Add :class:`lava_server.extension.HeadlessExtension`. This class is helpful
+  for writing GUI-less extensions for LAVA.
+* Small documentation cleanup
+* Initial code reference
+
 .. _version_0.9:
 
 Version 0.9
 ===========
+
 * Added support for data-tables serverside code
 * LAVA Server now depends on django-1.3
 * Fixed bugs 915314, 915293
@@ -14,19 +25,19 @@ 
 Version 0.8.2
 =============
 
-*  Fix the default mount point to be ""
-*  Make extensions aware of mount points
+* Fix the default mount point to be ""
+* Make extensions aware of mount points
 
 .. _version_0.7.2:
 
 Version 0.7.2
 =============
 
-*  Fix width of output in scheduler app
-*  fix wrapping issue with code blocks
-*  Add some documenation for lava-server
-*  Make the user menu stay inside the window on FF 3.6
-*  Use user nickname when real name is empty
-*  Better compatibility with older firefox
-*  Add .svg files to manifes
-*  Fix sign-in/sign-out menu
+* Fix width of output in scheduler app
+* fix wrapping issue with code blocks
+* Add some documenation for lava-server
+* Make the user menu stay inside the window on FF 3.6
+* Use user nickname when real name is empty
+* Better compatibility with older firefox
+* Add .svg files to manifes
+* Fix sign-in/sign-out menu

=== modified file 'doc/extending.rst'
--- doc/extending.rst	2011-11-16 04:13:00 +0000
+++ doc/extending.rst	2012-02-09 16:46:27 +0000
@@ -1,16 +1,14 @@ 
 Adding Extensions to LAVA Server
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-LAVA Server can be used as the base for further extensions.  Extensions
+LAVA Server can be used as the base for further extensions. Extensions
 currently exist for things like adding scheduler support, a dashboard
-interface, and additional views of test data.  Extensions can add
-further data models, menus, and views, and even APIs to the existing LAVA Server framework.
-
-Extensions are essentially just a django app.  It hooks into LAVA Server
-using an entry point called *extensions*.
-
-For a simple example of adding an extension, see the 'demo' subdirectory
-in the lava-server source repository.
+interface, and additional views of test data. Extensions can add further data
+models, menus, and views, and even APIs to the existing LAVA Server framework.
+
+Extensions are essentially just a django app. They hook into LAVA Server using
+an pkg_resources entry points machinery. For a simple example of adding an
+extension, see the 'demo' subdirectory in the lava-server source repository.
 
 setup.py
 ********
@@ -27,20 +25,26 @@ 
 
 The *DemoExtension* class will be defined below.
 
-LavaServerExtension
+The extension class
 *******************
-The other thing your django extension to LAVA Server will need is a
-class that inherits LavaServerExtensions.  This class defines properties
-that are needed for LAVA Server to include your extension.
+
+The other thing your django extension to LAVA Server will need is a class that
+implements the :class:`~lava_server.extension.IExtension` interface. This class
+defines the properties and methods that are needed for LAVA Server to include
+your extension.
+
+You may find a small demo extension in the source tree. You can use that as a
+base for your own code.
 
 .. literalinclude:: ../demo/demo_app/extension.py
 
-Extending the API
-*****************
-As previously mentioned, the LAVA Server xmlrpc API can be extended with
-new methods using LAVA Server extensions.  In the *demo_app* example we
-have been looking at, a new method called *demoMethod()* is added to the
-API and is automatically added under a namespace called *demo*.  It uses
-*ExposedAPI* from *linaro_django_xmlrpc.models* to do this.
+Adding new XML-RPC methods
+**************************
+
+As previously mentioned, the LAVA Server XML-RPC API can be extended with new
+methods using LAVA Server extensions.  In the *demo_app* example we have been
+looking at, a new method called *demoMethod()* is added to the API and is
+automatically added under a namespace called *demo*.  It uses *ExposedAPI* from
+*linaro_django_xmlrpc.models* to do this.
 
 .. literalinclude:: ../demo/demo_app/models.py

=== modified file 'doc/index.rst'
--- doc/index.rst	2011-11-14 18:15:05 +0000
+++ doc/index.rst	2012-02-09 02:54:55 +0000
@@ -2,14 +2,13 @@ 
 LAVA Server Documentation
 =========================
 
-.. warning::
-    This document is *work in progress*.
-
 Features
 ========
-The LAVA Server is the core framework used by LAVA web apps.  It provides 
-the main web interface to LAVA and supports extensions.
-
+
+The LAVA Server is the core framework used by LAVA web apps. It provides the
+main web interface to LAVA and supports extensions.
+
+.. seealso:: See what's new in :ref:`version_0.9.1`
 
 Indices and tables
 ==================
@@ -21,6 +20,7 @@ 
     extending.rst
     process.rst
     changes.rst
+    reference.rst
 
 * :ref:`search`
 
@@ -37,10 +37,10 @@ 
 
 .. todolist::
 
+.. _questions:
 
 Questions
 ^^^^^^^^^
-.. _questions:
 
 If you have any questions, including to the content of this document, feel free
 to ask them here: https://answers.launchpad.net/lava-project

=== modified file 'doc/installation.rst'
--- doc/installation.rst	2011-11-16 04:13:00 +0000
+++ doc/installation.rst	2012-02-09 02:54:55 +0000
@@ -7,19 +7,26 @@ 
 can always ask for support using Launchpad support tracker (see
 :ref:`questions`)
 
+
+Using LAVA Deployment Tool
+**************************
+
+See http://launchpad.net/lava-deployment-tool/ to learn more about this method.
+This is by far the most supported installation mode available.
+
 Using virtualenv
-******************
+****************
 
 Python Virtualenv is a useful tool for creating a sandbox for working
 with python modules.  In Ubuntu, you can get it by installing
 *python-virtualenv* using apt-get.  For source and pypi installations of
 non-production systems, it is highly recommended.
 
-Example usage ::
+Example usage::
 
- $ virtualenv sandbox
- $ cd sandbox
- $ . bin/activate
+    $ virtualenv sandbox
+    $ cd sandbox
+    $ . bin/activate
 
 Once activated, the environment for that session will be set up so that
 subsequent commands will use the virtual environment settings.
@@ -77,21 +84,3 @@ 
 .. todo::
  Installation instructions for production installations against
  postgresql using pypi
-
-Installation from PPA
-*********************
-
-This method is only suitable for users running Ubuntu 10.04 or later. Here LAVA
-is pre-compiled and packaged as Debian packages (debs). The installation
-scripts embedded in the packages take care for setting up additional services
-so usually this is the best method to quickly have a self-contained running
-installation. The downside is longer release period as packaging takes
-additional time after each release. Another downside is that our support is
-limited to Ubuntu.
-
-To install using the ppa ::
-
- $ sudo add-apt-repository ppa:linaro-validation/ppa
- $ sudo apt-get update
- $ sudo apt-get install lava-server
-

=== added file 'doc/reference.rst'
--- doc/reference.rst	1970-01-01 00:00:00 +0000
+++ doc/reference.rst	2012-02-09 02:54:55 +0000
@@ -0,0 +1,14 @@ 
+.. _code_reference:
+
+Code Rereference
+================
+
+.. automodule:: lava_server
+    :members:
+
+.. automodule:: lava_server.bread_crumbs
+    :members:
+
+.. automodule:: lava_server.extension
+    :members:
+

=== modified file 'lava_server/__init__.py'
--- lava_server/__init__.py	2012-01-19 17:42:13 +0000
+++ lava_server/__init__.py	2012-02-09 02:56:00 +0000
@@ -16,5 +16,11 @@ 
 # You should have received a copy of the GNU Affero General Public License
 # along with LAVA Server.  If not, see <http://www.gnu.org/licenses/>.
 
-
-__version__ = (0, 9, 0, "final", 0)
+"""
+lava_server
+===========
+
+The LAVA server package. Contains only the version declaration.
+"""
+
+__version__ = (0, 9, 1, "final", 0)

=== modified file 'lava_server/bread_crumbs.py'
--- lava_server/bread_crumbs.py	2011-11-18 11:24:38 +0000
+++ lava_server/bread_crumbs.py	2012-02-09 02:56:00 +0000
@@ -16,8 +16,10 @@ 
 # You should have received a copy of the GNU Affero General Public License
 # along with LAVA Server.  If not, see <http://www.gnu.org/licenses/>.
 
-
 """
+lava_server.bread_crumbs
+========================
+
 Bread crumb management for LAVA server.
 
 This system allows one to construct static trees of views or even site maps,

=== modified file 'lava_server/extension.py'
--- lava_server/extension.py	2011-12-05 23:39:52 +0000
+++ lava_server/extension.py	2012-02-09 02:56:14 +0000
@@ -17,13 +17,22 @@ 
 # You should have received a copy of the GNU Affero General Public License
 # along with LAVA Server.  If not, see <http://www.gnu.org/licenses/>.
 
+"""
+lava_server.extension
+=====================
+
+LAVA Server automatically loads extensions registered under the
+``lava_server.extensions`` entry point namespace. Each entry point
+must be a subclass of :class:`lava_server.extension.IExtension`
+"""
+
 
 from abc import ABCMeta, abstractmethod, abstractproperty
 import logging
 import pkg_resources
 
 
-class ILavaServerExtension(object):
+class IExtension(object):
     """
     Interface for LAVA Server extensions.
     """
@@ -31,6 +40,12 @@ 
     __metaclass__ = ABCMeta
 
     @abstractmethod
+    def __init__(self, slug):
+        """
+        Remember slug name
+        """
+
+    @abstractmethod
     def contribute_to_settings(self, settings_module):
         """
         Add elements required to initialize this extension into the project
@@ -99,6 +114,10 @@ 
         """
 
 
+# Old longish name, we know it's LAVA already
+ILavaServerExtension = IExtension
+
+
 class Menu(object):
     """
     Menu (for navigation)
@@ -110,11 +129,55 @@ 
         self.sub_menu = sub_menu or []
 
 
-class LavaServerExtension(ILavaServerExtension):
-    """
-    LAVA Server extension class.
-
-    Implements basic behavior for LAVA server extensions
+class HeadlessExtension(ILavaServerExtension):
+    """
+    Base class for building headless extensions.
+
+    The only required things to implement are two ``@property`` functions. You
+    will need to implement :attr:`~ILavaServerExtension.name` and
+    :attr:`~ILavaServerExtension.version`.
+
+    Meaningful extensions will want to implement
+    :meth:`~ILavaServerExtension.contribute_to_settings_ex` and add additional
+    applications to ``INSTALLED_APPS``
+    """
+
+    def __init__(self, slug):
+        self.slug = slug
+
+    def contribute_to_settings(self, settings_module):
+        pass
+
+    def contribute_to_settings_ex(self, settings_module, settings_object):
+        pass
+
+    def contribute_to_urlpatterns(self, urlpatterns, mount_point):
+        pass
+
+    @property
+    def api_class(self):
+        return None
+
+    @property
+    def front_page_template(self):
+        return None 
+        
+    def get_front_page_context(self):
+        return {}
+
+    def get_main_url(self):
+        pass
+
+    def get_menu(self):
+        pass
+
+
+class Extension(ILavaServerExtension):
+    """
+    Base class for commmon extensions.
+
+    This class implements most of the :class:`IExtension` interface leaving a
+    only handful of more concrete methods and properties to be implemented. 
     """
 
     def __init__(self, slug):
@@ -170,6 +233,9 @@ 
         return reverse(self.main_view_name)
 
 
+LavaServerExtension = Extension
+
+
 class ExtensionLoadError(Exception):
     """
     Exception internally raised by extension loader