web/webconfig.py
changeset 5907 5eba1248e12b
parent 5902 c344b3079a2d
child 5933 3d707b8f8a4d
equal deleted inserted replaced
5905:ed66f5a8d48a 5907:5eba1248e12b
   262         if user is not None:
   262         if user is not None:
   263             user = unicode(user)
   263             user = unicode(user)
   264         return user, passwd
   264         return user, passwd
   265 
   265 
   266     def locate_resource(self, rid):
   266     def locate_resource(self, rid):
   267         """return the directory where the given resource may be found"""
   267         """return the (directory, filename) where the given resource
       
   268         may be found
       
   269         """
   268         return self._fs_locate(rid, 'data')
   270         return self._fs_locate(rid, 'data')
   269 
   271 
   270     def locate_doc_file(self, fname):
   272     def locate_doc_file(self, fname):
   271         """return the directory where the given resource may be found"""
   273         """return the directory where the given resource may be found"""
   272         return self._fs_locate(fname, 'wdoc')
   274         return self._fs_locate(fname, 'wdoc')[0]
   273 
   275 
   274     @cached
   276     @cached
   275     def _fs_path_locate(self, rid, rdirectory):
   277     def _fs_path_locate(self, rid, rdirectory):
   276         """return the directory where the given resource may be found"""
   278         """return the directory where the given resource may be found"""
   277         path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())]
   279         path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())]
   278         for directory in path:
   280         for directory in path:
   279             if exists(join(directory, rdirectory, rid)):
   281             if exists(join(directory, rdirectory, rid)):
   280                 return directory
   282                 return directory
   281 
   283 
   282     def _fs_locate(self, rid, rdirectory):
   284     def _fs_locate(self, rid, rdirectory):
   283         """return the directory where the given resource may be found"""
   285         """return the (directory, filename) where the given resource
       
   286         may be found
       
   287         """
   284         directory = self._fs_path_locate(rid, rdirectory)
   288         directory = self._fs_path_locate(rid, rdirectory)
   285         if directory is None:
   289         if directory is None:
   286             return None
   290             return None, None
   287         if rdirectory == 'data' and rid.endswith('.css'):
   291         if rdirectory == 'data' and rid.endswith('.css'):
   288             if self['use-old-css'] and rid == 'cubicweb.css':
   292             if self['use-old-css'] and rid == 'cubicweb.css':
   289                 # @import('cubicweb.css') in css
   293                 # @import('cubicweb.css') in css
   290                 rid == 'cubicweb.old.css'
   294                 rid = 'cubicweb.old.css'
   291             return self.uiprops.process_resource(join(directory, rdirectory), rid)
   295             return self.uiprops.process_resource(join(directory, rdirectory), rid), rid
   292         return join(directory, rdirectory)
   296         return join(directory, rdirectory), rid
   293 
   297 
   294     def locate_all_files(self, rid, rdirectory='wdoc'):
   298     def locate_all_files(self, rid, rdirectory='wdoc'):
   295         """return all files corresponding to the given resource"""
   299         """return all files corresponding to the given resource"""
   296         path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())]
   300         path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())]
   297         for directory in path:
   301         for directory in path: