From patchwork Tue Oct 11 10:35:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zygmunt Krynicki X-Patchwork-Id: 4618 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 313A323DEF for ; Tue, 11 Oct 2011 10:35:17 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1F4C4A1832B for ; Tue, 11 Oct 2011 10:35:17 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id 5so1953429eyg.11 for ; Tue, 11 Oct 2011 03:35:17 -0700 (PDT) Received: by 10.223.77.69 with SMTP id f5mr38807088fak.3.1318329316747; Tue, 11 Oct 2011 03:35:16 -0700 (PDT) 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.152.24.41 with SMTP id r9cs152877laf; Tue, 11 Oct 2011 03:35:16 -0700 (PDT) Received: by 10.216.229.5 with SMTP id g5mr620937weq.67.1318329314442; Tue, 11 Oct 2011 03:35:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id w5si15823736weq.18.2011.10.11.03.35.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Oct 2011 03:35:14 -0700 (PDT) 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 1RDZg1-0008Rz-RH for ; Tue, 11 Oct 2011 10:35:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id C43D5E03DF for ; Tue, 11 Oct 2011 10:35:13 +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: 255 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-server/trunk] Rev 255: A ton of PEP8 fixes Message-Id: <20111011103513.21793.33747.launchpad@ackee.canonical.com> Date: Tue, 11 Oct 2011 10:35:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14124"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 2eb83ed5d1866ec700b26e673b7e32df903b3feb ------------------------------------------------------------ revno: 255 committer: Zygmunt Krynicki branch nick: trunk timestamp: Tue 2011-10-11 11:20:14 +0200 message: A ton of PEP8 fixes modified: lava_projects/admin.py lava_projects/extension.py lava_projects/forms.py lava_projects/models.py lava_projects/urls.py lava_projects/views.py lava_server/bread_crumbs.py lava_server/context_processors.py lava_server/extension.py lava_server/manage.py lava_server/settings/common.py lava_server/settings/debian.py lava_server/settings/development.py lava_server/settings/production.py lava_server/templates/index.html lava_server/urls.py lava_server/views.py lava_server/xmlrpc.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 'lava_projects/admin.py' --- lava_projects/admin.py 2011-09-24 19:18:28 +0000 +++ lava_projects/admin.py 2011-10-11 09:20:14 +0000 @@ -18,15 +18,20 @@ from django.contrib import admin -from lava_projects.models import Project, ProjectFormerIdentifier +from lava_projects.models import Project, ProjectFormerIdentifier class ProjectAdmin(admin.ModelAdmin): - list_display=('__unicode__', 'identifier', 'registered_by', 'registered_on', 'is_public', 'owner') + + list_display = ( + '__unicode__', 'identifier', 'registered_by', + 'registered_on', 'is_public', 'owner') class ProjectFormerIdentifierAdmin(admin.ModelAdmin): - list_display=('former_identifier', 'project', 'renamed_on', 'renamed_by') + + list_display = ( + 'former_identifier', 'project', 'renamed_on', 'renamed_by') admin.site.register(Project, ProjectAdmin) === modified file 'lava_projects/extension.py' --- lava_projects/extension.py 2011-09-30 13:45:00 +0000 +++ lava_projects/extension.py 2011-10-11 09:20:14 +0000 @@ -44,4 +44,5 @@ def version(self): import lava_projects import versiontools - return versiontools.format_version(lava_projects.__version__, hint=lava_projects) + return versiontools.format_version( + lava_projects.__version__, hint=lava_projects) === modified file 'lava_projects/forms.py' --- lava_projects/forms.py 2011-09-24 19:18:28 +0000 +++ lava_projects/forms.py 2011-10-11 09:20:14 +0000 @@ -59,8 +59,8 @@ is_aggregate = forms.BooleanField( label=_(u"Project is an aggregation (distribution)"), help_text=_(u"If selected the project will be treated like a" - u" distribution. Some UI elements are optimized for that case" - u" and behave differently."), + u" distribution. Some UI elements are optimized for that" + u" case and behave differently."), required=False) def restrict_group_selection_for_user(self, user): @@ -93,7 +93,7 @@ def clean_identifier(self): """ Check that the identifier is correct: - + 1) It does not collide with other projects 2) Or their past identifiers """ @@ -103,10 +103,14 @@ project = Project.objects.all().get_by_identifier(value) if project.identifier == value: # Disallow current identifiers from other projects - raise ValidationError("Project %s is already using this identifier" % project) - else: + raise ValidationError( + "Project {0} is already using this identifier".format( + project)) + else: # Disallow past identifiers from other projects - raise ValidationError("Project %s was using this identifier in the past" % project) + raise ValidationError( + "Project {0} was using this identifier in the past".format( + project)) except Project.DoesNotExist: pass return value @@ -125,7 +129,8 @@ name = forms.CharField( label=_(u"Projet name"), - help_text=_(u"The new project name, same limits as before (100 chars)"), + help_text=_(u"The new project name, same limits as before " + u"(100 chars)"), required=True, max_length=100) @@ -143,7 +148,7 @@ def clean_identifier(self): """ Check that new identifier is correct: - + 1) It does not collide with other projects 2) Or their past identifiers 3) It is different than the one we are currently using @@ -162,12 +167,13 @@ elif project.identifier == value: # Disallow current identifiers from other projects raise ValidationError( - _(u"Project %s is already using this identifier") % project) - else: + _(u"Project {0} is already using this identifier").format( + project)) + else: # Disallow past identifiers from other projects raise ValidationError( - _(u"Project %s was using this identifier in the past") % - project) + _(u"Project {0} was using this identifier in the" + u"past").format(project)) except Project.DoesNotExist: pass return value === modified file 'lava_projects/models.py' --- lava_projects/models.py 2011-09-26 14:00:18 +0000 +++ lava_projects/models.py 2011-10-11 09:20:14 +0000 @@ -42,8 +42,9 @@ return self.get(identifier=identifier) except Project.DoesNotExist as no_such_project: try: - project_former_identifier = ProjectFormerIdentifier.objects.get(former_identifier=identifier) - return project_former_identifier.project + p_f_ir = ProjectFormerIdentifier.objects.get( + former_identifier=identifier) + return p_f_i.project except ProjectFormerIdentifier.DoesNotExist: raise no_such_project @@ -132,17 +133,17 @@ description = models.TextField( null=False, blank=True, - verbose_name = _(u"Description"), - help_text = _(u"Arbitrary text about the project, you can use markdown" - u" formatting to style it")) + verbose_name=_(u"Description"), + help_text=_(u"Arbitrary text about the project, you can use markdown" + u" formatting to style it")) is_aggregate = models.BooleanField( blank=True, null=False, verbose_name=_(u"Aggregate"), help_text=_(u"When selected the project will be treated like a" - u" distribution. Some UI elements are optimized for that case" - u" and behave differently.")) + u" distribution. Some UI elements are optimized for that" + u" case and behave differently.")) registered_by = models.ForeignKey( User, === modified file 'lava_projects/urls.py' --- lava_projects/urls.py 2011-09-24 19:18:28 +0000 +++ lava_projects/urls.py 2011-10-11 09:20:14 +0000 @@ -21,10 +21,15 @@ urlpatterns = patterns( 'lava_projects.views', - url('^$', 'project_root', name='lava.project.root'), - url(r'^\+list/$', 'project_list', name='lava.project.list'), - url(r'^\+register/$', 'project_register', name='lava.project.register'), - url(r'^(?P[a-z0-9-]+)/$', 'project_detail', name='lava.project.detail'), - url(r'^(?P[a-z0-9-]+)/\+update/$', 'project_update', name='lava.project.update'), - url(r'^(?P[a-z0-9-]+)/\+rename/$', 'project_rename', name='lava.project.rename'), -) + url('^$', 'project_root', + name='lava.project.root'), + url(r'^\+list/$', 'project_list', + name='lava.project.list'), + url(r'^\+register/$', 'project_register', + name='lava.project.register'), + url(r'^(?P[a-z0-9-]+)/$', 'project_detail', + name='lava.project.detail'), + url(r'^(?P[a-z0-9-]+)/\+update/$', 'project_update', + name='lava.project.update'), + url(r'^(?P[a-z0-9-]+)/\+rename/$', 'project_rename', + name='lava.project.rename')) === modified file 'lava_projects/views.py' --- lava_projects/views.py 2011-10-03 14:05:03 +0000 +++ lava_projects/views.py 2011-10-11 09:20:14 +0000 @@ -17,7 +17,8 @@ # along with LAVA Server. If not, see . from django.contrib.auth.decorators import login_required -from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden +from django.http import ( + HttpResponse, HttpResponseRedirect, HttpResponseForbidden) from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext, loader from django.utils.translation import ugettext as _ @@ -43,9 +44,9 @@ template_name = "lava_projects/project_root.html" t = loader.get_template(template_name) c = RequestContext(request, { - 'recent_project_list': Project.objects.accessible_by_principal(request.user).recently_registered(), - 'bread_crumb_trail': BreadCrumbTrail.leading_to(project_root) - }) + 'recent_project_list': Project.objects.accessible_by_principal( + request.user).recently_registered(), + 'bread_crumb_trail': BreadCrumbTrail.leading_to(project_root)}) return HttpResponse(t.render(c)) @@ -56,23 +57,26 @@ queryset=Project.objects.accessible_by_principal(request.user), template_name="lava_projects/project_list.html", extra_context={ - 'bread_crumb_trail': BreadCrumbTrail.leading_to(project_list) - }, + 'bread_crumb_trail': BreadCrumbTrail.leading_to( + project_list)}, template_object_name="project") -@BreadCrumb("{project}", +@BreadCrumb("{project}", parent=project_root, needs=['project_identifier']) def project_detail(request, identifier): # A get by identifier, looking at renames, if needed. try: - project = Project.objects.accessible_by_principal(request.user).get_by_identifier(identifier) + project = Project.objects.accessible_by_principal( + request.user).get_by_identifier(identifier) except Project.DoesNotExist: raise Http404("No such project") - # Redirect users to proper URL of this project if using one of the older names. + # Redirect users to proper URL of this project if using one of the older + # names. if project.identifier != identifier: - return HttpResponseRedirect(project.get_absolute_url() + "?former_identifier=" + identifier) + return HttpResponseRedirect( + project.get_absolute_url() + "?former_identifier=" + identifier) # Lookup former identifier if we have been redirected former_identifier = None if request.GET.get("former_identifier"): @@ -86,13 +90,12 @@ t = loader.get_template(template_name) c = RequestContext(request, { 'project': project, - 'former_identifier': former_identifier, + 'former_identifier': former_identifier, 'belongs_to_user': project.is_owned_by(request.user), 'bread_crumb_trail': BreadCrumbTrail.leading_to( project_detail, project=project, - project_identifier=project.identifier) - }) + project_identifier=project.identifier)}) return HttpResponse(t.render(c)) @@ -133,7 +136,7 @@ @login_required def project_update(request, identifier): project = get_object_or_404( - Project.objects.accessible_by_principal(request.user), + Project.objects.accessible_by_principal(request.user), identifier=identifier) if not project.is_owned_by(request.user): return HttpResponseForbidden("You cannot update this project") @@ -163,8 +166,7 @@ 'bread_crumb_trail': BreadCrumbTrail.leading_to( project_update, project=project, - project_identifier=project.identifier) - }) + project_identifier=project.identifier)}) return HttpResponse(t.render(c)) @@ -174,14 +176,14 @@ @login_required def project_rename(request, identifier): project = get_object_or_404( - Project.objects.accessible_by_principal(request.user), + Project.objects.accessible_by_principal(request.user), identifier=identifier) if not project.is_owned_by(request.user): return HttpResponseForbidden("You cannot update this project") if request.method == 'POST': form = ProjectRenameForm(project, request.POST) if form.is_valid(): - # Remove old entry if we are reusing our older identifier + # Remove old entry if we are reusing our older identifier pfi = ProjectFormerIdentifier.objects.filter( former_identifier=form.cleaned_data['identifier'], project=project.pk).delete() @@ -208,6 +210,5 @@ 'bread_crumb_trail': BreadCrumbTrail.leading_to( project_rename, project=project, - project_identifier=project.identifier) - }) + project_identifier=project.identifier)}) return HttpResponse(t.render(c)) === modified file 'lava_server/bread_crumbs.py' --- lava_server/bread_crumbs.py 2011-10-06 12:00:37 +0000 +++ lava_server/bread_crumbs.py 2011-10-11 09:20:14 +0000 @@ -96,7 +96,8 @@ try: return self.name.format(**kwargs) except: - logging.exception("Unable to construct breadcrumb name for view %r", self.view) + logging.exception( + "Unable to construct breadcrumb name for view %r", self.view) raise def get_absolute_url(self, kwargs): @@ -109,9 +110,12 @@ the kwargs dictionary. """ try: - return reverse(self.view, args=[kwargs[name] for name in self.needs]) + return reverse( + self.view, + args=[kwargs[name] for name in self.needs]) except: - logging.exception("Unable to construct breadcrumb URL for view %r", self.view) + logging.exception( + "Unable to construct breadcrumb URL for view %r", self.view) raise @@ -156,7 +160,8 @@ @classmethod def leading_to(cls, view, **kwargs): """ - Create an instance of BreadCrumbTrail that starts at the specified view. + Create an instance of BreadCrumbTrail that starts at the specified + view. Additional keyword arguments, if provided, will be available to get_name() and get_absolute_url() of each LiveBreadCrumb that makes up === modified file 'lava_server/context_processors.py' --- lava_server/context_processors.py 2011-09-30 13:45:00 +0000 +++ lava_server/context_processors.py 2011-10-11 09:20:14 +0000 @@ -21,10 +21,10 @@ import lava_server from lava_server.extension import loader + def lava(request): return { 'lava': { 'extension_list': loader.extensions, - 'version': versiontools.format_version(lava_server.__version__, hint=lava_server) - } - } + 'version': versiontools.format_version( + lava_server.__version__, hint=lava_server)}} === modified file 'lava_server/extension.py' --- lava_server/extension.py 2011-08-18 14:59:36 +0000 +++ lava_server/extension.py 2011-10-11 09:20:14 +0000 @@ -81,6 +81,12 @@ """ @abstractmethod + def get_front_page_context(self): + """ + Context available to the front page template + """ + + @abstractmethod def get_main_url(self): """ Absolute URL of the main view @@ -113,6 +119,9 @@ def front_page_template(self): return None + def get_front_page_context(self): + return {} + @property def api_class(self): """ @@ -130,7 +139,7 @@ pass def contribute_to_urlpatterns(self, urlpatterns): - from django.conf.urls.defaults import url, include + from django.conf.urls.defaults import url, include urlpatterns += [ url(r'^{slug}/'.format(slug=self.slug), include('{app_name}.urls'.format(app_name=self.app_name)))] @@ -140,7 +149,6 @@ return reverse(self.main_view_name) - class ExtensionLoadError(Exception): """ Exception internally raised by extension loader @@ -161,7 +169,8 @@ """ def __init__(self): - self._extensions = None # Load this lazily so that others can import this module + # Load this lazily so that others can import this module + self._extensions = None self._mapper = None @property @@ -211,7 +220,8 @@ try: extension = self._load_extension(name) except ExtensionLoadError as ex: - logging.exception("Unable to load extension %r: %s", name, ex.message) + logging.exception( + "Unable to load extension %r: %s", name, ex.message) else: self._extensions.append(extension) return self._extensions @@ -227,7 +237,8 @@ for extension in self.extensions: extension.contribute_to_settings(settings_module) if settings_object is not None: - extension.contribute_to_settings_ex(settings_module, settings_object) + extension.contribute_to_settings_ex( + settings_module, settings_object) def contribute_to_urlpatterns(self, urlpatterns): """ @@ -240,7 +251,7 @@ return sorted( pkg_resources.iter_entry_points( 'lava_server.extensions'), - key=lambda ep:ep.name) + key=lambda ep: ep.name) def _load_extension(self, entrypoint): """ @@ -254,7 +265,8 @@ try: extension_cls = entrypoint.load() except ImportError as ex: - logging.exception("Unable to load extension entry point: %r", entrypoint) + logging.exception( + "Unable to load extension entry point: %r", entrypoint) raise ExtensionLoadError( entrypoint, "Unable to load extension entry point") === modified file 'lava_server/manage.py' --- lava_server/manage.py 2011-09-16 09:40:08 +0000 +++ lava_server/manage.py 2011-10-11 09:20:14 +0000 @@ -65,24 +65,33 @@ @classmethod def register_arguments(cls, parser): group = parser.add_argument_group("Server configuration") - group.add_argument("-d", "--development", - action="store_false", - dest="production", - help="Use development settings") - group.add_argument("-p", "--production", - action="store_true", - default=True, - help="Use production settings (default)") - group.add_argument("-i", "--instance", - action="store", - default=None, - help="Use the specified instance (works only with --production)") - group.add_argument("-I", "--instance-template", - action="store", - default="/srv/lava/instances/{instance}/etc/lava-server/{{filename}}.conf", - help="Template used for constructing instance pathname. The default value is: %(default)s") - parser.add_argument("command", nargs="...", - help="Invoke this Django management command") + group.add_argument( + "-d", "--development", + action="store_false", + dest="production", + help="Use development settings") + group.add_argument( + "-p", "--production", + action="store_true", + default=True, + help="Use production settings (default)") + group.add_argument( + "-i", "--instance", + action="store", + default=None, + help="Use the specified instance (works only with --production)") + group.add_argument( + "-I", "--instance-template", + action="store", + default=( + "/srv/lava/instances/{instance}" + "/etc/lava-server/{{filename}}.conf"), + help=( + "Template used for constructing instance pathname." + " The default value is: %(default)s")) + parser.add_argument( + "command", nargs="...", + help="Invoke this Django management command") def invoke(self): if self.args.production: @@ -90,7 +99,8 @@ else: settings_module = "lava_server.settings.development" if self.args.instance: - ddst = self.args.instance_template.format(instance=self.args.instance) + ddst = self.args.instance_template.format( + instance=self.args.instance) os.environ["DJANGO_DEBIAN_SETTINGS_TEMPLATE"] = ddst settings = __import__(settings_module, fromlist=['']) from django.core.management import execute_manager @@ -115,9 +125,8 @@ settings_module = "lava_server.settings.development" settings = __import__(settings_module, fromlist=['']) from django.core.management import execute_manager - execute_manager(settings) + execute_manager(settings) if __name__ == "__main__": legacy_main() - === modified file 'lava_server/settings/common.py' --- lava_server/settings/common.py 2011-09-23 08:25:04 +0000 +++ lava_server/settings/common.py 2011-10-11 09:20:14 +0000 @@ -119,9 +119,7 @@ from openid import oidutil oidutil.log = lambda msg, level=0: None -RESTRUCTUREDTEXT_FILTER_SETTINGS = { - "initial_header_level": 4 -} +RESTRUCTUREDTEXT_FILTER_SETTINGS = {"initial_header_level": 4} # Skip south tests as they seem to break everything else. # This is fixed in south 0.7.1, if we upgrade past that it's safe to === modified file 'lava_server/settings/debian.py' --- lava_server/settings/debian.py 2011-09-05 14:57:05 +0000 +++ lava_server/settings/debian.py 2011-10-11 09:20:14 +0000 @@ -9,9 +9,7 @@ debian_settings = Settings("lava-server") # Load default database from Debian integration -DATABASES = { - 'default': debian_settings.default_database -} +DATABASES = {'default': debian_settings.default_database} # Load debug settings from the configuration file DEBUG = debian_settings.DEBUG @@ -28,7 +26,7 @@ MEDIA_URL = debian_settings.MEDIA_URL # Absolute filesystem path to the directory that will hold static, read only -# files collected from all applications. +# files collected from all applications. STATIC_ROOT = debian_settings.STATIC_ROOT # URL that handles the media served from STATIC_ROOT. Make sure to use a @@ -62,7 +60,7 @@ # link). This is only used if CommonMiddleware is installed (see Middleware. # See also IGNORABLE_404_STARTS, IGNORABLE_404_ENDS and Error reporting via # e-mail. -SEND_BROKEN_LINK_EMAILS=debian_settings.SEND_BROKEN_LINK_EMAILS +SEND_BROKEN_LINK_EMAILS = debian_settings.SEND_BROKEN_LINK_EMAILS # Load extensions loader.contribute_to_settings(locals(), debian_settings) === modified file 'lava_server/settings/development.py' --- lava_server/settings/development.py 2011-09-16 09:40:08 +0000 +++ lava_server/settings/development.py 2011-10-11 09:20:14 +0000 @@ -29,18 +29,20 @@ # environment. LOCALENV_DIR = os.getenv("VIRTUAL_ENV") if not LOCALENV_DIR: - print "Not using lava-dev-tool? Well okay, but just be careful with your imports and python path" + print "Not using lava-dev-tool?" + print "Well okay, but just be careful with your imports and python path" # Top-level directory of the project. # # This directory MUST contain two sub-directories: -# * templates/ - project-wide template files -# * htdocs/ - project-wide static files (_not_ the root of the static file cache) +# * templates/ - project-wide template files +# * htdocs/ - project-wide static files +# (_not_ the root of the static file cache) PROJECT_SRC_DIR = os.path.normpath( os.path.join( os.path.dirname( os.path.abspath(__file__)), - "..")) + "..")) # Top-level directory for nonvolatile files, as used by lava-dev-tool. It is a # sibling directory to localenv so it's easier to define its location as @@ -48,7 +50,7 @@ if LOCALENV_DIR: PRECIOUS_DIR = os.path.join(LOCALENV_DIR, "../precious") else: - PRECIOUS_DIR = os.path.join(PROJECT_SRC_DIR, "precious") + PRECIOUS_DIR = os.path.join(PROJECT_SRC_DIR, "precious") # Create precious directory if needed if not os.path.exists(PRECIOUS_DIR): @@ -89,7 +91,8 @@ DATA_URL_PREFIX = r"" -# XXX: this is ugly, it would be good to have rails-like configuration file in the future +# XXX: this is ugly! +# It would be good to have rails-like configuration file in the future devel_db = os.getenv("DEVEL_DB", "sqlite") if devel_db == "pgsql": DATABASES = { @@ -99,9 +102,7 @@ 'USER': 'devel', 'PASSWORD': 'devel', 'HOST': 'localhost', - 'PORT': '' - } - } + 'PORT': ''}} elif devel_db == "sqlite": DATABASES = { 'default': { @@ -110,9 +111,7 @@ 'USER': '', 'PASSWORD': '', 'HOST': '', - 'PORT': '', - } - } + 'PORT': ''}} elif devel_db == "nosql": raise ValueError("not yet ;-)") else: @@ -124,7 +123,7 @@ MEDIA_ROOT = os.path.join(PROJECT_STATE_DIR, "media", devel_db) # Absolute filesystem path to the directory that will hold static, read only -# files collected from all applications. +# files collected from all applications. # Example: "/home/media/static.lawrence.com/" STATIC_ROOT = os.path.join(PROJECT_STATE_DIR, "static") @@ -144,7 +143,9 @@ ADMIN_MEDIA_PREFIX = "/" + DATA_URL_PREFIX + "static/admin/" if not DEBUG: - raise Exception("You need to configure MEDIA_URL, STATIC_URL and ADMIN_MEDIA_PREFIX to point to a production web server") + raise Exception( + "You need to configure MEDIA_URL, STATIC_URL and ADMIN_MEDIA_PREFIX to" + "point to a production web server") # Make this unique, and don't share it with anybody. SECRET_KEY = '00000000000000000000000000000000000000000000000000' @@ -154,15 +155,15 @@ os.path.join(PROJECT_SRC_DIR, "templates"), ) -STATICFILES_DIRS = [ - ('lava-server', os.path.join(PROJECT_SRC_DIR, 'htdocs')) -] - +STATICFILES_DIRS = [('lava-server', os.path.join(PROJECT_SRC_DIR, 'htdocs'))] + + +INSTALLED_APPS += ['devserver'] # Login redirects back to home LOGIN_REDIRECT_URL = '/' -# Any emails that would normally be sent are redirected to stdout. +# Any emails that would normally be sent are redirected to stdout. # This setting is only used for django 1.2 and newer. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' === modified file 'lava_server/settings/production.py' --- lava_server/settings/production.py 2011-07-13 11:27:51 +0000 +++ lava_server/settings/production.py 2011-10-11 09:20:14 +0000 @@ -19,7 +19,7 @@ # Django settings for django_hello project. from lava_server.settings.common import * -DEBUG = False +DEBUG = False TEMPLATE_DEBUG = DEBUG # Application URL prefix defines where the application is located at @@ -65,4 +65,6 @@ LOGIN_URL = '/' + DATA_URL_PREFIX + 'accounts/login/' if DEBUG: - raise Exception("You should not run this application with debugging in a production environment") + raise Exception( + "You should not run this application with debugging in a production" + " environment") === modified file 'lava_server/templates/index.html' --- lava_server/templates/index.html 2011-09-16 12:59:19 +0000 +++ lava_server/templates/index.html 2011-10-11 09:20:14 +0000 @@ -4,7 +4,7 @@ {% block content %}

