def __readConfigFile(self): """initializes configuration parameters (Search order: indico.conf, default_values) IF YOU WANT TO CREATE NEW USER CONFIGURABLE OPTIONS: If you need to define a new configuration option you _need_ to specify it here with its default value and then you can put it in indico.conf. #### Indico will not see options that don't appear here #### """ self._configVars = {} declared_values = dir(MaKaCConfig) # When populating configuration variables indico.conf's values have priority for k in self.default_values: if k in declared_values: self._configVars[k] = MaKaCConfig.__getattribute__(k) # declared_values[k] doesn't work, don't ask me why else: # key is not declared in indico.conf, using its default value self._configVars[k] = self.default_values[k] # options that are derived automatically self._deriveOptions() self.__tplFiles = {} if self.getSanitizationLevel() not in range(4): raise MaKaCError("Invalid SanitizationLevel value (%s). Valid values: 0, 1, 2, 3" % (self._configVars['SanitizationLevel'])) if self.getCSRFLevel() not in range(4): raise MaKaCError("Invalid CSRFLevel value (%s). Valid values: 0, 1, 2, 3" % (self._configVars['CSRFLevel']))
def __readConfigFile(self): """initializes configuration parameters (Search order: indico.conf, default_values) IF YOU WANT TO CREATE NEW USER CONFIGURABLE OPTIONS: If you need to define a new configuration option you _need_ to specify it here with its default value and then you can put it in indico.conf. #### Indico will not see options that don't appear here #### """ self._configVars = {} declared_values = dir(MaKaCConfig) # When populating configuration variables indico.conf's values have priority for k in self.default_values: if k in declared_values: self._configVars[k] = MaKaCConfig.__getattribute__( k) # declared_values[k] doesn't work, don't ask me why else: # key is not declared in indico.conf, using its default value self._configVars[k] = self.default_values[k] # options that are derived automatically self._deriveOptions() self.__tplFiles = {} if self.getSanitizationLevel() not in range(4): raise MaKaCError( "Invalid SanitizationLevel value (%s). Valid values: 0, 1, 2, 3" % (self._configVars['SanitizationLevel'])) if self.getCSRFLevel() not in range(4): raise MaKaCError( "Invalid CSRFLevel value (%s). Valid values: 0, 1, 2, 3" % (self._configVars['CSRFLevel']))
def __readConfigFile(self): """initializes configuration parameters (Search order: indico.conf, default_values) IF YOU WANT TO CREATE NEW USER CONFIGURABLE OPTIONS: If you need to define a new configuration option you _need_ to specify it here with its default value and then you can put it in indico.conf. #### Indico will not see options that don't appear here #### """ self._configVars = {} declared_values = dir(MaKaCConfig) # When populating configuration variables indico.conf's values have priority for k in self.default_values: if k in declared_values: self._configVars[k] = MaKaCConfig.__getattribute__(k) # declared_values[k] doesn't work, don't ask me why else: # key is not declared in indico.conf, using its default value self._configVars[k] = self.default_values[k] # options that are derived automatically self._deriveOptions() self.__tplFiles = {} if self.getSanitizationLevel() not in range(4): raise MaKaCError("Invalid SanitizationLevel value (%s). Valid values: 0, 1, 2, 3" % (self._configVars['SanitizationLevel'])) if self.getCSRFLevel() not in range(4): raise MaKaCError("Invalid CSRFLevel value (%s). Valid values: 0, 1, 2, 3" % (self._configVars['CSRFLevel'])) if self.getRedisConnectionURL(): # Rest if redis is available and if we can connect try: import redis redis.StrictRedis.from_url(self.getRedisConnectionURL()) # a redis ping here would be nice but we do not have a working logger yet except ImportError, e: raise MaKaCError('Could not import redis: %s' % e.message)
def __readConfigFile(self): """initializes configuration parameters (Search order: indico.conf, default_values) IF YOU WANT TO CREATE NEW USER CONFIGURABLE OPTIONS: If you need to define a new configuration option you _need_ to specify it here with its default value and then you can put it in indico.conf. #### Indico will not see options that don't appear here #### """ default_values = { 'DBConnectionParams' : ("localhost", 9675), 'DBUserName' : '', 'DBPassword' : '', 'DBRealm' : '', 'SanitizationLevel' : 1, 'BaseURL' : 'http://localhost/', 'BaseSecureURL' : 'https://localhost/', 'LoginURL' : "", 'RegistrationURL' : "", 'ShortEventTag' : "/event/", 'ShortCategTag' : "/categ/", 'ConfigurationDir' : "/opt/indico/etc", 'DocumentationDir' : "/opt/indico/doc", 'HtdocsDir' : "/opt/indico/htdocs", 'LogDir' : "/opt/indico/log" , 'ArchiveDir' : "/opt/indico/archive", 'BinDir' : "/opt/indico/bin", 'UploadedFilesTempDir' : "/opt/indico/tmp", 'XMLCacheDir' : "/opt/indico/cache", 'SmtpServer' : 'localhost', 'SmtpLogin' : '', 'SmtpPassword' : '', 'SmtpUseTLS' : 'no', 'SupportEmail' : 'root@localhost', 'PublicSupportEmail' : 'root@localhost', 'IndicoSearchServer' : '', 'IndicoSearchClass' : 'MaKaC.search.invenioSEA.InvenioSEA', 'FileConverter' : {"conversion_server": "", "response_url": "http://localhost/getConvertedFile.py"}, 'AuthenticatorList' : ['Local'], 'NiceLogin' : '', 'NicePassword' : '', 'CssStylesheetName' : 'indico.css', 'PublicFolder' : "/opt/indico/htdocs/results", 'ReportNumberSystems' : {}, 'OAILogFile' : "/opt/indico/log/oai.log", 'NbRecordsInResume' : 100, 'NbIdentifiersInResume': 100, 'OAIRtExpire' : 90000, 'OAINamespace' : '', 'IconfNamespace' : "http://localhost/", 'IconfXSD' : "http://localhost/iconf.xsd", 'RepositoryName' : '', 'RepositoryIdentifier' : '', 'ApacheUser' : 'nobody', 'ApacheGroup' : 'nogroup', # Room Booking Related 'LightboxCssStylesheetName': "lightbox/lightbox.css", 'LightboxJavascriptName' : "lightbox/lightbox.js", } if sys.platform == 'win32': default_values.update({ "ConfigurationDir" : "C:\\indico\\etc", "DocumentationDir" : "C:\\indico\\doc", "HtdocsDir" : "C:\\Program Files\\Apache Group\\Apache2\\htdocs\\MaKaC", "LogDir" : "C:\\indico\\log", "ArchiveDir" : "C:\\indico\\archive", "BinDir" : "C:\\indico\\archive", "UploadedFilesTempDir" : "C:\\indico\\temp", "XMLCacheDir" : "C:\\indico\\cache", }) self._configVars = {} declared_values = dir(MaKaCConfig) # When populating configuration variables indico.conf's values have priority for k in default_values: if k in declared_values: self._configVars[k] = MaKaCConfig.__getattribute__(k) # declared_values[k] doesn't work, don't ask me why else: # key is not declared in indico.conf, using its default value self._configVars[k] = default_values[k] # Variables whose value is derived automatically # THIS IS THE PLACE TO ADD NEW SHORTHAND OPTIONS, DONT CREATE A FUNCTION IF THE VALUE NEVER CHANGES, # Configuration.py will become fat again if you don't follow this advice. self._configVars.update({ 'TPLVars' : {"MaKaCHomeURL": "%sindex.py" % self.getBaseURL()}, 'FileTypes' : MaKaCConfig.FileTypes, 'HelpDir' : os.path.join(self.getHtdocsDir(), 'ihelp'), 'WorkerName' : socket.gethostname(), 'StylesheetsDir' : os.path.join(os.path.dirname(__file__), '..', 'webinterface', 'stylesheets'), 'ImagesDir' : os.path.join(self.getHtdocsDir(), 'images'), 'PublicURL' : "%s/%s" % (self.getBaseURL(), self.getPublicFolder()), 'SystemIcons' : self.__systemIcons, 'Stylesheets' : self.__stylesheets, 'EventStylesheets' : self.__eventStylesheets, 'TempDir' : self.getUploadedFilesTempDir(), 'RoomPhotosDir' : os.path.join(self.getHtdocsDir(), 'images', "rooms", "large_photos"), 'RoomSmallPhotosDir' : os.path.join(self.getHtdocsDir(), 'images', "rooms", "small_photos"), 'CssDir' : "%s/css/" % (self.getHtdocsDir()), 'CssBaseURL' : "%s/css" % self.getBaseURL(), 'CssConfTemplateBaseURL' : "%s/css/confTemplates" % self.getBaseURL(), 'DefaultEventStylesheet' : self.__defaultEventStylesheet, 'ShortCategURL' : '%s%s' % (self.getBaseURL(), self.getShortCategTag()), 'ShortEventURL' : '%s%s' % (self.getBaseURL(), self.getShortEventTag()), 'TPLDir' : os.path.join(os.path.dirname(__file__), '..', 'webinterface', 'tpls'), 'HostNameURL' : urlparse.urlparse(self.getBaseURL())[1].split(':')[0], 'FileConverterServerURL' : self.getFileConverter().get("conversion_server", ""), 'FileConverterResponseURL': self.getFileConverter().get("response_url", ""), 'ImagesBaseURL' : "%s/images" % self._configVars['BaseURL'], 'ImagesBaseSecureURL' : "%s/images" % self._configVars['BaseSecureURL'], 'Version' : MaKaC.__version__, }) self.__tplFiles = {} if self.getSanitizationLevel() not in range(4): raise "Invalid SanitizationLevel value (%s). Valid values: 0, 1, 2, 3" % (self._configVars['SanitizationLevel'])