equal
deleted
inserted
replaced
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 |
403 def static_file_open(self, rpath, mode='wb'): |
403 def static_file_open(self, rpath, mode='wb'): |
404 staticdir = self.static_directory |
404 staticdir = self.static_directory |
405 rdir, filename = split(rpath) |
405 rdir, filename = split(rpath) |
406 if rdir: |
406 if rdir: |
407 staticdir = join(staticdir, rdir) |
407 staticdir = join(staticdir, rdir) |
408 os.makedirs(staticdir) |
408 if not isdir(staticdir) and 'w' in mode: |
|
409 os.makedirs(staticdir) |
409 return file(join(staticdir, filename), mode) |
410 return file(join(staticdir, filename), mode) |
410 |
411 |
411 def static_file_add(self, rpath, data): |
412 def static_file_add(self, rpath, data): |
412 stream = self.static_file_open(rpath) |
413 stream = self.static_file_open(rpath) |
413 stream.write(data) |
414 stream.write(data) |