summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjschneider <jschneider@3ed937ae-f919-0410-9a43-8e6f19e4ba6e>2009-10-02 16:32:22 (GMT)
committerjschneider <jschneider@3ed937ae-f919-0410-9a43-8e6f19e4ba6e>2009-10-02 16:32:22 (GMT)
commit51c1afbec9d9c3a135968178a83252f9223b5536 (patch)
treee0e49574c0eee2bfed906317deb77a12911466f8
parentf85cca12574fa76d0fb45d871373c63322cb61a8 (diff)
downloadlarpe-51c1afbec9d9c3a135968178a83252f9223b5536.zip
larpe-51c1afbec9d9c3a135968178a83252f9223b5536.tar.gz
larpe-51c1afbec9d9c3a135968178a83252f9223b5536.tar.bz2
Fixed apache vhost generation
* larpe/admin/apache.py: cosmetic changes * larpe/admin/hosts.ptl: initialize apache_python_paths and apache_output_python_filters correctly and optimize the code * larpe/site_authentication.ptl: get_filters must return an iterable object git-svn-id: svn+ssh://labs.libre-entreprise.org/svnroot/larpe@485 3ed937ae-f919-0410-9a43-8e6f19e4ba6e
-rw-r--r--larpe/trunk/larpe/admin/apache.py8
-rw-r--r--larpe/trunk/larpe/admin/hosts.ptl22
-rw-r--r--larpe/trunk/larpe/site_authentication.ptl2
3 files changed, 15 insertions, 17 deletions
diff --git a/larpe/trunk/larpe/admin/apache.py b/larpe/trunk/larpe/admin/apache.py
index 060b0f8..3fd607f 100644
--- a/larpe/trunk/larpe/admin/apache.py
+++ b/larpe/trunk/larpe/admin/apache.py
@@ -147,8 +147,8 @@ class Location(object):
reversed_directory = property(get_reversed_directory)
def get_python_path(self):
- if hasattr(self.host, 'apache_output_python_filters') and \
- hasattr(self.host, 'apache_python_paths') and self.host.apache_python_paths:
+ if self.host.apache_output_python_filters and \
+ self.host.apache_python_paths:
python_path = 'PythonPath "sys.path'
for path in self.host.apache_python_paths:
python_path += "+['%s']" % path
@@ -161,14 +161,14 @@ class Location(object):
def get_output_filters(self):
python_filters = ''
output_filters = []
- if hasattr(self.host, 'apache_output_python_filters'):
+ if self.host.apache_output_python_filters:
i = 0
for filter_file in self.host.apache_output_python_filters:
filter_name = 'filter%d' % i
python_filters += 'PythonOutputFilter %s %s\n\t\t' % (filter_file, filter_name)
output_filters.append(filter_name)
i += 1
- if hasattr(self.host, 'apache_output_filters'):
+ if self.host.apache_output_filters:
for output_filter in self.host.apache_output_filters:
output_filters.append(output_filter)
if output_filters:
diff --git a/larpe/trunk/larpe/admin/hosts.ptl b/larpe/trunk/larpe/admin/hosts.ptl
index dc11279..72a07ce 100644
--- a/larpe/trunk/larpe/admin/hosts.ptl
+++ b/larpe/trunk/larpe/admin/hosts.ptl
@@ -792,19 +792,21 @@ POST request. You can desactivate some or all of them, or change their value.'''
self.host.store()
def generate_apache_filters(self):
- # Set Python filter path for Apache configuration
+ self.host.apache_python_paths = []
+ self.host.apache_output_python_filters = []
site_auth = site_authentication.get_site_authentication(self.host)
filters = site_auth.get_filters()
replace_login_form = self.host.auth_form_places == 'form_everywhere' and \
self.host.auth_form_action
- python_path = os.path.join(self.host.site_dir, 'filters')
- if python_path not in self.host.apache_python_paths:
- self.host.apache_python_paths.append(python_path)
-
- # Write Python filter
- python_file = open(os.path.join(self.host.site_dir, 'filters', 'output_replace_form.py'), 'w')
- python_file.write(open(OUTPUT_FILTER_BASE).read())
if filters or replace_login_form:
+ # Set Python filter path for Apache configuration
+ python_path = os.path.join(self.host.site_dir, 'filters')
+ if python_path not in self.host.apache_python_paths:
+ self.host.apache_python_paths.append(python_path)
+
+ # Write Python filter
+ python_file = open(os.path.join(self.host.site_dir, 'filters', 'output_replace_form.py'), 'w')
+ python_file.write(open(OUTPUT_FILTER_BASE).read())
python_file.write("def filter_page(filter, page):\n")
if replace_login_form:
python_file.write('''\
@@ -819,10 +821,6 @@ POST request. You can desactivate some or all of them, or change their value.'''
# Set Python filter for Apache configuration
if not 'output_replace_form' in self.host.apache_output_python_filters:
self.host.apache_output_python_filters.append('output_replace_form')
- else:
- if 'output_replace_form' in self.host.apache_output_python_filters:
- self.host.apache_output_python_filters.remove('output_replace_form')
-
def sso_init_link [html] (self):
form = self.form_sso_init_link()
diff --git a/larpe/trunk/larpe/site_authentication.ptl b/larpe/trunk/larpe/site_authentication.ptl
index b90d942..638a53a 100644
--- a/larpe/trunk/larpe/site_authentication.ptl
+++ b/larpe/trunk/larpe/site_authentication.ptl
@@ -115,7 +115,7 @@ class SiteAuthentication:
filters.append(filter)
return filters
"""
- return None
+ return list()
def submit_local_auth_form(self, form):
username = form.get_widget('username').parse()