django-orchestra-test/orchestra/contrib/webapps/backends/symboliclink.py

36 lines
1.1 KiB
Python
Raw Normal View History

2015-04-09 14:32:10 +00:00
import textwrap
2015-03-04 21:06:16 +00:00
from django.utils.translation import ugettext_lazy as _
2015-04-05 18:02:36 +00:00
from orchestra.contrib.orchestration import ServiceController, replace
2015-03-04 21:06:16 +00:00
2015-04-09 14:32:10 +00:00
from .php import PHPBackend
2015-03-04 21:06:16 +00:00
2015-04-09 14:32:10 +00:00
class SymbolicLinkBackend(PHPBackend, ServiceController):
2015-04-23 19:46:23 +00:00
"""
Same as PHPBackend but allows you to have the webapps on a directory diferent than the webapps dir.
"""
2015-03-04 21:06:16 +00:00
verbose_name = _("Symbolic link webapp")
model = 'webapps.WebApp'
default_route_match = "webapp.type == 'symbolic-link'"
2015-04-09 14:32:10 +00:00
def create_webapp_dir(self, context):
self.append(textwrap.dedent("""\
if [[ ! -e %(app_path)s ]]; then
ln -s '%(link_path)s' %(app_path)s
fi
chown -h %(user)s:%(group)s %(app_path)s
""") % context
)
2015-03-04 21:06:16 +00:00
2015-04-09 14:32:10 +00:00
def set_under_construction(self, context):
pass
2015-03-04 21:06:16 +00:00
def get_context(self, webapp):
context = super(SymbolicLinkBackend, self).get_context(webapp)
context.update({
'link_path': webapp.data['path'],
})
2015-04-05 18:02:36 +00:00
return replace(context, "'", '"')