Changeset 252
- Timestamp:
- 03/15/11 13:26:45 (2 years ago)
- Location:
- branches/mbutscher/work
- Files:
-
- 8 modified
-
Consts.py (modified) (2 diffs)
-
extensions/Presentation.py (modified) (3 diffs)
-
lib/pwiki/WikiTxtCtrl.py (modified) (126 diffs)
-
lib/pwiki/wikidata/compact_sqlite/DbStructure.py (modified) (1 diff)
-
lib/pwiki/wikidata/compact_sqlite/WikiData.py (modified) (15 diffs)
-
lib/pwiki/wikidata/original_gadfly/WikiData.py (modified) (6 diffs)
-
lib/pwiki/wikidata/original_sqlite/DbStructure.py (modified) (2 diffs)
-
lib/pwiki/wikidata/original_sqlite/WikiData.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/mbutscher/work/Consts.py
r251 r252 5 5 # where branch is normally string "wikidPad", but should be changed if somebody 6 6 # develops a derived version of WikidPad. 7 # 7 # 8 8 # major and minor are the main versions, 9 9 # stateAndMicro is: 10 # between 0 and 99 for "alpha" 10 # between 0 and 99 for "alpha" 11 11 # between 100 and 199 for "beta" 12 12 # between 200 and 299 for "rc" (release candidate) 13 13 # 300 for "final" 14 # 14 # 15 15 # the unit and tenth place form the micro version. 16 # 16 # 17 17 # patch is a sub-micro version, if needed, normally 0. 18 # 18 # 19 19 # Examples: 20 20 # (1, 8, 207, 0) is 1.8rc07 … … 40 40 FormatTypes = Enumeration("FormatTypes", ["Default", "WikiWord", 41 41 "AvailWikiWord", "Bold", "Italic", "Heading1", "Heading2", "Heading3", 42 "Heading4", " Url", "Script", "Attribute", "ToDo"42 "Heading4", "Heading5", "Url", "Script", "Attribute", "ToDo" 43 43 ], 0) 44 44 45 45 46 46 # Store hints for WikiData.storeDataBlock() -
branches/mbutscher/work/extensions/Presentation.py
r213 r252 12 12 'other': 'Comic Sans MS', 13 13 'size' : 10, 14 'heading5': 9, 14 15 'heading4': 10, 15 16 'heading3': 11, … … 23 24 'other': 'new century schoolbook', 24 25 'size' : 10, 26 'heading5': 9, 25 27 'heading4': 10, 26 28 'heading3': 11, … … 63 65 "fore:%(colPlaintext)s,face:%(mono)s,size:%(size)d" % styleFaces), 64 66 (FormatTypes.WikiWord, 65 "fore:%(colPlaintext)s,underline,face:%(mono)s,size:%(size)d" % styleFaces), 67 "fore:%(colPlaintext)s,underline,face:%(mono)s,size:%(size)d" % styleFaces), 66 68 (FormatTypes.AvailWikiWord, 67 "fore:%(colLink)s,underline,face:%(mono)s,size:%(size)d" % styleFaces), 68 (FormatTypes.Bold, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(size)d" % styleFaces), 69 (FormatTypes.Italic, "fore:%(colPlaintext)s,italic,face:%(mono)s,size:%(size)d" % styleFaces), 70 (FormatTypes.Heading4, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading4)d" % styleFaces), 71 (FormatTypes.Heading3, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading3)d" % styleFaces), 72 (FormatTypes.Heading2, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading2)d" % styleFaces), 73 (FormatTypes.Heading1, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading1)d" % styleFaces), 69 "fore:%(colLink)s,underline,face:%(mono)s,size:%(size)d" % styleFaces), 70 (FormatTypes.Bold, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(size)d" % styleFaces), 71 (FormatTypes.Italic, "fore:%(colPlaintext)s,italic,face:%(mono)s,size:%(size)d" % styleFaces), 72 (FormatTypes.Heading5, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading5)d" % styleFaces), 73 (FormatTypes.Heading4, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading4)d" % styleFaces), 74 (FormatTypes.Heading3, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading3)d" % styleFaces), 75 (FormatTypes.Heading2, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading2)d" % styleFaces), 76 (FormatTypes.Heading1, "fore:%(colPlaintext)s,bold,face:%(mono)s,size:%(heading1)d" % styleFaces), 74 77 (FormatTypes.Url, 75 "fore:%(colLink)s,underline,face:%(mono)s,size:%(size)d" % styleFaces), 78 "fore:%(colLink)s,underline,face:%(mono)s,size:%(size)d" % styleFaces), 76 79 (FormatTypes.Script, 77 80 "fore:%(colAttribute)s,face:%(mono)s,size:%(size)d" % styleFaces), -
branches/mbutscher/work/lib/pwiki/WikiTxtCtrl.py
r249 r252 89 89 # etEVT_STYLE_DONE_COMMAND = wx.NewEventType() 90 90 # EVT_STYLE_DONE_COMMAND = wx.PyEventBinder(etEVT_STYLE_DONE_COMMAND, 0) 91 # 91 # 92 92 # class StyleDoneEvent(wx.PyCommandEvent): 93 93 # """ … … 175 175 self.SetMarginWidth(self.SELECT_MARGIN, 16) 176 176 self.SetMarginWidth(self.NUMBER_MARGIN, 0) 177 177 178 178 self.SetMarginType(self.FOLD_MARGIN, wx.stc.STC_MARGIN_SYMBOL) 179 179 self.SetMarginType(self.SELECT_MARGIN, wx.stc.STC_MARGIN_SYMBOL) … … 201 201 # i plan on lexing myself 202 202 self.SetLexer(wx.stc.STC_LEX_CONTAINER) 203 203 204 204 # make the text control a drop target for files and text 205 205 self.SetDropTarget(WikiTxtCtrlDropTarget(self)) 206 206 207 207 # self.CmdKeyClearAll() 208 # 208 # 209 209 # # register some keyboard commands 210 210 # self.CmdKeyAssign(ord('+'), wx.stc.STC_SCMOD_CTRL, wx.stc.STC_CMD_ZOOMIN) … … 216 216 # self.CmdKeyAssign(wx.stc.STC_KEY_END, wx.stc.STC_SCMOD_SHIFT, 217 217 # wx.stc.STC_CMD_LINEENDWRAPEXTEND) 218 # 219 # 218 # 219 # 220 220 # # Clear all key mappings for clipboard operations 221 221 # # PersonalWikiFrame handles them and calls the special clipboard functions … … 224 224 # self.CmdKeyClear(wx.stc.STC_KEY_INSERT, wx.stc.STC_SCMOD_SHIFT) 225 225 # self.CmdKeyClear(wx.stc.STC_KEY_DELETE, wx.stc.STC_SCMOD_SHIFT) 226 # 226 # 227 227 # self.CmdKeyClear(ord('X'), wx.stc.STC_SCMOD_CTRL) 228 228 # self.CmdKeyClear(ord('C'), wx.stc.STC_SCMOD_CTRL) … … 246 246 ("options changed", self.onOptionsChanged), 247 247 ), wx.GetApp().getMiscEvent(), self) 248 248 249 249 self.__sinkGlobalConfig = wxKeyFunctionSink(( 250 250 ("changed configuration", self.onChangedConfiguration), … … 280 280 wx.stc.EVT_STC_DWELLSTART(self, ID, self.OnDwellStart) 281 281 wx.stc.EVT_STC_DWELLEND(self, ID, self.OnDwellEnd) 282 282 283 283 wx.EVT_LEFT_DOWN(self, self.OnClick) 284 284 wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown) … … 292 292 293 293 wx.EVT_CONTEXT_MENU(self, self.OnContextMenu) 294 294 295 295 # self.incSearchCharStartPos = 0 296 296 self.incSearchPreviousHiddenLines = None … … 309 309 self.contextMenuTokens = None 310 310 self.contextMenuSpellCheckSuggestions = None 311 311 312 312 # Connect context menu events to functions 313 313 wx.EVT_MENU(self, GUI_ID.CMD_UNDO, lambda evt: self.Undo()) … … 330 330 331 331 wx.EVT_MENU(self, GUI_ID.CMD_ADD_THIS_SPELLING_SESSION, 332 self.OnAddThisSpellingToIgnoreSession) 332 self.OnAddThisSpellingToIgnoreSession) 333 333 wx.EVT_MENU(self, GUI_ID.CMD_ADD_THIS_SPELLING_GLOBAL, 334 self.OnAddThisSpellingToIgnoreGlobal) 334 self.OnAddThisSpellingToIgnoreGlobal) 335 335 wx.EVT_MENU(self, GUI_ID.CMD_ADD_THIS_SPELLING_LOCAL, 336 self.OnAddThisSpellingToIgnoreLocal) 337 338 wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_THIS, self.OnActivateThis) 336 self.OnAddThisSpellingToIgnoreLocal) 337 338 wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_THIS, self.OnActivateThis) 339 339 wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_NEW_TAB_THIS, 340 self.OnActivateNewTabThis) 340 self.OnActivateNewTabThis) 341 341 wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_NEW_TAB_BACKGROUND_THIS, 342 342 self.OnActivateNewTabBackgroundThis) … … 385 385 return 386 386 387 cbIcept = self.presenter.getMainControl().getClipboardInterceptor() 387 cbIcept = self.presenter.getMainControl().getClipboardInterceptor() 388 388 if cbIcept is not None: 389 389 cbIcept.informCopyInWikidPadStart(text=text) … … 406 406 if filenames is not None: 407 407 mc = self.presenter.getMainControl() 408 408 409 409 paramDict = {"editor": self, "filenames": filenames, 410 410 "x": -1, "y": -1, "main control": mc, … … 425 425 img = bmp.ConvertToImage() 426 426 del bmp 427 427 428 428 if self.presenter.getConfig().getboolean("main", 429 429 "editor_imagePaste_askOnEachPaste", True): … … 441 441 # Couldn't find unused filename or saving denied 442 442 return True 443 443 444 444 # destPath = fs.findDestPathNoSource(u".png", u"") 445 # 445 # 446 446 # print "Paste6", repr(destPath) 447 447 # if destPath is None: 448 448 # # Couldn't find unused filename 449 449 # return 450 # 450 # 451 451 # img.SaveFile(destPath, wx.BITMAP_TYPE_PNG) 452 452 453 453 url = self.presenter.getMainControl().makeAbsPathRelUrl(destPath) 454 454 455 455 if url is None: 456 456 url = u"file:" + StringOps.urlFromPathname(destPath) 457 457 458 458 self.ReplaceSelection(url) 459 459 460 460 # locPath = self.presenter.getMainControl().getWikiConfigPath() 461 # 461 # 462 462 # if locPath is not None: 463 463 # locPath = dirname(locPath) … … 469 469 # else: 470 470 # url = "rel://%s" % urlFromPathname(relPath) 471 # 471 # 472 472 # if url: 473 473 # self.ReplaceSelection(url) 474 474 475 475 return True 476 476 477 477 if not WindowsHacks: 478 478 return False … … 482 482 if destPath is not None: 483 483 url = self.presenter.getMainControl().makeAbsPathRelUrl(destPath) 484 484 485 485 if url is None: 486 486 url = u"file:" + StringOps.urlFromPathname(destPath) 487 487 488 488 self.ReplaceSelection(url) 489 489 return True … … 492 492 # if destPath is not None: 493 493 # locPath = self.presenter.getMainControl().getWikiConfigPath() 494 # 494 # 495 495 # if locPath is not None: 496 496 # locPath = dirname(locPath) … … 502 502 # else: 503 503 # url = "rel://%s>i" % urlFromPathname(relPath) 504 # 504 # 505 505 # if url: 506 506 # self.ReplaceSelection(url) … … 514 514 self.Copy() 515 515 516 517 516 517 518 518 def setLayerVisible(self, vis, scName=""): 519 519 """ … … 535 535 def setAutoIndent(self, onOff): 536 536 self.autoIndent = onOff 537 537 538 538 def getAutoIndent(self): 539 539 return self.autoIndent … … 541 541 def setAutoBullets(self, onOff): 542 542 self.autoBullets = onOff 543 543 544 544 def getAutoBullets(self): 545 545 return self.autoBullets 546 546 547 547 def setTabsToSpaces(self, onOff): 548 548 self.tabsToSpaces = onOff 549 549 self.SetUseTabs(not onOff) 550 550 551 551 def getTabsToSpaces(self): 552 552 return self.tabsToSpaces … … 569 569 forceSync -- when setting folding on, the folding is completed 570 570 before function returns iff forceSync is True 571 """ 571 """ 572 572 if onOrOff: 573 573 self.SetMarginWidth(self.FOLD_MARGIN, 16) … … 648 648 self.SetTargetStart(bs) 649 649 self.SetTargetEnd(be) 650 650 651 651 if isUnicode(): 652 652 self.ReplaceTarget(newText) … … 656 656 # text = self.GetText() 657 657 # text = text[:pos] + newText + text[(pos + len):] 658 # 658 # 659 659 # self.replaceText(text) 660 660 … … 662 662 def showSelectionByCharPos(self, start, end): 663 663 """ 664 Same as SetSelectionByCharPos(), but scrolls to position correctly 664 Same as SetSelectionByCharPos(), but scrolls to position correctly 665 665 """ 666 666 text = self.GetText() … … 691 691 692 692 self.AutoCompSetFillUps(u":=") # TODO Add '.'? 693 # self.SetYCaretPolicy(wxSTC_CARET_SLOP, 2) 694 # self.SetYCaretPolicy(wxSTC_CARET_JUMPS | wxSTC_CARET_EVEN, 4) 695 self.SetYCaretPolicy(wx.stc.STC_CARET_SLOP | wx.stc.STC_CARET_EVEN, 4) 693 # self.SetYCaretPolicy(wxSTC_CARET_SLOP, 2) 694 # self.SetYCaretPolicy(wxSTC_CARET_JUMPS | wxSTC_CARET_EVEN, 4) 695 self.SetYCaretPolicy(wx.stc.STC_CARET_SLOP | wx.stc.STC_CARET_EVEN, 4) 696 696 697 697 … … 739 739 740 740 self.wikiPageSink.disconnect() 741 741 742 742 self.presenter.setDocPage(None) 743 743 … … 747 747 # self.pageAst = None 748 748 self.pageType = "normal" 749 749 750 750 ## _prof.stop() 751 751 … … 756 756 content = None 757 757 wikiDataManager = self.presenter.getWikiDocument() 758 758 759 759 self.presenter.setDocPage(funcPage) 760 760 761 761 if self.getLoadedDocPage() is None: 762 762 return # TODO How to handle? … … 898 898 self.setFoldInfo(foldInfo) 899 899 self.GotoPos(lastPos) 900 900 901 901 self.scrollXY(scrollPosX, scrollPosY) 902 902 903 903 # # Bad hack: First scroll to position to avoid a visible jump 904 904 # # if scrolling works, then update display, 905 905 # # then scroll again because it may have failed the first time 906 # 906 # 907 907 # self.SetScrollPos(wx.HORIZONTAL, scrollPosX, False) 908 908 # screvt = wx.ScrollWinEvent(wx.wxEVT_SCROLLWIN_THUMBTRACK, … … 912 912 # scrollPosX, wx.HORIZONTAL) 913 913 # self.ProcessEvent(screvt) 914 # 914 # 915 915 # self.SetScrollPos(wx.VERTICAL, scrollPosY, True) 916 916 # screvt = wx.ScrollWinEvent(wx.wxEVT_SCROLLWIN_THUMBTRACK, … … 920 920 # scrollPosY, wx.VERTICAL) 921 921 # self.ProcessEvent(screvt) 922 # 922 # 923 923 # self.Update() 924 # 924 # 925 925 # self.SetScrollPos(wx.HORIZONTAL, scrollPosX, False) 926 926 # screvt = wx.ScrollWinEvent(wx.wxEVT_SCROLLWIN_THUMBTRACK, … … 930 930 # scrollPosX, wx.HORIZONTAL) 931 931 # self.ProcessEvent(screvt) 932 # 932 # 933 933 # self.SetScrollPos(wx.VERTICAL, scrollPosY, True) 934 934 # screvt = wx.ScrollWinEvent(wx.wxEVT_SCROLLWIN_THUMBTRACK, … … 955 955 self._goToNextFormField() 956 956 return True 957 957 958 958 return False 959 959 … … 994 994 wx.GetApp().freeWikiLanguageHelper(self.wikiLanguageHelper) 995 995 self.wikiLanguageHelper = docPage.createWikiLanguageHelper() 996 996 997 997 if self.pageType == u"normal": 998 998 # Scroll page according to the anchor … … 1039 1039 faces = self.presenter.getDefaultFontFaces().copy() 1040 1040 1041 if isinstance(self.getLoadedDocPage(), 1041 if isinstance(self.getLoadedDocPage(), 1042 1042 (DocPages.WikiPage, DocPages.AliasWikiPage)): 1043 1043 … … 1124 1124 Called directly from a doc page to repair the editor state if an 1125 1125 invalid file signature was detected. 1126 1126 1127 1127 docPage -- calling docpage 1128 1128 """ … … 1131 1131 (DocPages.DataCarryingPage, DocPages.AliasWikiPage)): 1132 1132 return 1133 1133 1134 1134 sd, ud = docPage.getDirty() 1135 1135 if sd: … … 1160 1160 if self.getLoadedDocPage() is not None: 1161 1161 self.wikiPageSink.disconnect() 1162 1162 1163 1163 self.SetDocPointer(None) 1164 1164 self.applyBasicSciSettings() … … 1182 1182 text = docPage.getLiveText() # self.GetText() 1183 1183 textlen = len(text) 1184 1184 1185 1185 t = self.stylingThreadHolder.getThread() 1186 1186 if t is not None: … … 1209 1209 1210 1210 sth = self.stylingThreadHolder 1211 1211 1212 1212 delay = self.presenter.getConfig().getfloat( 1213 1213 "main", "async_highlight_delay") … … 1234 1234 templateNames = [n for n in wikiDocument.getAllDefinedWikiPageNames() 1235 1235 if templateRe.search(n)] 1236 1236 1237 1237 wikiDocument.getCollator().sort(templateNames) 1238 1238 … … 1278 1278 if not isinstance(docPage, DocPages.WikiPage): 1279 1279 return 1280 1280 1281 1281 if not docPage.isDefined() and not docPage.getDirty()[0]: 1282 1282 title = _(u"Select Template") … … 1300 1300 self.pageType = docPage.getAttributes().get(u"pagetype", 1301 1301 [u"normal"])[-1] 1302 self.handleSpecialPageType() 1302 self.handleSpecialPageType() 1303 1303 self.presenter.informEditorTextChanged(self) 1304 1304 … … 1307 1307 def OnContextMenu(self, evt): 1308 1308 mousePos = self.ScreenToClient(wx.GetMousePosition()) 1309 1309 1310 1310 leftFold = 0 1311 1311 for i in range(self.FOLD_MARGIN): … … 1386 1386 appendToMenuByMenuDesc(templateSubmenu, 1387 1387 _CONTEXT_MENU_SELECT_TEMPLATE_IN_TEMPLATE_MENU) 1388 1388 1389 1389 menu.AppendSeparator() 1390 1390 menu.AppendMenu(wx.NewId(), _(u'Use Template'), … … 1445 1445 1446 1446 charStartPos = end 1447 1447 1448 1448 1449 1449 def handleDropText(self, x, y, text): … … 1477 1477 # self.pageAst = pageAst 1478 1478 self.foldingseq = foldingseq 1479 1479 1480 1480 def putStyle(): 1481 1481 if stylebytes: … … 1496 1496 sleep(delay) 1497 1497 threadstop.testRunning() 1498 1498 1499 1499 docPage = self.getLoadedDocPage() 1500 1500 if docPage is None: 1501 1501 return 1502 1502 1503 1503 for i in range(20): # "while True" is too dangerous 1504 1504 formatDetails = docPage.getFormatDetails() … … 1511 1511 1512 1512 stylebytes = self.processTokens(text, pageAst, threadstop) 1513 1513 1514 1514 threadstop.testRunning() 1515 1515 1516 1516 if self.getFoldingActive(): 1517 1517 foldingseq = self.processFolding(pageAst, threadstop) … … 1576 1576 for node in pageAst.iterFlatNamed(): 1577 1577 threadstop.testRunning() 1578 1578 1579 1579 styleNo = WikiTxtCtrl._TOKEN_TO_STYLENO.get(node.name) 1580 1580 1581 1581 if styleNo is not None: 1582 1582 stylebytes.bindStyle(node.pos, node.strLength, styleNo) … … 1596 1596 elif node.name == "value" and "todoEntry" in stack: 1597 1597 process(node, stack[:]) 1598 1598 1599 1599 elif node.name == "heading": 1600 if node.level < 4:1600 if node.level < 5: 1601 1601 styleNo = FormatTypes.Heading1 + \ 1602 1602 (node.level - 1) 1603 1603 else: 1604 styleNo = FormatTypes.Heading 41604 styleNo = FormatTypes.Heading5 1605 1605 1606 1606 stylebytes.bindStyle(node.pos, node.strLength, styleNo) 1607 1607 1608 1608 elif node.name in ("table", "tableRow", "tableCell", 1609 1609 "orderedList", "unorderedList", "indentedText", … … 1631 1631 levelStack = [] 1632 1632 foldHeader = False 1633 1633 1634 1634 for node in pageAst: 1635 1635 threadstop.testRunning() 1636 1636 1637 1637 if node.name == "heading": 1638 1638 while levelStack and (levelStack[-1][0] != "heading" or … … 1654 1654 if lfc > 0: 1655 1655 foldingseq += [len(levelStack) + 1] * lfc 1656 1656 1657 1657 prevLevel = len(levelStack) + 1 1658 1658 1659 1659 # final line 1660 1660 foldingseq.append(len(levelStack) + 1) 1661 1661 1662 1662 return foldingseq 1663 1663 … … 1682 1682 for i in xrange(self.GetLineCount()): 1683 1683 self.SetFoldExpanded(i, True) 1684 1684 1685 1685 self.ShowLines(0, self.GetLineCount()-1) 1686 1686 … … 1724 1724 levOut |= 8192 1725 1725 if self.GetLineVisible(ln): 1726 levOut |= 16384 1726 levOut |= 16384 1727 1727 result[ln] = levOut 1728 1728 1729 1729 return result 1730 1730 … … 1740 1740 if levIn & 4096: 1741 1741 levComb |= wx.stc.STC_FOLDLEVELHEADERFLAG 1742 1742 1743 1743 self.SetFoldLevel(ln, levComb) 1744 1744 self.SetFoldExpanded(ln, bool(levIn & 8192)) … … 1747 1747 else: 1748 1748 self.HideLines(ln, ln) 1749 1749 1750 1750 self.repairFoldingVisibility() 1751 1751 … … 1755 1755 if not self.getFoldingActive(): 1756 1756 return 1757 1757 1758 1758 lc = self.GetLineCount() 1759 1759 1760 1760 if lc == 0: 1761 1761 return … … 1764 1764 if lc == 1: 1765 1765 return 1766 1766 1767 1767 combLevel = self.GetFoldLevel(0) 1768 1768 prevLevel = combLevel & 4095 … … 1771 1771 prevVisible = True # First line must always be visible 1772 1772 prevLn = 0 1773 1773 1774 1774 # print "0", prevLevel, bool(prevIsHeader), bool(prevIsExpanded), bool(prevVisible) 1775 1775 … … 1788 1788 (prevIsHeader and prevIsExpanded): 1789 1789 # if current level is not larger than previous this indicates 1790 # an error except that the previous line is a header line and 1790 # an error except that the previous line is a header line and 1791 1791 # folded (not expanded). 1792 1792 # Other possibility of an error is if previous line is a 1793 1793 # header and IS expanded. 1794 1794 1795 1795 # Show line in these cases 1796 1796 self.SetFoldExpanded(prevLn, True) # Needed? … … 1815 1815 1816 1816 wikiPage = self.presenter.getWikiDocument().getWikiPageNoError("ScratchPad") 1817 1817 1818 1818 # wikiPage.appendLiveText("\n%s\n---------------------------\n\n%s\n" % 1819 1819 # (mbcsDec(strftime("%x %I:%M %p"), "replace")[0], text)) … … 1839 1839 try: 1840 1840 endCharPos += len(startChars) 1841 1841 1842 1842 if emptySelection: 1843 1843 # If selection is empty, cursor will in the end … … 1850 1850 self.gotoCharPos(startCharPos, scroll=False) 1851 1851 self.AddText(startChars) 1852 1852 1853 1853 self.gotoCharPos(endCharPos, scroll=False) 1854 1854 self.AddText(endChars) … … 1857 1857 finally: 1858 1858 self.EndUndoAction() 1859 1859 1860 1860 1861 1861 def getPageAst(self): … … 1887 1887 # Same tab 1888 1888 presenter = self.presenter 1889 1889 1890 1890 titleFromLink = self.presenter.getConfig().getboolean("main", 1891 1891 "wikiPageTitle_fromLinkTitle", False) 1892 1892 1893 1893 if not titleFromLink or node.titleNode is None: 1894 1894 suggNewPageTitle = None 1895 1895 else: 1896 1896 suggNewPageTitle = node.titleNode.getString() 1897 1897 1898 1898 unaliasedTarget = self.presenter.getWikiDocument()\ 1899 1899 .getUnAliasedWikiWordOrAsIs(node.wikiWord) 1900 1900 1901 1901 docPage = self.getLoadedDocPage() 1902 1902 1903 1903 # Contains start and end character position where a search fragment 1904 1904 # search should never match … … 1922 1922 searchOp.wildCard = "no" # TODO Why not regex? 1923 1923 searchOp.searchStr = searchfrag 1924 1924 1925 1925 found = presenter.getSubControl("textedit").executeSearch( 1926 1926 searchOp, 0) 1927 1927 1928 1928 if found[0] >= forbiddenSearchfragHit[0] and \ 1929 1929 found[0] < forbiddenSearchfragHit[1]: … … 1945 1945 elif node.name == "insertion": 1946 1946 if node.key == u"page": 1947 1947 1948 1948 # open the wiki page 1949 1949 if tabMode & 2: … … 1954 1954 # Same tab 1955 1955 presenter = self.presenter 1956 1956 1957 1957 presenter.openWikiPage(node.value, 1958 1958 motionType="child") # , anchor=node.value) … … 1962 1962 presenter.getMainControl().getMainAreaPanel().\ 1963 1963 showPresenter(presenter) 1964 1964 1965 1965 return True 1966 1966 … … 1975 1975 pageAst = self.getPageAst() 1976 1976 footnoteId = node.footnoteId 1977 1977 1978 1978 anchorNode = getFootnoteAnchorDict(pageAst).get(footnoteId) 1979 1979 if anchorNode is not None: … … 1987 1987 self.gotoCharPos(fnNode.pos) 1988 1988 break 1989 1989 1990 1990 return True 1991 1991 except NoPageAstException: … … 2025 2025 wantedUnknownWords = allUnknownWords.findNodesForCharPos( 2026 2026 linkCharPos) 2027 2027 2028 2028 if linkCharPos > 0 and len(wantedUnknownWords) == 0: 2029 2029 # No unknown word found -> try left to cursor … … 2139 2139 link = self.presenter.getMainControl()\ 2140 2140 .makeRelUrlAbsolute(link) 2141 2141 2142 2142 elif link.startswith(u"file:"): 2143 2143 link = self.presenter.getMainControl()\ … … 2207 2207 # Execute all or selected script blocks on the page (or other 2208 2208 # related pages) 2209 try: 2209 try: 2210 2210 pageAst = self.getPageAst() 2211 2211 except NoPageAstException: … … 2213 2213 2214 2214 scriptNodeGroups = [list(pageAst.iterDeepByName(SCRIPTFORMAT))] 2215 2215 2216 2216 # process script imports 2217 2217 if securityLevel > 1: # Local import_scripts attributes allowed … … 2243 2243 except: 2244 2244 pass 2245 2245 2246 2246 if self.presenter.getConfig().getboolean("main", 2247 2247 "script_search_reverse", False): … … 2297 2297 # "process_autogenerated_areas"): 2298 2298 # return text 2299 # 2299 # 2300 2300 # return WikiFormatting.AutoGenAreaRE.sub(ur"\1\2\4", text) 2301 2301 … … 2328 2328 # "process_autogenerated_areas"): 2329 2329 # return text 2330 # 2330 # 2331 2331 # # So the text can be referenced from an AGA function 2332 2332 # self.agatext = text 2333 # 2333 # 2334 2334 # return WikiFormatting.AutoGenAreaRE.sub(self._agaReplace, text) 2335 2335 … … 2394 2394 startLine = self.LineFromPosition(byteStart) 2395 2395 endLine = self.LineFromPosition(byteEnd) 2396 2396 2397 2397 # Just to be sure, shouldn't happen normally 2398 2398 if endLine < startLine: 2399 2399 startLine, endLine = endLine, startLine 2400 2400 2401 2401 for checkLine in xrange(endLine, startLine - 1, -1): 2402 2402 if not self.GetLineVisible(checkLine): … … 2440 2440 else: 2441 2441 self.HideLines(line, line) 2442 2442 2443 2443 line += 1 2444 2444 2445 2445 self.incSearchPreviousHiddenLines = None 2446 2446 self.incSearchPreviousHiddenStartLine = -1 2447 2447 2448 2448 if start == -1: 2449 2449 # self.SetSelection(-1, -1) … … 2456 2456 startLine = self.LineFromPosition(byteStart) 2457 2457 endLine = self.LineFromPosition(byteEnd) 2458 2458 2459 2459 # Store current show/hide state of lines to show 2460 2460 shownList = [] 2461 2461 for i in xrange(startLine, endLine + 1): 2462 2462 shownList.append(self.GetLineVisible(i)) 2463 2463 2464 2464 self.incSearchPreviousHiddenLines = shownList 2465 2465 self.incSearchPreviousHiddenStartLine = startLine … … 2489 2489 # def startIncrementalSearch(self, initSearch=None): 2490 2490 # sb = self.presenter.getStatusBar() 2491 # 2491 # 2492 2492 # self.incSearchCharStartPos = self.GetSelectionCharPos()[1] 2493 2493 # self.incSearchPreviousHiddenLines = None 2494 2494 # self.incSearchPreviousHiddenStartLine = -1 2495 # 2495 # 2496 2496 # rect = sb.GetFieldRect(0) 2497 2497 # if isOSX(): 2498 2498 # # needed on Mac OSX to avoid cropped text 2499 2499 # rect = wx._core.Rect(rect.x, rect.y - 2, rect.width, rect.height + 4) 2500 # 2500 # 2501 2501 # rect.SetPosition(sb.ClientToScreen(rect.GetPosition())) 2502 # 2502 # 2503 2503 # dlg = WikiTxtDialogs.IncrementalSearchDialog(self, -1, self, rect, 2504 2504 # sb.GetFont(), self.presenter, initSearch) 2505 2505 # dlg.Show() 2506 # 2507 # 2506 # 2507 # 2508 2508 # def executeIncrementalSearch(self, next=False): 2509 2509 # """ … … 2516 2516 # else: 2517 2517 # charStartPos = self.incSearchCharStartPos 2518 # 2518 # 2519 2519 # regex = None 2520 2520 # try: … … 2524 2524 # # Regex error 2525 2525 # return charStartPos # ? 2526 # 2526 # 2527 2527 # match = regex.search(text, charStartPos, len(text)) 2528 2528 # if not match and charStartPos > 0: 2529 2529 # match = regex.search(text, 0, charStartPos) 2530 # 2530 # 2531 2531 # if match: 2532 2532 # # matchbytestart = self.bytelenSct(text[:match.start()]) 2533 2533 # # matchbyteend = matchbytestart + \ 2534 2534 # # self.bytelenSct(text[match.start():match.end()]) 2535 # 2535 # 2536 2536 # self.setSelectionForIncSearchByCharPos( 2537 2537 # match.start(), match.end()) 2538 # 2538 # 2539 2539 # return match.end() 2540 # 2540 # 2541 2541 # self.setSelectionForIncSearchByCharPos(-1, -1) 2542 2542 # self.GotoPos(self.bytelenSct(text[:self.incSearchCharStartPos])) 2543 # 2543 # 2544 2544 # return -1 2545 # 2546 # 2545 # 2546 # 2547 2547 # def executeIncrementalSearchBackward(self): 2548 2548 # """ … … 2552 2552 # if len(self.searchStr) > 0: 2553 2553 # charStartPos = self.GetSelectionCharPos()[0] 2554 # 2554 # 2555 2555 # regex = None 2556 2556 # try: … … 2560 2560 # # Regex error 2561 2561 # return charStartPos # ? 2562 # 2562 # 2563 2563 # match = regex.search(text, 0, len(text)) 2564 2564 # if match: … … 2570 2570 # break 2571 2571 # match = matchNext 2572 # 2572 # 2573 2573 # else: 2574 2574 # while True: … … 2577 2577 # break 2578 2578 # match = matchNext 2579 # 2579 # 2580 2580 # self.setSelectionForIncSearchByCharPos(match.start(), match.end()) 2581 # 2581 # 2582 2582 # return match.start() 2583 # 2583 # 2584 2584 # self.setSelectionForIncSearchByCharPos(-1, -1) 2585 2585 # self.GotoPos(self.bytelenSct(text[:self.incSearchCharStartPos])) 2586 # 2586 # 2587 2587 # return -1 2588 # 2589 # 2588 # 2589 # 2590 2590 # def forgetIncrementalSearch(self): 2591 2591 # """ … … 2594 2594 # """ 2595 2595 # pass 2596 # 2596 # 2597 2597 # def resetIncrementalSearch(self): 2598 2598 # """ … … 2602 2602 # self.setSelectionForIncSearchByCharPos(-1, -1) 2603 2603 # self.GotoPos(self.bytelenSct(self.GetText()[:self.incSearchCharStartPos])) 2604 # 2605 # 2604 # 2605 # 2606 2606 # def endIncrementalSearch(self): 2607 2607 # """ … … 2610 2610 # byteStart = self.GetSelectionStart() 2611 2611 # byteEnd = self.GetSelectionEnd() 2612 # 2612 # 2613 2613 # self.setSelectionForIncSearchByCharPos(-1, -1) 2614 # 2614 # 2615 2615 # self.SetSelection(byteStart, byteEnd) 2616 2616 # self.ensureSelectionExpanded() 2617 # 2618 # 2617 # 2618 # 2619 2619 # def getContinuePosForSearch(self, sarOp): 2620 2620 # """ … … 2622 2622 # search operation sarOp. It always continues at beginning 2623 2623 # or end of current selection. 2624 # 2624 # 2625 2625 # If sarOp uses a regular expression, this function may throw 2626 2626 # a re.error exception. 2627 2627 # """ 2628 2628 # range = self.GetSelectionCharPos() 2629 # 2629 # 2630 2630 # # if sarOp.matchesPart(self.GetSelectedText()) is not None: 2631 2631 # if sarOp.matchesPart(self.GetText(), range) is not None: … … 2637 2637 # # -> continue searching at the beginning of selection 2638 2638 # return range[0] 2639 # 2640 # 2639 # 2640 # 2641 2641 # def executeSearch(self, sarOp, searchCharStartPos=-1, next=False): 2642 2642 # """ … … 2647 2647 # if sarOp.booleanOp: 2648 2648 # return (-1, -1) # Not possible 2649 # 2649 # 2650 2650 # if searchCharStartPos == -2: 2651 2651 # searchCharStartPos = self.getContinuePosForSearch(sarOp) 2652 # 2652 # 2653 2653 # text = self.GetText() 2654 2654 # if len(sarOp.searchStr) > 0: … … 2662 2662 # # Regex error 2663 2663 # return (-1, -1) # (self.anchorCharPosition, self.anchorCharPosition) 2664 # 2664 # 2665 2665 # if start is not None: 2666 2666 # self.showSelectionByCharPos(start, end) 2667 # 2667 # 2668 2668 # return found # self.anchorCharPosition 2669 # 2669 # 2670 2670 # self.SetSelection(-1, -1) 2671 2671 # self.GotoPos(self.bytelenSct(text[:searchCharStartPos])) 2672 # 2672 # 2673 2673 # return (-1, -1) 2674 # 2675 # 2674 # 2675 # 2676 2676 # def executeReplace(self, sarOp): 2677 2677 # """ … … 2683 2683 # # found = sarOp.matchesPart(seltext) 2684 2684 # range = self.GetSelectionCharPos() 2685 # 2685 # 2686 2686 # # if sarOp.matchesPart(self.GetSelectedText()) is not None: 2687 2687 # found = sarOp.matchesPart(text, range) 2688 # 2688 # 2689 2689 # if found is None: 2690 2690 # return -1 2691 # 2692 # replacement = sarOp.replace(text, found) 2691 # 2692 # replacement = sarOp.replace(text, found) 2693 2693 # bytestart = self.GetSelectionStart() 2694 2694 # self.ReplaceSelection(replacement) 2695 2695 # selByteEnd = bytestart + self.bytelenSct(replacement) 2696 2696 # selCharEnd = len(self.GetTextRange(0, selByteEnd)) 2697 # 2697 # 2698 2698 # return selCharEnd 2699 2699 … … 2721 2721 bytePos = self.GetCurrentPos() 2722 2722 lineStartBytePos = self.PositionFromLine(self.LineFromPosition(bytePos)) 2723 2723 2724 2724 lineStartCharPos = len(self.GetTextRange(0, lineStartBytePos)) 2725 2725 charPos = lineStartCharPos + len(self.GetTextRange(lineStartBytePos, … … 2733 2733 self.presenter.getWikiDocument().getCollator().sortByFirst( 2734 2734 acResultTuples) 2735 2735 2736 2736 self.autoCompBackBytesMap = dict( ( 2737 2737 (art[1], self.bytelenSct(text[charPos - art[2]:charPos])) … … 2797 2797 selByteStart = self.PositionFromLine(self.LineFromPosition(selByteStart)) 2798 2798 selByteEnd = self.PositionFromLine(lastLine + 1) 2799 2799 2800 2800 if extendOverChildren: 2801 2801 # Extend over all lines which are more indented than the last line 2802 2802 2803 2803 lastLineDeep = StringOps.splitIndentDeepness(self.GetLine(lastLine))[0] 2804 2804 2805 2805 testLine = lastLine + 1 2806 while True: 2806 while True: 2807 2807 testLineContent = self.GetLine(testLine) 2808 2808 if len(testLineContent) == 0: … … 2812 2812 if StringOps.splitIndentDeepness(testLineContent)[0] <= lastLineDeep: 2813 2813 break 2814 2814 2815 2815 testLine += 1 2816 2816 … … 2827 2827 def OnKeyDown(self, evt): 2828 2828 key = evt.GetKeyCode() 2829 2829 2830 2830 self.lastKeyPressed = time() 2831 2831 accP = getAccelPairFromKeyDown(evt) … … 2842 2842 selByteStart, selByteEnd = self._getExpandedByteSelectionToLine( 2843 2843 bool(accP[0] & wx.ACCEL_SHIFT)) 2844 2844 2845 2845 firstLine = self.LineFromPosition(selByteStart) 2846 2846 if firstLine > 0: … … 2871 2871 selByteStart, selByteEnd = self._getExpandedByteSelectionToLine( 2872 2872 bool(accP[0] & wx.ACCEL_SHIFT)) 2873 2873 2874 2874 lastLine = self.LineFromPosition(selByteEnd) 2875 2875 lineCount = self.GetLineCount() - 1 … … 2901 2901 self.EndUndoAction() 2902 2902 return 2903 2903 2904 2904 evt.Skip() 2905 2905 … … 2909 2909 # self.startIncrementalSearch(self.searchStr) 2910 2910 # evt.Skip() 2911 # 2911 # 2912 2912 # elif matchesAccelPair("StartIncrementalSearch", accP): 2913 2913 # # Start incremental search … … 2958 2958 bytePos = self.GetCurrentPos() 2959 2959 lineStartBytePos = self.PositionFromLine(self.LineFromPosition(bytePos)) 2960 2960 2961 2961 lineStartCharPos = len(self.GetTextRange(0, lineStartBytePos)) 2962 2962 charPos = lineStartCharPos + len(self.GetTextRange(lineStartBytePos, … … 2965 2965 autoUnbullet = self.presenter.getConfig().getboolean("main", 2966 2966 "editor_autoUnbullets", False) 2967 2967 2968 2968 settings = { 2969 2969 "autoUnbullet": autoUnbullet, … … 2971 2971 "autoIndent": self.autoIndent 2972 2972 } 2973 2973 2974 2974 if self.wikiLanguageHelper.handleNewLineBeforeEditor(self, text, 2975 2975 charPos, lineStartCharPos, wikiDocument, settings): … … 2979 2979 else: 2980 2980 evt.Skip() 2981 2981 2982 2982 else: 2983 2983 super(WikiTxtCtrl, self).OnKeyDown(evt) … … 2995 2995 evt.Skip() 2996 2996 return 2997 2997 2998 2998 if key >= wx.WXK_START and (not isUnicode() or evt.GetUnicodeKey() != key): 2999 2999 evt.Skip() … … 3063 3063 3064 3064 tabMode = Configuration.MIDDLE_MOUSE_CONFIG_TO_TABMODE[middleConfig] 3065 3065 3066 3066 if not self.activateLink(evt.GetPosition(), tabMode=tabMode): 3067 3067 evt.Skip() … … 3081 3081 # else: 3082 3082 # textPos = self.PositionFromPoint(evt.GetPosition()) 3083 # 3083 # 3084 3084 # if (self.isPositionInWikiWord(textPos) or 3085 3085 # self.isPositionInLink(textPos)): … … 3096 3096 # if evt.stylebytes: 3097 3097 # self.applyStyling(evt.stylebytes) 3098 # 3098 # 3099 3099 # if evt.foldingseq: 3100 3100 # self.applyFolding(evt.foldingseq) 3101 # 3101 # 3102 3102 3103 3103 … … 3128 3128 self.ToggleFold(line) 3129 3129 self.repairFoldingVisibility() 3130 3130 3131 3131 evt.Skip() 3132 3133 3132 3133 3134 3134 3135 3135 def _threadShowCalltip(self, wikiDocument, charPos, bytePos, … … 3179 3179 args=(wikiDocument, charPos, bytePos), 3180 3180 kwargs={"threadstop": self.calltipThreadHolder}) 3181 3181 3182 3182 self.calltipThreadHolder.setThread(thread) 3183 3183 thread.start() … … 3201 3201 x = paramDict.get("x") 3202 3202 y = paramDict.get("y") 3203 3203 3204 3204 dlgParams = WikiTxtDialogs.FilePasteParams() 3205 3205 # config = editor.presenter.getMainControl().getConfig() … … 3224 3224 # User abort 3225 3225 return 3226 3226 3227 3227 unifActionName = dlgParams.unifActionName 3228 3228 … … 3275 3275 for fn in filenames: 3276 3276 url = StringOps.urlFromPathname(fn) 3277 3277 3278 3278 if fn.endswith(u".wiki"): 3279 3279 urls.append(u"wiki:%s" % url) … … 3295 3295 # Relative rel: URL 3296 3296 url = editor.presenter.getMainControl().makeAbsPathRelUrl(fn) 3297 3297 3298 3298 if url is None: 3299 3299 url = u"file:" + StringOps.urlFromPathname(fn) … … 3331 3331 # wxGetKeyState(WXK_MBUTTON) or \ 3332 3332 # wxGetKeyState(WXK_RBUTTON) 3333 # 3333 # 3334 3334 # ctrlPressed = wxGetKeyState(WXK_CONTROL) 3335 # 3335 # 3336 3336 # if (not ctrlPressed) or mouseBtnPressed: 3337 3337 # self.SetCursor(WikiTxtCtrl.CURSOR_IBEAM) … … 3339 3339 # else: 3340 3340 # linkPos = self.PositionFromPoint(wxPoint(*self.ScreenToClientXY(*mousePos))) 3341 # 3341 # 3342 3342 # if (self.isPositionInWikiWord(linkPos) or 3343 3343 # self.isPositionInLink(linkPos)): … … 3368 3368 self.fobj = wx.FileDataObject() 3369 3369 dataob.Add(self.fobj) 3370 3370 3371 3371 self.dataob = dataob 3372 3372 self.SetDataObject(dataob) … … 3403 3403 urls = [] 3404 3404 3405 # Necessary because key state may change during the loop 3405 # Necessary because key state may change during the loop 3406 3406 controlPressed = wx.GetKeyState(wx.WXK_CONTROL) 3407 3407 shiftPressed = wx.GetKeyState(wx.WXK_SHIFT) 3408 3408 3409 3409 if isLinux(): 3410 3410 # On Linux, at least Ubuntu, fn may be a UTF-8 encoded unicode(!?) … … 3439 3439 # u"action/editor/this/paste/files/insert/url/absolute", 3440 3440 # WikiTxtCtrl.userActionPasteFiles) 3441 # 3441 # 3442 3442 # _ACTION_EDITOR_PASTE_FILES_RELATIVE = UserActionCoord.SimpleAction("", 3443 3443 # u"action/editor/this/paste/files/insert/url/relative", 3444 3444 # WikiTxtCtrl.userActionPasteFiles) 3445 # 3445 # 3446 3446 # _ACTION_EDITOR_PASTE_FILES_TOSTORAGE = UserActionCoord.SimpleAction("", 3447 3447 # u"action/editor/this/paste/files/insert/url/tostorage", 3448 3448 # WikiTxtCtrl.userActionPasteFiles) 3449 # 3449 # 3450 3450 # _ACTION_EDITOR_PASTE_FILES_ASK = UserActionCoord.SimpleAction("", 3451 3451 # u"action/editor/this/paste/files/insert/url/ask", 3452 3452 # WikiTxtCtrl.userActionPasteFiles) 3453 # 3454 # 3453 # 3454 # 3455 3455 # _ACTIONS = ( 3456 3456 # _ACTION_EDITOR_PASTE_FILES_ABSOLUTE, _ACTION_EDITOR_PASTE_FILES_RELATIVE, -
branches/mbutscher/work/lib/pwiki/wikidata/compact_sqlite/DbStructure.py
r234 r252 897 897 return int(connwrap.execSqlQuerySingleItem("select value from settings where key=?", 898 898 (key,), default)) 899 900 899 901 900 902 -
branches/mbutscher/work/lib/pwiki/wikidata/compact_sqlite/WikiData.py
r250 r252 36 36 # pass 37 37 38 39 38 from pwiki.StringOps import getBinCompactForDiff, applyBinCompact, longPathEnc, \ 40 39 longPathDec, binCompactToCompact, fileContentToUnicode, utf8Enc, utf8Dec, \ … … 61 60 62 61 dbfile = longPathDec(dbfile) 62 63 63 try: 64 64 self.connWrap = DbStructure.ConnectWrapSyncCommit( … … 67 67 traceback.print_exc() 68 68 raise DbReadAccessError(e) 69 69 70 70 # Set temporary directory if this is first sqlite use after prog. start 71 71 if not GetApp().sqliteInitFlag: … … 105 105 GetApp().sqliteInitFlag = True 106 106 107 108 107 DbStructure.registerSqliteFunctions(self.connWrap) 109 108 … … 147 146 # return value, used by getContent() 148 147 self.contentDbToOutput = lambda c: utf8Dec(c, "replace")[0] 149 148 150 149 try: 151 150 # Set marker for database type … … 167 166 self._createTempTables() 168 167 169 # reset cache168 # create word caches 170 169 self.cachedContentNames = None 171 172 170 self.cachedGlobalAttrs = None 173 171 self.getGlobalAttributes() … … 180 178 raise DbReadAccessError(e2) 181 179 raise DbReadAccessError(e) 182 180 183 181 if lastException: 184 182 raise lastException … … 198 196 # These schema changes are only on a temporary table so they are not 199 197 # in DbStructure.py 200 self.connWrap.execSql("create temp table temppathfindparents " 198 self.connWrap.execSql("create temp table temppathfindparents "+ 201 199 "(word text primary key, child text, steps integer)") 202 200 203 self.connWrap.execSql("create index temppathfindparents_steps " 201 self.connWrap.execSql("create index temppathfindparents_steps "+ 204 202 "on temppathfindparents(steps)") 205 203 206 204 207 205 # ---------- Direct handling of page data ---------- 208 206 209 207 def getContent(self, word): 208 """ 209 Function must work for read-only wiki. 210 """ 210 211 try: 211 212 result = self.connWrap.execSqlQuerySingleItem("select content from "+\ … … 365 366 "created = ?, visited = ? where word = ?", 366 367 (moddate, creadate, visitdate, word)) 368 self.commitNeeded = True 367 369 except (IOError, OSError, sqlite.Error), e: 368 370 traceback.print_exc() … … 426 428 427 429 430 431 428 432 # ---------- Renaming/deleting pages with cache update or invalidation ---------- 429 433 … … 439 443 self.connWrap.execSql("update wikiwordmatchterms set word = ? where word = ?", (toWord, word)) 440 444 self._renameContent(word, toWord) 441 442 445 self.connWrap.commit() 443 446 except: … … 449 452 450 453 451 def deleteWord(self, word ):454 def deleteWord(self, word, delContent=True): 452 455 """ 453 456 delete everything about the wikiword passed in. an exception is raised 454 457 if you try and delete the wiki root node. 458 459 delContent -- Should actual content be deleted as well? (Parameter is 460 not part of official API) 455 461 """ 456 462 if word != self.wikiDocument.getWikiName(): … … 465 471 self.deleteAttributes(word) 466 472 self.deleteTodos(word) 467 # self.connWrap.execSql("delete from wikiwordcontent where word = ?", (word,))468 self._deleteContent(word)473 if delContent: 474 self._deleteContent(word) 469 475 self.deleteWikiWordMatchTerms(word, syncUpdate=False) 470 476 self.deleteWikiWordMatchTerms(word, syncUpdate=True) … … 488 494 self.connWrap.execSql("update wikiwordcontent set metadataprocessed = ? " 489 495 "where word = ?", (state, word)) 496 self.commitNeeded = True 490 497 except (IOError, OSError, sqlite.Error), e: 491 498 traceback.print_exc() … … 511 518 self.connWrap.execSql("update wikiwordcontent set metadataprocessed = ?", 512 519 (state,)) 520 self.commitNeeded = True 513 521 514 522 -
branches/mbutscher/work/lib/pwiki/wikidata/original_gadfly/WikiData.py
r250 r252 141 141 142 142 def getContent(self, word): 143 """ 144 Function must work for read-only wiki. 145 """ 143 146 try: 144 147 try: … … 294 297 """ 295 298 Returns a tuple with modification, creation and visit date of 296 a word or (None, None, None) if word is not in the database 299 a word or (None, None, None) if word is not in the database. 300 Aliases must be resolved beforehand. 301 Function must work for read-only wiki. 297 302 """ 298 303 try: … … 313 318 """ 314 319 Set timestamps for an existing wiki page. 320 Aliases must be resolved beforehand. 315 321 """ 316 322 moddate, creadate, visitdate = timestamps[:3] … … 427 433 if word != self.wikiDocument.getWikiName(): 428 434 try: 435 self.connWrap.syncCommit() 429 436 try: 430 self.commit()431 437 # don't delete the relations to the word since other 432 438 # pages still have valid outward links to this page. … … 460 466 461 467 462 463 468 def setMetaDataState(self, word, state): 464 469 """ … … 601 606 """ 602 607 get the child relations of this word 608 Function must work for read-only wiki. 603 609 existingonly -- List only existing wiki words 604 610 selfreference -- List also wikiWord if it references itself -
branches/mbutscher/work/lib/pwiki/wikidata/original_sqlite/DbStructure.py
r234 r252 350 350 finally: 351 351 self.accessLock.release() 352 353 352 354 353 … … 551 550 552 551 rebuildIndices(connwrap) 552 553 553 # connwrap.execSql("create unique index wikirelations_pkey on wikirelations(word, relation)") 554 554 # connwrap.execSql("create index wikirelations_word on wikirelations(word)") -
branches/mbutscher/work/lib/pwiki/wikidata/original_sqlite/WikiData.py
r250 r252 165 165 # Remember but continue 166 166 lastException = DbWriteAccessError(e) 167 167 168 168 # Function to convert unicode strings from input to content in database 169 169 # used by setContent 170 170 171 def contentUniInputToDb(unidata): 171 172 return utf8Enc(unidata, "replace")[0] … … 403 404 "created = ?, visited = ? where word = ?", 404 405 (moddate, creadate, visitdate, word)) 406 self.commitNeeded = True 405 407 except (IOError, OSError, sqlite.Error), e: 406 408 traceback.print_exc() … … 423 425 "visited": Last visit date of page 424 426 "firstcharpos": Dummy returning very high value 425 426 427 """ 427 428 if withFields is None: … … 530 531 self.connWrap.execSql("update wikiwords set metadataprocessed = ? " 531 532 "where word = ?", (state, word)) 533 self.commitNeeded = True 532 534 except (IOError, OSError, sqlite.Error), e: 533 535 traceback.print_exc() … … 553 555 self.connWrap.execSql("update wikiwords set metadataprocessed = ?", 554 556 (state,)) 557 self.commitNeeded = True 555 558 556 559
