diff -r bcb895aa2684 -r f9b46b63393e cubicweb/web/webconfig.py --- a/cubicweb/web/webconfig.py Thu Mar 21 11:47:10 2019 +0100 +++ b/cubicweb/web/webconfig.py Thu Mar 21 11:50:31 2019 +0100 @@ -32,28 +32,27 @@ from logilab.common.configuration import merge_options from cubicweb import ConfigurationError -from cubicweb.toolsutils import read_config from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options _DATA_DIR = join(dirname(__file__), 'data') -register_persistent_options( ( +register_persistent_options(( # site-wide only web ui configuration ('site-title', - {'type' : 'string', 'default': 'unset title', + {'type': 'string', 'default': 'unset title', 'help': _('site title'), 'sitewide': True, 'group': 'ui', }), ('main-template', - {'type' : 'string', 'default': 'main-template', + {'type': 'string', 'default': 'main-template', 'help': _('id of main template used to render pages'), 'sitewide': True, 'group': 'ui', }), # user web ui configuration ('fckeditor', - {'type' : 'yn', 'default': False, + {'type': 'yn', 'default': False, 'help': _('should html fields being edited using fckeditor (a HTML ' 'WYSIWYG editor). You should also select text/html as default ' 'text format to actually get fckeditor.'), @@ -61,23 +60,23 @@ }), # navigation configuration ('page-size', - {'type' : 'int', 'default': 40, + {'type': 'int', 'default': 40, 'help': _('maximum number of objects displayed by page of results'), 'group': 'navigation', }), ('related-limit', - {'type' : 'int', 'default': 8, + {'type': 'int', 'default': 8, 'help': _('maximum number of related entities to display in the primary ' 'view'), 'group': 'navigation', }), ('combobox-limit', - {'type' : 'int', 'default': 20, + {'type': 'int', 'default': 20, 'help': _('maximum number of entities to display in related combo box'), 'group': 'navigation', }), - )) +)) class BaseWebConfiguration(CubicWebConfiguration): @@ -87,7 +86,7 @@ options = merge_options(CubicWebConfiguration.options + ( ('repository-uri', - {'type' : 'string', + {'type': 'string', 'default': 'inmemory://', 'help': 'see `cubicweb.dbapi.connect` documentation for possible value', 'group': 'web', 'level': 2, @@ -98,26 +97,27 @@ 'group': 'ui', 'level': 2, }), ('anonymous-user', - {'type' : 'string', + {'type': 'string', 'default': None, - 'help': 'login of the CubicWeb user account to use for anonymous user (if you want to allow anonymous)', + 'help': ('login of the CubicWeb user account to use for anonymous ' + 'user (if you want to allow anonymous)'), 'group': 'web', 'level': 1, }), ('anonymous-password', - {'type' : 'string', + {'type': 'string', 'default': None, 'help': 'password of the CubicWeb user account to use for anonymous user, ' 'if anonymous-user is set', 'group': 'web', 'level': 1, }), ('query-log-file', - {'type' : 'string', + {'type': 'string', 'default': None, 'help': 'web instance query log file', 'group': 'web', 'level': 3, }), ('cleanup-anonymous-session-time', - {'type' : 'time', + {'type': 'time', 'default': '5min', 'help': 'Same as cleanup-session-time but specific to anonymous ' 'sessions. You can have a much smaller timeout here since it will be ' @@ -133,7 +133,7 @@ allowed or if an empty login is used in configuration """ try: - user = self['anonymous-user'] or None + user = self['anonymous-user'] or None passwd = self['anonymous-password'] if user: user = text_type(user) @@ -144,7 +144,6 @@ return user, passwd - class WebConfiguration(BaseWebConfiguration): """the WebConfiguration is a singleton object handling instance's configuration and preferences @@ -159,20 +158,20 @@ 'group': 'web', }), ('auth-mode', - {'type' : 'choice', - 'choices' : ('cookie', 'http'), + {'type': 'choice', + 'choices': ('cookie', 'http'), 'default': 'cookie', 'help': 'authentication mode (cookie / http)', 'group': 'web', 'level': 3, }), ('realm', - {'type' : 'string', + {'type': 'string', 'default': 'cubicweb', 'help': 'realm to use on HTTP authentication mode', 'group': 'web', 'level': 3, }), ('http-session-time', - {'type' : 'time', + {'type': 'time', 'default': 0, 'help': "duration of the cookie used to store session identifier. " "If 0, the cookie will expire when the user exist its browser. " @@ -180,7 +179,7 @@ 'group': 'web', 'level': 2, }), ('submit-mail', - {'type' : 'string', + {'type': 'string', 'default': None, 'help': ('Mail used as recipient to report bug in this instance, ' 'if you want this feature on'), @@ -188,31 +187,32 @@ }), ('language-mode', - {'type' : 'choice', + {'type': 'choice', 'choices': ('http-negotiation', 'url-prefix', ''), 'default': 'http-negotiation', 'help': ('source for interface\'s language detection. ' 'If set to "http-negotiation" the Accept-Language HTTP header will be used,' - ' if set to "url-prefix", the URL will be inspected for a short language prefix.'), + ' if set to "url-prefix", the URL will be inspected for a' + ' short language prefix.'), 'group': 'web', 'level': 2, }), ('print-traceback', - {'type' : 'yn', + {'type': 'yn', 'default': CubicWebConfiguration.mode != 'system', 'help': 'print the traceback on the error page when an error occurred', 'group': 'web', 'level': 2, }), ('captcha-font-file', - {'type' : 'string', + {'type': 'string', 'default': join(_DATA_DIR, 'porkys.ttf'), 'help': 'True type font to use for captcha image generation (you \ must have the python imaging library installed to use captcha)', 'group': 'web', 'level': 3, }), ('captcha-font-size', - {'type' : 'int', + {'type': 'int', 'default': 25, 'help': 'Font size to use for captcha image generation (you must \ have the python imaging library installed to use captcha)', @@ -220,7 +220,7 @@ }), ('concat-resources', - {'type' : 'yn', + {'type': 'yn', 'default': False, 'help': 'use modconcat-like URLS to concat and serve JS / CSS files', 'group': 'web', 'level': 2, @@ -244,36 +244,37 @@ 'group': 'web', 'level': 2, }), ('access-control-allow-origin', - {'type' : 'csv', + {'type': 'csv', 'default': (), - 'help':('comma-separated list of allowed origin domains or "*" for any domain'), + 'help': ('comma-separated list of allowed origin domains or "*" for any domain'), 'group': 'web', 'level': 2, }), ('access-control-allow-methods', - {'type' : 'csv', + {'type': 'csv', 'default': (), 'help': ('comma-separated list of allowed HTTP methods'), 'group': 'web', 'level': 2, }), ('access-control-max-age', - {'type' : 'int', + {'type': 'int', 'default': None, 'help': ('maximum age of cross-origin resource sharing (in seconds)'), 'group': 'web', 'level': 2, }), ('access-control-expose-headers', - {'type' : 'csv', + {'type': 'csv', 'default': (), - 'help':('comma-separated list of HTTP headers the application declare in response to a preflight request'), + 'help': ('comma-separated list of HTTP headers the application ' + 'declare in response to a preflight request'), 'group': 'web', 'level': 2, }), ('access-control-allow-headers', - {'type' : 'csv', + {'type': 'csv', 'default': (), - 'help':('comma-separated list of HTTP headers the application may set in the response'), + 'help': ('comma-separated list of HTTP headers the application may set in the response'), 'group': 'web', 'level': 2, }), - )) + )) def __init__(self, *args, **kwargs): super(WebConfiguration, self).__init__(*args, **kwargs) @@ -344,8 +345,8 @@ DeprecationWarning) rid = 'cubicweb.css' return self.ensure_uid_directory( - self.uiprops.process_resource( - join(directory, rdirectory), rid)), rid + self.uiprops.process_resource( + join(directory, rdirectory), rid)), rid return join(directory, rdirectory), rid def locate_all_files(self, rid, rdirectory='wdoc'): @@ -403,14 +404,14 @@ self._load_ui_properties_file(uiprops, path) self._load_ui_properties_file(uiprops, self.apphome) datadir_url = uiprops.context['datadir_url'] - if (datadir_url+'/cubicweb.old.css') in uiprops['STYLESHEETS']: + if (datadir_url + '/cubicweb.old.css') in uiprops['STYLESHEETS']: warn('[3.20] cubicweb.old.css has been renamed back to cubicweb.css', DeprecationWarning) - idx = uiprops['STYLESHEETS'].index(datadir_url+'/cubicweb.old.css') - uiprops['STYLESHEETS'][idx] = datadir_url+'/cubicweb.css' - if datadir_url+'/cubicweb.reset.css' in uiprops['STYLESHEETS']: + idx = uiprops['STYLESHEETS'].index(datadir_url + '/cubicweb.old.css') + uiprops['STYLESHEETS'][idx] = datadir_url + '/cubicweb.css' + if datadir_url + '/cubicweb.reset.css' in uiprops['STYLESHEETS']: warn('[3.20] cubicweb.reset.css is obsolete', DeprecationWarning) - uiprops['STYLESHEETS'].remove(datadir_url+'/cubicweb.reset.css') + uiprops['STYLESHEETS'].remove(datadir_url + '/cubicweb.reset.css') cubicweb_js_url = datadir_url + '/cubicweb.js' if cubicweb_js_url not in uiprops['JAVASCRIPTS']: uiprops['JAVASCRIPTS'].insert(0, cubicweb_js_url)