- Timestamp:
- 01/30/11 12:14:27 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/mbutscher/work/lib/pwiki/wikidata/WikiDataManager.py
r245 r247 20 20 from .. import ParseUtilities 21 21 from ..StringOps import mbcsDec, re_sub_escape, pathEnc, pathDec, \ 22 unescapeWithRe, strToBool 22 unescapeWithRe, strToBool, pathnameFromUrl, urlFromPathname, \ 23 relativeFilePath 23 24 from ..DocPages import DocPage, WikiPage, FunctionalPage, AliasWikiPage 24 25 # from ..timeView.Versioning import VersionOverview … … 341 342 dataDir = os.path.join(os.path.dirname(wikiConfigFilename), dataDir) 342 343 343 # dataDir = mbcsDec(os.path.abspath(dataDir), "replace")[0]344 344 dataDir = pathDec(os.path.abspath(dataDir)) 345 346 # self.wikiConfigFilename = wikiConfigFilename347 345 348 346 if not dbtype: … … 395 393 self.wikiPageDict = WeakValueDictionary() 396 394 self.funcPageDict = WeakValueDictionary() 397 395 398 396 self.updateExecutor = SingleThreadExecutor(4) 399 397 self.pageRetrievingLock = TimeoutRLock(Consts.DEADBLOCKTIMEOUT) … … 473 471 474 472 self.updateExecutor.start() 475 473 474 if self.isSearchIndexEnabled() and self.getWikiConfig().getint( 475 "main", "indexSearch_formatNo", 1) != Consts.SEARCHINDEX_FORMAT_NO: 476 # Search index rebuild needed 477 # Remove old search index and lower meta data state. 478 # The following pushDirtyMetaDataUpdate() will start rebuilding 479 480 wikiData = self.getWikiData() 481 482 wikiData.commit() 483 finalState = Consts.WIKIWORDMETADATA_STATE_SYNTAXPROCESSED 484 485 for wikiWord in wikiData.getWikiWordsForMetaDataState( 486 finalState, "<"): 487 wikiData.setMetaDataState(wikiWord, finalState) 488 489 wikiData.commit() 490 self.removeSearchIndex() 491 476 492 self.pushDirtyMetaDataUpdate() 477 493 … … 714 730 wikiConfig.setWriteAccessDenied(False) 715 731 wikiConfig.set("main", "wiki_readOnly", "False") 732 733 734 735 def makeRelUrlAbsolute(self, relurl): 736 """ 737 Return the absolute file: URL for a rel: URL 738 """ 739 relpath = pathnameFromUrl(relurl[6:], False) 740 741 url = u"file:" + urlFromPathname( 742 os.path.abspath(os.path.join(os.path.dirname( 743 self.getWikiConfigPath()), relpath))) 744 745 return url 746 747 748 def makeAbsPathRelUrl(self, absPath): 749 """ 750 Return the rel: URL for an absolute file path or None if 751 a relative URL can't be created 752 """ 753 locPath = self.getWikiConfigPath() 754 755 if locPath is None: 756 return None 757 758 locPath = os.path.dirname(locPath) 759 relPath = relativeFilePath(locPath, absPath) 760 if relPath is None: 761 return None 762 763 return u"rel://" + urlFromPathname(relPath) 764 716 765 717 766 … … 924 973 # No active page available 925 974 realWikiWord = self.getUnAliasedWikiWordOrAsIs(wikiWord) 926 # print "--_getWikiPageNoErrorNoCache13", repr((wikiWord, realWikiWord))927 975 if wikiWord == realWikiWord: 928 976 # no alias … … 1607 1655 resultList = s.search(q, limit=None) 1608 1656 1609 # docnumList = [(rd.docnum, rd["unifName"]) for rd in resultList]1610 #1611 # docnumList.sort()1612 # docpp = "\n".join(["%3i %s" % rd for rd in docnumList])1613 #1614 # print "--docResults"1615 # print docpp.encode("mbcs", "replace")1616 1617 1657 result = [rd["unifName"][9:] for rd in resultList 1618 1658 if rd["unifName"].startswith(u"wikipage/")] … … 1663 1703 1664 1704 def removeSearchIndex(self): 1665 if self.isSearchIndexEnabled():1666 raise InternalError("Calling removeSearchIndex() while index is enabled")1705 # if self.isSearchIndexEnabled(): 1706 # raise InternalError("Calling removeSearchIndex() while index is enabled") 1667 1707 1668 1708 p = self.updateExecutor.pause(wait=True) … … 1680 1720 shutil.rmtree(indexPath, ignore_errors=True) 1681 1721 1722 self.getWikiConfig().set("main", "indexSearch_formatNo", u"0") 1723 1682 1724 1683 1725 def getSearchIndex(self, clear=False): … … 1704 1746 1705 1747 self.whooshIndex = whoosh.index.open_dir(indexPath) 1748 1749 self.getWikiConfig().set("main", "indexSearch_formatNo", 1750 unicode(Consts.SEARCHINDEX_FORMAT_NO)) 1706 1751 1707 1752 self.whooshIndex = self.whooshIndex.refresh() 1753 1708 1754 return self.whooshIndex 1709 1755
