Fix a bug : post set to non published were not removed during re generation

This commit is contained in:
Gregory Soutade 2014-06-01 11:28:47 +02:00
parent ddf267e9ca
commit 8485fa662e
1 changed files with 15 additions and 6 deletions

View File

@ -184,17 +184,26 @@ class Post(Index):
impl = xml.dom.getDOMImplementation()
for post in posts:
if not post.published: continue
#print 'Generate ' + filename
dom_ = impl.createDocument('', 'xml', None)
dom_.replaceChild(dom.firstChild.cloneNode(True), dom_.firstChild)
nodes = self.parse(src, self.hooks, post, dom_, dom_.firstChild)
filename = output + '/post/'
filename = filename + post.creation_date.strftime("%Y") + '/' + post.creation_date.strftime("%m") + '/'
if not os.path.exists(filename):
os.makedirs(filename)
filename = filename + post.title_slug + '.html'
if not post.published:
if os.path.exists(filename):
from dynastie.search import *
os.unlink(filename)
os.unlink(filename + '.gz')
self.addReport('Remove ' + filename)
s = Search()
s.delete_post(blog, post.id)
continue
#print 'Generate ' + filename
dom_ = impl.createDocument('', 'xml', None)
dom_.replaceChild(dom.firstChild.cloneNode(True), dom_.firstChild)
nodes = self.parse(src, self.hooks, post, dom_, dom_.firstChild)
self.writeIfNotTheSame(filename, nodes)
if not self.somethingWrote: