[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
--- a/devtools/livetest.py Tue Jul 06 11:45:11 2010 +0200
+++ b/devtools/livetest.py Tue Jul 06 17:11:41 2010 +0200
@@ -55,7 +55,7 @@
"""Indicate which resource to use to process down the URL's path"""
if len(segments) and segments[0] == 'data':
# Anything in data/ is treated as static files
- datadir = self.config.locate_resource(segments[1])
+ datadir = self.config.locate_resource(segments[1])[0]
if datadir:
return static.File(str(datadir), segments[1:])
# Otherwise we use this single resource
--- a/devtools/qunit.py Tue Jul 06 11:45:11 2010 +0200
+++ b/devtools/qunit.py Tue Jul 06 17:11:41 2010 +0200
@@ -132,7 +132,7 @@
# generate html test file
- jquery_dir = 'file://' + self.config.locate_resource('jquery.js')
+ jquery_dir = 'file://' + self.config.locate_resource('jquery.js')[0]
html_test_file = NamedTemporaryFile(suffix='.html')
html_test_file.write(make_qunit_html(test_file, depends,
server_data=(self.test_host, self.test_port),
--- a/etwist/server.py Tue Jul 06 11:45:11 2010 +0200
+++ b/etwist/server.py Tue Jul 06 17:11:41 2010 +0200
@@ -178,7 +178,7 @@
return cls(uiprops['FCKEDITOR_PATH'])
if path == directory: # recurse
return self
- datadir = self.config.locate_resource(path)
+ datadir, path = self.config.locate_resource(path)
if datadir is None:
return self # recurse
self.debug('static file %s from %s', path, datadir)
--- a/web/test/unittest_webconfig.py Tue Jul 06 11:45:11 2010 +0200
+++ b/web/test/unittest_webconfig.py Tue Jul 06 17:11:41 2010 +0200
@@ -41,8 +41,8 @@
def test_locate_resource(self):
self.failUnless('FILE_ICON' in self.config.uiprops)
rname = self.config.uiprops['FILE_ICON'].replace(self.config.datadir_url, '')
- self.failUnless('file' in self.config.locate_resource(rname).split(os.sep))
- cubicwebcsspath = self.config.locate_resource('cubicweb.css').split(os.sep)
+ self.failUnless('file' in self.config.locate_resource(rname)[0].split(os.sep))
+ cubicwebcsspath = self.config.locate_resource('cubicweb.css')[0].split(os.sep)
self.failUnless('web' in cubicwebcsspath or 'shared' in cubicwebcsspath) # 'shared' if tests under apycot
if __name__ == '__main__':
--- a/web/webconfig.py Tue Jul 06 11:45:11 2010 +0200
+++ b/web/webconfig.py Tue Jul 06 17:11:41 2010 +0200
@@ -264,12 +264,14 @@
return user, passwd
def locate_resource(self, rid):
- """return the directory where the given resource may be found"""
+ """return the (directory, filename) where the given resource
+ may be found
+ """
return self._fs_locate(rid, 'data')
def locate_doc_file(self, fname):
"""return the directory where the given resource may be found"""
- return self._fs_locate(fname, 'wdoc')
+ return self._fs_locate(fname, 'wdoc')[0]
@cached
def _fs_path_locate(self, rid, rdirectory):
@@ -280,16 +282,18 @@
return directory
def _fs_locate(self, rid, rdirectory):
- """return the directory where the given resource may be found"""
+ """return the (directory, filename) where the given resource
+ may be found
+ """
directory = self._fs_path_locate(rid, rdirectory)
if directory is None:
- return None
+ return None, None
if rdirectory == 'data' and rid.endswith('.css'):
if self['use-old-css'] and rid == 'cubicweb.css':
# @import('cubicweb.css') in css
- rid == 'cubicweb.old.css'
- return self.uiprops.process_resource(join(directory, rdirectory), rid)
- return join(directory, rdirectory)
+ rid = 'cubicweb.old.css'
+ return self.uiprops.process_resource(join(directory, rdirectory), rid), rid
+ return join(directory, rdirectory), rid
def locate_all_files(self, rid, rdirectory='wdoc'):
"""return all files corresponding to the given resource"""