Skip to content

Commit

Permalink
Update fassembler build for brainpower to spit out a better apache co…
Browse files Browse the repository at this point in the history
…nfig, and link the brainpower media dir.
  • Loading branch information
slinkp committed Aug 27, 2009
1 parent cf97334 commit f075f41
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions fassembler/topp_brainpower.py
Expand Up @@ -16,22 +16,39 @@
"""

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>
"""
<VirtualHost ...>
ServerName ...
SetEnv DJANGO_SETTINGS_MODULE brainpower.settings
SetEnv PYTHON_EGG_CACHE /tmp/egg-cache
DocumentRoot {{task.htdocs}}
RewriteEngine on
# By default, go to the filmclip admin page.
RewriteRule ^/$ /admin/filmy/filmclip/ [R]
RewriteRule ^/admin/filmy/$ /admin/filmy/filmclip/ [R]
# Django uses a lot of links that break if the current URL doesn't have a
# trailing slash. But we don't want trailing slashes on images, css, etc.
# Hackaround: Don't rewrite urls in /*media directories.
RewriteCond %{REQUEST_URI} !^/.*media/.*
RewriteRule ^/(.*)([^/]+)$ /$1$2/ [R]
<Location "/">
SetHandler python-program
PythonPath "['{{project.build_properties.get("virtualenv_bin_path") or "argh"}}'] + sys.path"
PythonHandler brainpower_handler
PythonDebug Off
</Location>
<Location "/adminmedia/">
# Use the files under $DocumentRoot/htdocs/adminmedia
SetHandler None
</Location>
<Location "/brainpower_media/">
SetHandler None
</Location>
</VirtualHost>
"""

apache_conf_postscript = """
To avoid editing apache's config on every build, use a 'current'
Expand Down Expand Up @@ -79,17 +96,16 @@ def post_unpack_hook(self):
self.maker.run_command(py, 'setup.py', 'install', cwd=where)


class AdminMediaLink(tasks.Task):
class MediaLinks(tasks.Task):

htdocs = interpolated('htdocs')

def __init__(self, name, stacklevel=1):
super(AdminMediaLink, self).__init__(name, stacklevel=stacklevel+1)
super(MediaLinks, 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)
Expand All @@ -99,8 +115,16 @@ def run(self):
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)

adminsource = os.path.join(djangopath, 'contrib', 'admin', 'media')
bpsource = self.interpolate(
'{{project.build_properties["virtualenv_path"]}}'
'/src/brainpower/brainpower/media')
for linktarget, linksource in (('adminmedia', adminsource),
('brainpower_media', bpsource)):
linktarget = os.path.join(self.htdocs, linktarget)
self.maker.ensure_symlink(linksource, linktarget, overwrite=True)

apache_example = self.interpolate(apache_conf_example)
self.logger.notify(apache_conf_prelude,
color='green')
Expand Down Expand Up @@ -210,5 +234,5 @@ def get_req_setting(self, setting):
content_path='{{project.build_properties["virtualenv_path"]}}/src/brainpower/brainpower_handler.py',
executable=True,
),
AdminMediaLink('Link topp admin media into {{task.htdocs}}.'),
MediaLinks('Link media directories into {{task.htdocs}}.'),
]

0 comments on commit f075f41

Please sign in to comment.