opencore r18827 - fassembler/trunk/fassembler
from
slinkp
on 2008-07-02 18:43
Author: pw
Date: 2008-07-02 18:43:14 -0400 (Wed, 02 Jul 2008)
New Revision: 18827
Modified:
fassembler/trunk/fassembler/topp_brainpower.py
Log:
ADDED: Create a symlink from django's admin media directory.
ADDED: Print an example apache conf that sets up mod_python correctly.
Modified: fassembler/trunk/fassembler/topp_brainpower.py
===================================================================
--- fassembler/trunk/fassembler/topp_brainpower.py 2008-07-02 22:42:06 UTC (rev 18826)
+++ fassembler/trunk/fassembler/topp_brainpower.py 2008-07-02 22:43:14 UTC (rev 18827)
@@ -6,9 +6,39 @@
from fassembler import tasks
from fassembler.project import Project, Setting
import os
+import subprocess
interpolated = tasks.interpolated
+apache_conf_prelude = """
+To serve brainpower via apache and mod_python, you should put
+this in your apache config:
+"""
+
+apache_conf_example = """
+ <VirtualHost ...>
+ ServerName ...
+ SetEnv DJANGO_SETTINGS_MODULE brainpower.settings
+ SetEnv PYTHON_EGG_CACHE /tmp/egg-cache
+ DocumentRoot {{task.htdocs}}
+ <Location "/">
+ SetHandler python-program
+ PythonPath "['{{project.build_properties.get("virtualenv_bin_path") or "argh"}}'] + sys.path"
+ PythonHandler brainpower_handler
+ PythonDebug Off
+ </Location>
+ <Location "/adminmedia/">
+ SetHandler None
+ </Location>
+ </VirtualHost>
+ """
+
+apache_conf_postscript = """
+To avoid editing apache's config on every build, use a 'current'
+symlink instead of the dated build directory for DocumentRoot and
+PythonPath, and just update the symlink after each build.
+"""
+
class InstallDjango(tasks.InstallTarball):
version_path = interpolated('version_path')
@@ -49,6 +79,36 @@
self.maker.run_command(py, 'setup.py', 'install', cwd=where)
+class AdminMediaLink(tasks.Task):
+
+ htdocs = interpolated('htdocs')
+
+ def __init__(self, name, stacklevel=1):
+ super(AdminMediaLink, self).__init__(name, stacklevel=stacklevel+1)
+ self.htdocs = '{{project.build_properties["virtualenv_path"]}}/htdocs'
+
+ def run(self):
+ self.maker.ensure_dir(self.htdocs, svn_add=False)
+ linktarget = os.path.join(self.htdocs, 'adminmedia')
+ py = self.interpolate(
+ '{{project.build_properties["virtualenv_bin_path"]}}/python',
+ stacklevel=1)
+ script = subprocess.Popen(
+ [py, '-c',
+ 'import os, django; print os.path.dirname(django.__file__)'],
+ stdout=subprocess.PIPE)
+ stdout, stderr = script.communicate()
+ djangopath = stdout.strip()
+ linksource = os.path.join(djangopath, 'contrib', 'admin', 'media')
+ self.maker.ensure_symlink(linksource, linktarget, overwrite=True)
+ apache_example = self.interpolate(apache_conf_example)
+ self.logger.notify(apache_conf_prelude,
+ color='green')
+ self.logger.notify(apache_example, color="yellow")
+ self.logger.notify(apache_conf_postscript, color='green')
+
+
+
class BrainpowerProject(Project):
"""Brainpower base project class"""
@@ -144,7 +204,8 @@
# Order of arguments matters here! Watch out for
# django bug http://code.djangoproject.com/ticket/7595
tasks.Script('Initialize brainpower test database',
- ['brainpower/bin/manage.py', 'syncdb', '--settings=brainpower.test_settings', '--noinput'])
-
-
+ ['brainpower/bin/manage.py', 'syncdb', '--settings=brainpower.test_settings', '--noinput']
+ ),
+
+ AdminMediaLink('Link topp admin media into {{task.htdocs}}.'),
]