def updateArticle(doc_id): """ We use when an article is written/modified. It also update index. To use the function we need the muse file for index, the html file for article. >>> ma = MuseArticle('1201170413') >>> #ma.html >>> #updateArticle('1201170413') """ mu = MuseArticle(doc_id) index = mu.json html = mu.html files = mu.files # We have to update the index file both side client and server. # Because some functions of the client side requires index file such # as the function getUnupdatedArticles. That function is used to check # the articles that unpublished. # Client side only need index. The html created from emacs. article = Article() article.set(doc_id) article.updateFromDict(index) articles = Articles() articles.set() articles.updateFromObj(article) articles.save() # Server side need both index and html. updateIndex(doc_id, index) writeArticle(doc_id, html) if files: updateFiles(files)
def getUnupdatedArticles(): """ Returns a list of document id that is not contained in index. >>> getUnupdatedArticles() #doctest: +SKIP """ articles = Articles() articles.set() article_table_updated = articles.json index = Index() article_table_all = index._create() for key in article_table_updated: if article_table_all.has_key(key): article_table_all.pop(key) return article_table_all.keys()