We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Include the main.debug.css
Hi, I'm new to CKAN in my organization and turned debug to true for development and encountered the `AttributeError: 'module' object has no attribute 'css/main.debug.css'` error. It took me a while to figure out that I had to compile the less to get it.

Wouldn't it be easier to include this file so that debug mode automatically works without needing to change anything else?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ckan/lib/app_globals.py`
Content:
```
1 ''' The application's Globals object '''
2 
3 import logging
4 import time
5 from threading import Lock
6 import re
7 
8 from paste.deploy.converters import asbool
9 from pylons import config
10 
11 import ckan
12 import ckan.model as model
13 import ckan.logic as logic
14 
15 
16 log = logging.getLogger(__name__)
17 
18 
19 # mappings translate between config settings and globals because our naming
20 # conventions are not well defined and/or implemented
21 mappings = {
22 #   'config_key': 'globals_key',
23 }
24 
25 
26 # This mapping is only used to define the configuration options (from the
27 # `config` object) that should be copied to the `app_globals` (`g`) object.
28 app_globals_from_config_details = {
29     'ckan.site_title': {},
30     'ckan.site_logo': {},
31     'ckan.site_url': {},
32     'ckan.site_description': {},
33     'ckan.site_about': {},
34     'ckan.site_intro_text': {},
35     'ckan.site_custom_css': {},
36     'ckan.favicon': {}, # default gets set in config.environment.py
37     'ckan.template_head_end': {},
38     'ckan.template_footer_end': {},
39         # has been setup in load_environment():
40     'ckan.site_id': {},
41     'ckan.recaptcha.publickey': {'name': 'recaptcha_publickey'},
42     'ckan.recaptcha.version': {'name': 'recaptcha_version', 'default': '1'},
43     'ckan.template_title_deliminater': {'default': '-'},
44     'ckan.template_head_end': {},
45     'ckan.template_footer_end': {},
46     'ckan.dumps_url': {},
47     'ckan.dumps_format': {},
48     'ofs.impl': {'name': 'ofs_impl'},
49     'ckan.homepage_style': {'default': '1'},
50 
51     # split string
52     'search.facets': {'default': 'organization groups tags res_format license_id',
53                       'type': 'split',
54                       'name': 'facets'},
55     'package_hide_extras': {'type': 'split'},
56     'ckan.plugins': {'type': 'split'},
57 
58     # bool
59     'debug': {'default': 'false', 'type' : 'bool'},
60     'ckan.debug_supress_header' : {'default': 'false', 'type' : 'bool'},
61     'ckan.legacy_templates' : {'default': 'false', 'type' : 'bool'},
62     'ckan.tracking_enabled' : {'default': 'false', 'type' : 'bool'},
63 
64     # int
65     'ckan.datasets_per_page': {'default': '20', 'type': 'int'},
66     'ckan.activity_list_limit': {'default': '30', 'type': 'int'},
67     'search.facets.default': {'default': '10', 'type': 'int',
68                              'name': 'facets_default_number'},
69 }
70 
71 
72 # A place to store the origional config options of we override them
73 _CONFIG_CACHE = {}
74 
75 def set_main_css(css_file):
76     ''' Sets the main_css using debug css if needed.  The css_file
77     must be of the form file.css '''
78     assert css_file.endswith('.css')
79     if config.get('debug') and css_file == '/base/css/main.css':
80         new_css = '/base/css/main.debug.css'
81     else:
82         new_css = css_file
83     # FIXME we should check the css file exists
84     app_globals.main_css = str(new_css)
85 
86 
87 def set_app_global(key, value):
88     '''
89     Set a new key on the app_globals (g) object
90 
91     It will process the value according to the options on
92     app_globals_from_config_details (if any)
93     '''
94     key, value = process_app_global(key, value)
95     setattr(app_globals, key, value)
96 
97 
98 def process_app_global(key, value):
99     '''
100     Tweak a key, value pair meant to be set on the app_globals (g) object
101 
102     According to the options on app_globals_from_config_details (if any)
103     '''
104     options = app_globals_from_config_details.get(key)
105     key = get_globals_key(key)
106     if options:
107         if 'name' in options:
108             key = options['name']
109         value = value or options.get('default', '')
110 
111         data_type = options.get('type')
112         if data_type == 'bool':
113             value = asbool(value)
114         elif data_type == 'int':
115             value = int(value)
116         elif data_type == 'split':
117             value = value.split()
118 
119     return key, value
120 
121 
122 def get_globals_key(key):
123     # create our globals key
124     # these can be specified in mappings or else we remove
125     # the `ckan.` part this is to keep the existing namings
126     # set the value
127     if key in mappings:
128         return mappings[key]
129     elif key.startswith('ckan.'):
130         return key[5:]
131     else:
132         return key
133 
134 
135 def reset():
136     ''' set updatable values from config '''
137     def get_config_value(key, default=''):
138         if model.meta.engine.has_table('system_info'):
139             value = model.get_system_info(key)
140         else:
141             value = None
142         config_value = config.get(key)
143         # sort encodeings if needed
144         if isinstance(config_value, str):
145             try:
146                 config_value = config_value.decode('utf-8')
147             except UnicodeDecodeError:
148                 config_value = config_value.decode('latin-1')
149         # we want to store the config the first time we get here so we can
150         # reset them if needed
151         if key not in _CONFIG_CACHE:
152             _CONFIG_CACHE[key] = config_value
153         if value is not None:
154             log.debug('config `%s` set to `%s` from db' % (key, value))
155         else:
156             value = _CONFIG_CACHE[key]
157             if value:
158                 log.debug('config `%s` set to `%s` from config' % (key, value))
159             else:
160                 value = default
161 
162         set_app_global(key, value)
163 
164         # update the config
165         config[key] = value
166         return value
167 
168     # update the config settings in auto update
169     schema = logic.schema.update_configuration_schema()
170     for key in schema.keys():
171         get_config_value(key)
172 
173     # cusom styling
174     main_css = get_config_value('ckan.main_css', '/base/css/main.css')
175     set_main_css(main_css)
176     # site_url_nice
177     site_url_nice = app_globals.site_url.replace('http://', '')
178     site_url_nice = site_url_nice.replace('www.', '')
179     app_globals.site_url_nice = site_url_nice
180 
181     if app_globals.site_logo:
182         app_globals.header_class = 'header-image'
183     elif not app_globals.site_description:
184         app_globals.header_class = 'header-text-logo'
185     else:
186         app_globals.header_class = 'header-text-logo-tagline'
187 
188 
189 class _Globals(object):
190 
191     ''' Globals acts as a container for objects available throughout the
192     life of the application. '''
193 
194     def __init__(self):
195         '''One instance of Globals is created during application
196         initialization and is available during requests via the
197         'app_globals' variable
198         '''
199         self._init()
200         self._config_update = None
201         self._mutex = Lock()
202 
203     def _check_uptodate(self):
204         ''' check the config is uptodate needed when several instances are
205         running '''
206         value = model.get_system_info('ckan.config_update')
207         if self._config_update != value:
208             if self._mutex.acquire(False):
209                 reset()
210                 self._config_update = value
211                 self._mutex.release()
212 
213     def _init(self):
214 
215         self.ckan_version = ckan.__version__
216         self.ckan_base_version = re.sub('[^0-9\.]', '', self.ckan_version)
217         if self.ckan_base_version == self.ckan_version:
218             self.ckan_doc_version = 'ckan-{0}'.format(self.ckan_version)
219         else:
220             self.ckan_doc_version = 'latest'
221 
222         # process the config details to set globals
223         for key in app_globals_from_config_details.keys():
224             new_key, value = process_app_global(key, config.get(key) or '')
225             setattr(self, new_key, value)
226 
227 
228 app_globals = _Globals()
229 del _Globals
230
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/ckan/lib/app_globals.py b/ckan/lib/app_globals.py
--- a/ckan/lib/app_globals.py
+++ b/ckan/lib/app_globals.py
@@ -73,13 +73,9 @@
 _CONFIG_CACHE = {}
 
 def set_main_css(css_file):
-    ''' Sets the main_css using debug css if needed.  The css_file
-    must be of the form file.css '''
+    ''' Sets the main_css.  The css_file must be of the form file.css '''
     assert css_file.endswith('.css')
-    if config.get('debug') and css_file == '/base/css/main.css':
-        new_css = '/base/css/main.debug.css'
-    else:
-        new_css = css_file
+    new_css = css_file
     # FIXME we should check the css file exists
     app_globals.main_css = str(new_css)

{"golden_diff": "diff --git a/ckan/lib/app_globals.py b/ckan/lib/app_globals.py\n--- a/ckan/lib/app_globals.py\n+++ b/ckan/lib/app_globals.py\n@@ -73,13 +73,9 @@\n _CONFIG_CACHE = {}\n \n def set_main_css(css_file):\n-    ''' Sets the main_css using debug css if needed.  The css_file\n-    must be of the form file.css '''\n+    ''' Sets the main_css.  The css_file must be of the form file.css '''\n     assert css_file.endswith('.css')\n-    if config.get('debug') and css_file == '/base/css/main.css':\n-        new_css = '/base/css/main.debug.css'\n-    else:\n-        new_css = css_file\n+    new_css = css_file\n     # FIXME we should check the css file exists\n     app_globals.main_css = str(new_css)\n", "issue": "Include the main.debug.css\nHi, I'm new to CKAN in my organization and turned debug to true for development and encountered the `AttributeError: 'module' object has no attribute 'css/main.debug.css'` error. It took me a while to figure out that I had to compile the less to get it.\n\nWouldn't it be easier to include this file so that debug mode automatically works without needing to change anything else?\n\n", "before_files": [{"content": "''' The application's Globals object '''\n\nimport logging\nimport time\nfrom threading import Lock\nimport re\n\nfrom paste.deploy.converters import asbool\nfrom pylons import config\n\nimport ckan\nimport ckan.model as model\nimport ckan.logic as logic\n\n\nlog = logging.getLogger(__name__)\n\n\n# mappings translate between config settings and globals because our naming\n# conventions are not well defined and/or implemented\nmappings = {\n#   'config_key': 'globals_key',\n}\n\n\n# This mapping is only used to define the configuration options (from the\n# `config` object) that should be copied to the `app_globals` (`g`) object.\napp_globals_from_config_details = {\n    'ckan.site_title': {},\n    'ckan.site_logo': {},\n    'ckan.site_url': {},\n    'ckan.site_description': {},\n    'ckan.site_about': {},\n    'ckan.site_intro_text': {},\n    'ckan.site_custom_css': {},\n    'ckan.favicon': {}, # default gets set in config.environment.py\n    'ckan.template_head_end': {},\n    'ckan.template_footer_end': {},\n        # has been setup in load_environment():\n    'ckan.site_id': {},\n    'ckan.recaptcha.publickey': {'name': 'recaptcha_publickey'},\n    'ckan.recaptcha.version': {'name': 'recaptcha_version', 'default': '1'},\n    'ckan.template_title_deliminater': {'default': '-'},\n    'ckan.template_head_end': {},\n    'ckan.template_footer_end': {},\n    'ckan.dumps_url': {},\n    'ckan.dumps_format': {},\n    'ofs.impl': {'name': 'ofs_impl'},\n    'ckan.homepage_style': {'default': '1'},\n\n    # split string\n    'search.facets': {'default': 'organization groups tags res_format license_id',\n                      'type': 'split',\n                      'name': 'facets'},\n    'package_hide_extras': {'type': 'split'},\n    'ckan.plugins': {'type': 'split'},\n\n    # bool\n    'debug': {'default': 'false', 'type' : 'bool'},\n    'ckan.debug_supress_header' : {'default': 'false', 'type' : 'bool'},\n    'ckan.legacy_templates' : {'default': 'false', 'type' : 'bool'},\n    'ckan.tracking_enabled' : {'default': 'false', 'type' : 'bool'},\n\n    # int\n    'ckan.datasets_per_page': {'default': '20', 'type': 'int'},\n    'ckan.activity_list_limit': {'default': '30', 'type': 'int'},\n    'search.facets.default': {'default': '10', 'type': 'int',\n                             'name': 'facets_default_number'},\n}\n\n\n# A place to store the origional config options of we override them\n_CONFIG_CACHE = {}\n\ndef set_main_css(css_file):\n    ''' Sets the main_css using debug css if needed.  The css_file\n    must be of the form file.css '''\n    assert css_file.endswith('.css')\n    if config.get('debug') and css_file == '/base/css/main.css':\n        new_css = '/base/css/main.debug.css'\n    else:\n        new_css = css_file\n    # FIXME we should check the css file exists\n    app_globals.main_css = str(new_css)\n\n\ndef set_app_global(key, value):\n    '''\n    Set a new key on the app_globals (g) object\n\n    It will process the value according to the options on\n    app_globals_from_config_details (if any)\n    '''\n    key, value = process_app_global(key, value)\n    setattr(app_globals, key, value)\n\n\ndef process_app_global(key, value):\n    '''\n    Tweak a key, value pair meant to be set on the app_globals (g) object\n\n    According to the options on app_globals_from_config_details (if any)\n    '''\n    options = app_globals_from_config_details.get(key)\n    key = get_globals_key(key)\n    if options:\n        if 'name' in options:\n            key = options['name']\n        value = value or options.get('default', '')\n\n        data_type = options.get('type')\n        if data_type == 'bool':\n            value = asbool(value)\n        elif data_type == 'int':\n            value = int(value)\n        elif data_type == 'split':\n            value = value.split()\n\n    return key, value\n\n\ndef get_globals_key(key):\n    # create our globals key\n    # these can be specified in mappings or else we remove\n    # the `ckan.` part this is to keep the existing namings\n    # set the value\n    if key in mappings:\n        return mappings[key]\n    elif key.startswith('ckan.'):\n        return key[5:]\n    else:\n        return key\n\n\ndef reset():\n    ''' set updatable values from config '''\n    def get_config_value(key, default=''):\n        if model.meta.engine.has_table('system_info'):\n            value = model.get_system_info(key)\n        else:\n            value = None\n        config_value = config.get(key)\n        # sort encodeings if needed\n        if isinstance(config_value, str):\n            try:\n                config_value = config_value.decode('utf-8')\n            except UnicodeDecodeError:\n                config_value = config_value.decode('latin-1')\n        # we want to store the config the first time we get here so we can\n        # reset them if needed\n        if key not in _CONFIG_CACHE:\n            _CONFIG_CACHE[key] = config_value\n        if value is not None:\n            log.debug('config `%s` set to `%s` from db' % (key, value))\n        else:\n            value = _CONFIG_CACHE[key]\n            if value:\n                log.debug('config `%s` set to `%s` from config' % (key, value))\n            else:\n                value = default\n\n        set_app_global(key, value)\n\n        # update the config\n        config[key] = value\n        return value\n\n    # update the config settings in auto update\n    schema = logic.schema.update_configuration_schema()\n    for key in schema.keys():\n        get_config_value(key)\n\n    # cusom styling\n    main_css = get_config_value('ckan.main_css', '/base/css/main.css')\n    set_main_css(main_css)\n    # site_url_nice\n    site_url_nice = app_globals.site_url.replace('http://', '')\n    site_url_nice = site_url_nice.replace('www.', '')\n    app_globals.site_url_nice = site_url_nice\n\n    if app_globals.site_logo:\n        app_globals.header_class = 'header-image'\n    elif not app_globals.site_description:\n        app_globals.header_class = 'header-text-logo'\n    else:\n        app_globals.header_class = 'header-text-logo-tagline'\n\n\nclass _Globals(object):\n\n    ''' Globals acts as a container for objects available throughout the\n    life of the application. '''\n\n    def __init__(self):\n        '''One instance of Globals is created during application\n        initialization and is available during requests via the\n        'app_globals' variable\n        '''\n        self._init()\n        self._config_update = None\n        self._mutex = Lock()\n\n    def _check_uptodate(self):\n        ''' check the config is uptodate needed when several instances are\n        running '''\n        value = model.get_system_info('ckan.config_update')\n        if self._config_update != value:\n            if self._mutex.acquire(False):\n                reset()\n                self._config_update = value\n                self._mutex.release()\n\n    def _init(self):\n\n        self.ckan_version = ckan.__version__\n        self.ckan_base_version = re.sub('[^0-9\\.]', '', self.ckan_version)\n        if self.ckan_base_version == self.ckan_version:\n            self.ckan_doc_version = 'ckan-{0}'.format(self.ckan_version)\n        else:\n            self.ckan_doc_version = 'latest'\n\n        # process the config details to set globals\n        for key in app_globals_from_config_details.keys():\n            new_key, value = process_app_global(key, config.get(key) or '')\n            setattr(self, new_key, value)\n\n\napp_globals = _Globals()\ndel _Globals\n", "path": "ckan/lib/app_globals.py"}], "after_files": [{"content": "''' The application's Globals object '''\n\nimport logging\nimport time\nfrom threading import Lock\nimport re\n\nfrom paste.deploy.converters import asbool\nfrom pylons import config\n\nimport ckan\nimport ckan.model as model\nimport ckan.logic as logic\n\n\nlog = logging.getLogger(__name__)\n\n\n# mappings translate between config settings and globals because our naming\n# conventions are not well defined and/or implemented\nmappings = {\n#   'config_key': 'globals_key',\n}\n\n\n# This mapping is only used to define the configuration options (from the\n# `config` object) that should be copied to the `app_globals` (`g`) object.\napp_globals_from_config_details = {\n    'ckan.site_title': {},\n    'ckan.site_logo': {},\n    'ckan.site_url': {},\n    'ckan.site_description': {},\n    'ckan.site_about': {},\n    'ckan.site_intro_text': {},\n    'ckan.site_custom_css': {},\n    'ckan.favicon': {}, # default gets set in config.environment.py\n    'ckan.template_head_end': {},\n    'ckan.template_footer_end': {},\n        # has been setup in load_environment():\n    'ckan.site_id': {},\n    'ckan.recaptcha.publickey': {'name': 'recaptcha_publickey'},\n    'ckan.recaptcha.version': {'name': 'recaptcha_version', 'default': '1'},\n    'ckan.template_title_deliminater': {'default': '-'},\n    'ckan.template_head_end': {},\n    'ckan.template_footer_end': {},\n    'ckan.dumps_url': {},\n    'ckan.dumps_format': {},\n    'ofs.impl': {'name': 'ofs_impl'},\n    'ckan.homepage_style': {'default': '1'},\n\n    # split string\n    'search.facets': {'default': 'organization groups tags res_format license_id',\n                      'type': 'split',\n                      'name': 'facets'},\n    'package_hide_extras': {'type': 'split'},\n    'ckan.plugins': {'type': 'split'},\n\n    # bool\n    'debug': {'default': 'false', 'type' : 'bool'},\n    'ckan.debug_supress_header' : {'default': 'false', 'type' : 'bool'},\n    'ckan.legacy_templates' : {'default': 'false', 'type' : 'bool'},\n    'ckan.tracking_enabled' : {'default': 'false', 'type' : 'bool'},\n\n    # int\n    'ckan.datasets_per_page': {'default': '20', 'type': 'int'},\n    'ckan.activity_list_limit': {'default': '30', 'type': 'int'},\n    'search.facets.default': {'default': '10', 'type': 'int',\n                             'name': 'facets_default_number'},\n}\n\n\n# A place to store the origional config options of we override them\n_CONFIG_CACHE = {}\n\ndef set_main_css(css_file):\n    ''' Sets the main_css.  The css_file must be of the form file.css '''\n    assert css_file.endswith('.css')\n    new_css = css_file\n    # FIXME we should check the css file exists\n    app_globals.main_css = str(new_css)\n\n\ndef set_app_global(key, value):\n    '''\n    Set a new key on the app_globals (g) object\n\n    It will process the value according to the options on\n    app_globals_from_config_details (if any)\n    '''\n    key, value = process_app_global(key, value)\n    setattr(app_globals, key, value)\n\n\ndef process_app_global(key, value):\n    '''\n    Tweak a key, value pair meant to be set on the app_globals (g) object\n\n    According to the options on app_globals_from_config_details (if any)\n    '''\n    options = app_globals_from_config_details.get(key)\n    key = get_globals_key(key)\n    if options:\n        if 'name' in options:\n            key = options['name']\n        value = value or options.get('default', '')\n\n        data_type = options.get('type')\n        if data_type == 'bool':\n            value = asbool(value)\n        elif data_type == 'int':\n            value = int(value)\n        elif data_type == 'split':\n            value = value.split()\n\n    return key, value\n\n\ndef get_globals_key(key):\n    # create our globals key\n    # these can be specified in mappings or else we remove\n    # the `ckan.` part this is to keep the existing namings\n    # set the value\n    if key in mappings:\n        return mappings[key]\n    elif key.startswith('ckan.'):\n        return key[5:]\n    else:\n        return key\n\n\ndef reset():\n    ''' set updatable values from config '''\n    def get_config_value(key, default=''):\n        if model.meta.engine.has_table('system_info'):\n            value = model.get_system_info(key)\n        else:\n            value = None\n        config_value = config.get(key)\n        # sort encodeings if needed\n        if isinstance(config_value, str):\n            try:\n                config_value = config_value.decode('utf-8')\n            except UnicodeDecodeError:\n                config_value = config_value.decode('latin-1')\n        # we want to store the config the first time we get here so we can\n        # reset them if needed\n        if key not in _CONFIG_CACHE:\n            _CONFIG_CACHE[key] = config_value\n        if value is not None:\n            log.debug('config `%s` set to `%s` from db' % (key, value))\n        else:\n            value = _CONFIG_CACHE[key]\n            if value:\n                log.debug('config `%s` set to `%s` from config' % (key, value))\n            else:\n                value = default\n\n        set_app_global(key, value)\n\n        # update the config\n        config[key] = value\n        return value\n\n    # update the config settings in auto update\n    schema = logic.schema.update_configuration_schema()\n    for key in schema.keys():\n        get_config_value(key)\n\n    # cusom styling\n    main_css = get_config_value('ckan.main_css', '/base/css/main.css')\n    set_main_css(main_css)\n    # site_url_nice\n    site_url_nice = app_globals.site_url.replace('http://', '')\n    site_url_nice = site_url_nice.replace('www.', '')\n    app_globals.site_url_nice = site_url_nice\n\n    if app_globals.site_logo:\n        app_globals.header_class = 'header-image'\n    elif not app_globals.site_description:\n        app_globals.header_class = 'header-text-logo'\n    else:\n        app_globals.header_class = 'header-text-logo-tagline'\n\n\nclass _Globals(object):\n\n    ''' Globals acts as a container for objects available throughout the\n    life of the application. '''\n\n    def __init__(self):\n        '''One instance of Globals is created during application\n        initialization and is available during requests via the\n        'app_globals' variable\n        '''\n        self._init()\n        self._config_update = None\n        self._mutex = Lock()\n\n    def _check_uptodate(self):\n        ''' check the config is uptodate needed when several instances are\n        running '''\n        value = model.get_system_info('ckan.config_update')\n        if self._config_update != value:\n            if self._mutex.acquire(False):\n                reset()\n                self._config_update = value\n                self._mutex.release()\n\n    def _init(self):\n\n        self.ckan_version = ckan.__version__\n        self.ckan_base_version = re.sub('[^0-9\\.]', '', self.ckan_version)\n        if self.ckan_base_version == self.ckan_version:\n            self.ckan_doc_version = 'ckan-{0}'.format(self.ckan_version)\n        else:\n            self.ckan_doc_version = 'latest'\n\n        # process the config details to set globals\n        for key in app_globals_from_config_details.keys():\n            new_key, value = process_app_global(key, config.get(key) or '')\n            setattr(self, new_key, value)\n\n\napp_globals = _Globals()\ndel _Globals\n", "path": "ckan/lib/app_globals.py"}]}