LAVA Highlights

-{% for extension in lava.extension_list %} +{% for extension in extension_list %} {% if extension.front_page_template %}

{{ extension.description }}

{% include extension.front_page_template %} === modified file 'lava_server/urls.py' --- lava_server/urls.py 2011-10-06 20:12:00 +0000 +++ lava_server/urls.py 2011-10-11 09:20:14 +0000 @@ -17,7 +17,8 @@ # along with LAVA Server. If not, see . from django.conf import settings -from django.conf.urls.defaults import handler404, handler500, include, patterns, url +from django.conf.urls.defaults import ( + handler404, handler500, include, patterns, url) from django.contrib import admin from django.views.generic.simple import direct_to_template from staticfiles.urls import staticfiles_urlpatterns @@ -34,25 +35,36 @@ # Root URL patterns urlpatterns = patterns( '', - url(r'^' + settings.APP_URL_PREFIX + r'$', index, name='lava.home'), - url(r'^' + settings.APP_URL_PREFIX + r'version/$', version, name='lava.version_details'), - url(r'^' + settings.APP_URL_PREFIX + r'accounts/', include('django.contrib.auth.urls')), - url(r'^' + settings.APP_URL_PREFIX + r'admin/', include(admin.site.urls)), - url(r'^' + settings.APP_URL_PREFIX + r'openid/', include('django_openid_auth.urls')), - url(r'^' + settings.APP_URL_PREFIX + r'RPC2/', 'linaro_django_xmlrpc.views.handler', + url(r'^' + settings.APP_URL_PREFIX + r'$', + index, + name='lava.home'), + url(r'^' + settings.APP_URL_PREFIX + r'version/$', + version, + name='lava.version_details'), + url(r'^' + settings.APP_URL_PREFIX + r'accounts/', + include('django.contrib.auth.urls')), + url(r'^' + settings.APP_URL_PREFIX + r'admin/', + include(admin.site.urls)), + url(r'^' + settings.APP_URL_PREFIX + r'openid/', + include('django_openid_auth.urls')), + url(r'^' + settings.APP_URL_PREFIX + r'RPC2/', + 'linaro_django_xmlrpc.views.handler', name='lava.api_handler', kwargs={ 'mapper': loader.xmlrpc_mapper, 'help_view': 'lava.api_help'}), - url(r'^' + settings.APP_URL_PREFIX + r'api/help/$', 'linaro_django_xmlrpc.views.help', + url(r'^' + settings.APP_URL_PREFIX + r'api/help/$', + 'linaro_django_xmlrpc.views.help', name='lava.api_help', kwargs={ 'mapper': loader.xmlrpc_mapper}), - url(r'^' + settings.APP_URL_PREFIX + r'api/', include(api_urls.token_urlpatterns)), + url(r'^' + settings.APP_URL_PREFIX + r'api/', + include(api_urls.token_urlpatterns)), # XXX: This is not needed but without it linaro-django-xmlrpc tests fail - url(r'^' + settings.APP_URL_PREFIX + r'api/', include(api_urls.default_mapper_urlpatterns)), - url(r'^' + settings.APP_URL_PREFIX + r'utils/markitup/', include('lava_markitup.urls')), -) + url(r'^' + settings.APP_URL_PREFIX + r'api/', + include(api_urls.default_mapper_urlpatterns)), + url(r'^' + settings.APP_URL_PREFIX + r'utils/markitup/', + include('lava_markitup.urls'))) # Enable static files serving for development server === modified file 'lava_server/views.py' --- lava_server/views.py 2011-10-06 20:09:17 +0000 +++ lava_server/views.py 2011-10-11 09:20:14 +0000 @@ -16,14 +16,24 @@ # You should have received a copy of the GNU Affero General Public License # along with LAVA Server. If not, see . +from django.http import HttpResponse +from django.template import loader, RequestContext from django.views.generic.simple import direct_to_template +from lava_server.extension import loader as extension_loader + def index(request): - return direct_to_template( - template='index.html') + # Start with a list of extensions + data = {'extension_list': extension_loader.extensions} + # Append each extension context data + for extension in extension_loader.extensions: + data.update(extension.get_front_page_context()) + # Load and render the template + context = RequestContext(request, data) + template = loader.get_template('index.html') + return HttpResponse(template.render(context)) def version(request): - return direct_to_template( - template='version_details.html') + return direct_to_template(request, 'version_details.html') === modified file 'lava_server/xmlrpc.py' --- lava_server/xmlrpc.py 2011-06-08 23:49:04 +0000 +++ lava_server/xmlrpc.py 2011-10-11 09:20:14 +0000 @@ -43,4 +43,3 @@ has. """ self.register(LavaSystemAPI, 'system') -