web/webconfig.py
changeset 8349 fdb796435d7b
parent 8259 1c5be4a1afd1
parent 8341 af813e7d5daa
child 8475 65fecbeb9c3a
equal deleted inserted replaced
8340:622fcca4fe00 8349:fdb796435d7b
    19 
    19 
    20 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    21 _ = unicode
    21 _ = unicode
    22 
    22 
    23 import os
    23 import os
    24 from os.path import join, exists, split
    24 from os.path import join, exists, split, isdir
    25 from warnings import warn
    25 from warnings import warn
    26 
    26 
    27 from logilab.common.decorators import cached
    27 from logilab.common.decorators import cached
    28 from logilab.common.deprecation import deprecated
    28 from logilab.common.deprecation import deprecated
    29 
    29 
   406     def static_file_open(self, rpath, mode='wb'):
   406     def static_file_open(self, rpath, mode='wb'):
   407         staticdir = self.static_directory
   407         staticdir = self.static_directory
   408         rdir, filename = split(rpath)
   408         rdir, filename = split(rpath)
   409         if rdir:
   409         if rdir:
   410             staticdir = join(staticdir, rdir)
   410             staticdir = join(staticdir, rdir)
   411             os.makedirs(staticdir)
   411             if not isdir(staticdir) and 'w' in mode:
       
   412                 os.makedirs(staticdir)
   412         return file(join(staticdir, filename), mode)
   413         return file(join(staticdir, filename), mode)
   413 
   414 
   414     def static_file_add(self, rpath, data):
   415     def static_file_add(self, rpath, data):
   415         stream = self.static_file_open(rpath)
   416         stream = self.static_file_open(rpath)
   416         stream.write(data)
   417         stream.write(data)