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
This commit is contained in:
parent
f85cca1257
commit
51c1afbec9
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Reference in New Issue