From patchwork Thu Feb 9 17:07:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zygmunt Krynicki X-Patchwork-Id: 6722 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A19FF23EAA for ; Thu, 9 Feb 2012 17:07:14 +0000 (UTC) Received: from mail-gy0-f180.google.com (mail-gy0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5856DA18199 for ; Thu, 9 Feb 2012 17:07:14 +0000 (UTC) Received: by ghbz22 with SMTP id z22so1234840ghb.11 for ; Thu, 09 Feb 2012 09:07:13 -0800 (PST) Received: by 10.50.216.231 with SMTP id ot7mr4716715igc.8.1328807233699; Thu, 09 Feb 2012 09:07:13 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.12.131 with SMTP id x3cs47316ibx; Thu, 9 Feb 2012 09:07:13 -0800 (PST) Received: by 10.180.81.66 with SMTP id y2mr4051250wix.20.1328807232372; Thu, 09 Feb 2012 09:07:12 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id hs7si3416517wib.31.2012.02.09.09.07.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Feb 2012 09:07:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RvXSh-00040e-RK for ; Thu, 09 Feb 2012 17:07:11 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id BF2DFE0180 for ; Thu, 9 Feb 2012 17:07:11 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-server X-Launchpad-Branch: ~linaro-validation/lava-server/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 344 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-server/trunk] Rev 344: Merge HeadlesExtension and documentation update Message-Id: <20120209170711.14470.14185.launchpad@ackee.canonical.com> Date: Thu, 09 Feb 2012 17:07:11 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14763"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 120d241d5b6ce6f521ef79408b3a194e07c8d902 X-Gm-Message-State: ALoCoQlnl0D4W2XXTdNb/mlvvKpeIfMaNnbnZBV1wg+xBYD0waZ5mAP7RkycSvobPkuKGCi0wkGA 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 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 === 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 . - -__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 . - """ +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 . +""" +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