Commits

Simone Gasbarroni committed cf32e54

now even file parent folder is deleted when an attachment from an is removed

  • Participants
  • Parent commits 81aac40

Comments (0)

Files changed (2)

File turbopress/controllers/root.py

     @expose()
     def save(self, *args, **kw):
         article = model.provider.get_obj(model.Article, params=dict(uid=kw['uid'],
-                                                                _id=kw['uid']))
+                                                                    _id=kw['uid']))
 
         hooks = config['hooks'].get('turbopress.before_save_article', [])
         for func in hooks:

File turbopress/model/ming/models.py

 import os
 from datetime import datetime
+import shutil
 
 import tg
 from tg.caching import cached_property
 class AttachmentExt(MapperExtension):
     def before_delete(self, instance, state, sess):
         try:
-            os.unlink(instance.content.local_path)
+            shutil.rmtree(os.path.dirname(instance.content.local_path))
         except:
             pass