81 lines
2.9 KiB
Python
81 lines
2.9 KiB
Python
# w.c.s. - web application for online forms
|
|
# Copyright (C) 2005-2010 Entr'ouvert
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import ConfigParser
|
|
import django.apps
|
|
from django.conf import settings
|
|
from quixote import get_publisher
|
|
|
|
try:
|
|
import lasso
|
|
except ImportError:
|
|
lasso = None
|
|
|
|
def _(message):
|
|
pub = get_publisher()
|
|
if pub is None:
|
|
return message
|
|
return unicode(pub.gettext(str(message)), 'utf-8').encode(pub.site_charset)
|
|
|
|
def ngettext(*args):
|
|
pub = get_publisher()
|
|
if pub is None:
|
|
return message
|
|
return unicode(pub.ngettext(*args), 'utf-8').encode(pub.site_charset)
|
|
|
|
from publisher import get_cfg, get_logger, get_publisher_class
|
|
import publisher
|
|
publisher._ = _
|
|
|
|
|
|
class AppConfig(django.apps.AppConfig):
|
|
name = 'wcs.qommon'
|
|
|
|
def ready(self):
|
|
config = ConfigParser.ConfigParser()
|
|
if settings.WCS_LEGACY_CONFIG_FILE:
|
|
config.read(settings.WCS_LEGACY_CONFIG_FILE)
|
|
if hasattr(settings, 'WCS_EXTRA_MODULES') and settings.WCS_EXTRA_MODULES:
|
|
if not config.has_section('extra'):
|
|
config.add_section('extra')
|
|
for i, extra in enumerate(settings.WCS_EXTRA_MODULES):
|
|
config.set('extra', 'cmd_line_extra_%d' % i, extra)
|
|
|
|
get_publisher_class().configure(config)
|
|
get_publisher_class().register_tld_names = True
|
|
get_publisher_class().init_publisher_class()
|
|
|
|
default_app_config = 'wcs.qommon.AppConfig'
|
|
|
|
|
|
if lasso:
|
|
if not hasattr(lasso, 'SAML2_SUPPORT'):
|
|
lasso.SAML2_SUPPORT = False
|
|
if not hasattr(lasso, 'SAML2_NAME_IDENTIFIER_FORMAT_EMAIL'):
|
|
lasso.SAML2_NAME_IDENTIFIER_FORMAT_EMAIL = 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
|
|
if not hasattr(lasso, 'SAML2_NAME_IDENTIFIER_FORMAT_UNSPECIFIED'):
|
|
lasso.SAML2_NAME_IDENTIFIER_FORMAT_EMAIL = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'
|
|
|
|
if not hasattr(lasso, 'cptrToPy') and not hasattr(lasso, 'OrigProvider'):
|
|
lasso.OrigProvider = lasso.Provider
|
|
# old (SWIG) bindings
|
|
class Provider(lasso.OrigProvider):
|
|
def __init__(self, *args):
|
|
lasso.OrigProvider.__init__(self, *args)
|
|
if self.this is None:
|
|
raise lasso.Error('Error creating Provider')
|
|
lasso.Provider = Provider
|