Changeset 2048
- Timestamp:
- 06/18/09 13:38:51 (9 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/apps/pylucid/models.py
r2040 r2048 21 21 22 22 import os 23 import errno 23 24 import warnings 24 25 import posixpath … … 517 518 518 519 def save_cache_file(self): 519 """ Try to cache the head file into filesystem (Only worked, if python process has write rights) """ 520 """ 521 Try to cache the head file into filesystem (Only worked, if python process has write rights) 522 Try to create the out path, if it's not exist. 523 """ 520 524 cachepath = self.get_cachepath() 525 526 def _save_cache_file(auto_create_dir=True): 527 try: 528 f = file(cachepath, "w") 529 f.write(self.content) 530 f.close() 531 except IOError, err: 532 if auto_create_dir and err.errno == errno.ENOENT: # No 2: No such file or directory 533 # Try to create the out dir and save the cache file 534 path = os.path.dirname(cachepath) 535 if not os.path.isdir(path): 536 # Try to create cache path and save file 537 os.makedirs(path) 538 user_message_or_warn("Cache path %s created" % path) 539 _save_cache_file(auto_create_dir=False) 540 return 541 raise 542 521 543 try: 522 f = file(cachepath, "w") 523 f.write(self.content) 524 f.close() 525 except Exception, err: 544 _save_cache_file() 545 except IOError, err: 526 546 user_message_or_warn("Can't cache EditableHtmlHeadFile into %r: %s" % (cachepath, err)) 527 547 else: