def updateArticle(self, id, path): u"""Update the article from *id* and *path*. Set the modification time, so we know when the file is updated.""" data = None wiki = self.readWikiFile(path) if wiki is not None: data = self.compileArticle(wiki) data.id = id data.source = wiki data.ranking = TX.asInt(data.ranking) or 0 # Make sure we can sort on the ranking field. data.blogresponse = TX.asBool(data.blogresponse) data.path = path # Keep the source path is case POST needs to save to the file. data.modificationTime = os.path.getmtime(path) # @@@ TODO: Should be DateTime instance. self.cacheArticle(data) return data
def updateArticle(self, id, path): u"""Update the article from *id* and *path*. Set the modification time, so we know when the file is updated.""" data = None wiki = self.readWikiFile(path) if wiki is not None: data = self.compileArticle(wiki) data.id = id data.source = wiki data.ranking = TX.asInt( data.ranking ) or 0 # Make sure we can sort on the ranking field. data.blogresponse = TX.asBool(data.blogresponse) data.path = path # Keep the source path is case POST needs to save to the file. data.modificationTime = os.path.getmtime( path) # @@@ TODO: Should be DateTime instance. self.cacheArticle(data) return data
def getChapterIndex(self, b, articleData): return min(max(0, TX.asInt(b.e.form[self.C.PARAM_CHAPTER]) or 0), len(articleData.items or [])-1)
def getChapterIndex(self, b, articleData): return min(max(0, TX.asInt(b.e.form[self.C.PARAM_CHAPTER]) or 0), len(articleData.chapters or []) - 1)
def getChapterIndex(self, b, article): return min(max(0, TX.asInt(b.e.form[C.PARAM_CHAPTER]) or 0), len(article.items or [])-1)