Changeset 178

Show
Ignore:
Timestamp:
01/25/09 10:13:14 (4 years ago)
Author:
mbutscher
Message:

2.0preAlpha (internal)

Works so far, now editing help wiki.

Location:
branches/mbutscher/next
Files:
347 added
1 removed
36 modified

Legend:

Unmodified
Added
Removed
  • branches/mbutscher/next/Consts.py

    r175 r178  
    2828 
    2929 
    30 DEADBLOCKTIMEOUT = 30 
     30DEADBLOCKTIMEOUT = 40 
    3131 
    3232 
     
    6767WIKIWORDMATCHTERMS_TYPE_FROM_CONTENT = 8 
    6868 
     69 
    6970# Matchterm will be created and deleted synchronously (normally in main thread) 
    7071# to ensure it is always up-to-date 
  • branches/mbutscher/next/ExceptionLogger.py

    r166 r178  
    11import sys, traceback, time, os.path 
     2 
     3EL = None 
     4 
    25 
    36# global exception control 
    47class StdErrReplacement: 
    58    def write(self, data): 
    6         try: 
    7             import ExceptionLogger as EL 
    8         except ImportError: 
    9             # This should only happen while interpreter shuts down 
    10             return 
    11 #         global _exceptionDestDir, _exceptionSessionTimeStamp, _exceptionOccurred 
    12 #         global _previousExcepthook 
     9        global EL 
     10#         try: 
     11#             import ExceptionLogger as EL 
     12#         except ImportError: 
     13#             # This should only happen while interpreter shuts down 
     14#             return 
    1315 
    1416        try: 
     
    1618            try: 
    1719                if not EL._timestampPrinted: 
    18                     # (Only write for first exception in session) This isn't an exception 
     20                    # Only write for first occurrence in session 
    1921                    f.write(EL._exceptionSessionTimeStamp) 
    2022                    EL._timestampPrinted = True 
     
    3032            self.write(l) 
    3133             
    32 #     def __getattr__(self, attr): 
    33 #         print "__getattr__", repr(attr) 
    34 #         return None 
    35  
    36  
    37 # class ExceptionHandler: 
    38 #     def __init__(self): 
    39 #         global _exceptionDestDir, _exceptionSessionTimeStamp, _exceptionOccurred 
    40 #         global _previousExcepthook 
    41 #         self._exceptionDestDir = _exceptionDestDir 
    42 #         self._exceptionSessionTimeStamp = _exceptionSessionTimeStamp 
    43 #         self._exceptionOccurred = _exceptionOccurred 
    44 #         self._previousExcepthook = _previousExcepthook 
    45 #         self.traceback = traceback 
    4634#  
    4735 
    4836def onException(typ, value, trace): 
    49 #     global _exceptionDestDir, _exceptionSessionTimeStamp, _exceptionOccurred 
    50 #     global _previousExcepthook 
    51 #     global _traceback2 
    52     import ExceptionLogger as EL 
    53  
     37    global EL 
     38    print "--onException1" 
    5439    try: 
     40#         import ExceptionLogger as EL 
     41        print "--onException4" 
    5542##        traceback.print_exception(typ, value, trace, file=sys.stdout) 
    5643        f = open(os.path.join(EL._exceptionDestDir, "WikidPad_Error.log"), "a") 
     
    7562 
    7663def startLogger(versionstring): 
    77     import ExceptionLogger as EL 
     64    global EL 
     65    import ExceptionLogger as EL2 
     66     
     67    EL = EL2 
    7868     
    7969    EL._exceptionDestDir = os.path.dirname(os.path.abspath(sys.argv[0])) 
  • branches/mbutscher/next/WikidPad.xrc

    r177 r178  
    126126      </object> 
    127127      <object class="sizeritem"> 
    128         <object class="wxCheckBox" name="cbLowResources"> 
    129           <label>Low resource usage</label> 
    130         </object> 
    131         <option>0</option> 
    132         <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    133         <border>5</border> 
    134       </object> 
    135       <object class="sizeritem"> 
    136         <object class="wxCheckBox" name="cbSingleProcess"> 
    137           <label>Single process per user</label> 
    138         </object> 
    139         <option>0</option> 
    140         <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    141         <border>5</border> 
    142       </object> 
    143       <object class="sizeritem"> 
    144128        <object class="wxCheckBox" name="cbWikiPathesRelative"> 
    145129          <label>Store relative pathes to wikis</label> 
     
    379363      </object> 
    380364      <object class="sizeritem"> 
     365        <object class="wxStaticLine"/> 
     366        <option>0</option> 
     367        <flag>wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     368        <border>5</border> 
     369      </object> 
     370      <object class="sizeritem"> 
    381371        <object class="wxFlexGridSizer"> 
    382372          <object class="sizeritem"> 
    383373            <object class="wxStaticText"> 
    384               <label>Structure window pos.:</label> 
     374              <label>Structure window position:</label> 
    385375            </object> 
    386376            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     
    403393          <object class="sizeritem"> 
    404394            <object class="wxStaticText"> 
    405               <label>Structure window depth:</label> 
     395              <label>Structure window heading depth:</label> 
    406396            </object> 
    407397            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     
    436426    <object class="wxBoxSizer"> 
    437427      <orient>wxVERTICAL</orient> 
    438       <object class="sizeritem"> 
    439         <object class="wxCheckBox" name="cbProcessAutoGenerated"> 
    440           <label>Process auto-generated areas</label> 
    441         </object> 
    442         <option>0</option> 
    443         <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    444         <border>5</border> 
    445       </object> 
    446428      <object class="sizeritem"> 
    447429        <object class="wxCheckBox" name="cbInsertionsAllowEval"> 
     
    501483      <object class="sizeritem"> 
    502484        <object class="wxCheckBox" name="cbHideUndefinedWords"> 
    503           <label>Hide Undefined WikiWords in Tree</label> 
    504         </object> 
    505         <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    506         <border>5</border> 
    507       </object> 
    508       <object class="sizeritem"> 
    509         <object class="wxCheckBox" name="cbTreeNoCycles"> 
    510           <label>No cycles in tree</label> 
     485          <label>Hide undefined wiki words in Tree</label> 
    511486        </object> 
    512487        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     
    967942    </object> 
    968943  </object> 
    969   <object class="wxPanel" name="OptionsPageAutosave"> 
    970     <object class="wxBoxSizer"> 
    971       <orient>wxVERTICAL</orient> 
    972       <object class="sizeritem"> 
    973         <object class="wxCheckBox" name="cbAutoSave"> 
    974           <label>Autosave active</label> 
    975         </object> 
    976         <option>0</option> 
    977         <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    978         <border>5</border> 
    979       </object> 
    980       <object class="sizeritem"> 
    981         <object class="wxFlexGridSizer"> 
    982           <object class="sizeritem"> 
    983             <object class="wxStaticText"> 
    984               <label>Delay after key pressed:</label> 
    985             </object> 
    986             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    987             <border>5</border> 
    988           </object> 
    989           <object class="sizeritem"> 
    990             <object class="wxTextCtrl" name="tfAutoSaveDelayKeyPressed"/> 
    991             <flag>wxALL|wxEXPAND</flag> 
    992             <border>5</border> 
    993           </object> 
    994           <object class="sizeritem"> 
    995             <object class="wxStaticText"> 
    996               <label>second(s)</label> 
    997             </object> 
    998             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    999             <border>5</border> 
    1000           </object> 
    1001           <cols>3</cols> 
    1002           <object class="sizeritem"> 
    1003             <object class="wxStaticText"> 
    1004               <label>Delay after page dirty:</label> 
    1005             </object> 
    1006             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1007             <border>5</border> 
    1008           </object> 
    1009           <object class="sizeritem"> 
    1010             <object class="wxTextCtrl" name="tfAutoSaveDelayDirty"/> 
    1011             <flag>wxALL|wxEXPAND</flag> 
    1012             <border>5</border> 
    1013           </object> 
    1014           <object class="sizeritem"> 
    1015             <object class="wxStaticText"> 
    1016               <label>second(s)</label> 
    1017             </object> 
    1018             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1019             <border>5</border> 
    1020           </object> 
    1021         </object> 
    1022         <option>0</option> 
    1023         <flag>wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1024       </object> 
    1025     </object> 
    1026   </object> 
    1027944  <object class="wxPanel" name="OptionsPageEditor"> 
    1028945    <object class="wxBoxSizer"> 
    1029946      <orient>wxVERTICAL</orient> 
    1030       <object class="sizeritem"> 
    1031         <object class="wxFlexGridSizer"> 
    1032           <cols>3</cols> 
    1033           <object class="sizeritem"> 
    1034             <object class="wxStaticText"> 
    1035               <label>Sync. highlighting limit:</label> 
    1036             </object> 
    1037             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1038             <border>5</border> 
    1039           </object> 
    1040           <object class="sizeritem"> 
    1041             <object class="wxTextCtrl" name="tfSyncHighlightingByteLimit"/> 
    1042             <flag>wxALL|wxEXPAND</flag> 
    1043             <border>5</border> 
    1044           </object> 
    1045           <object class="sizeritem"> 
    1046             <object class="wxStaticText"> 
    1047               <label>bytes</label> 
    1048             </object> 
    1049             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1050             <border>5</border> 
    1051           </object> 
    1052           <object class="sizeritem"> 
    1053             <object class="wxStaticText"> 
    1054               <label>Highlight start delay:</label> 
    1055             </object> 
    1056             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1057             <border>5</border> 
    1058           </object> 
    1059           <object class="sizeritem"> 
    1060             <object class="wxTextCtrl" name="tfAsyncHighlightingDelay"/> 
    1061             <flag>wxALL|wxEXPAND</flag> 
    1062             <border>5</border> 
    1063           </object> 
    1064           <object class="sizeritem"> 
    1065             <object class="wxStaticText"> 
    1066               <label>second(s)</label> 
    1067             </object> 
    1068             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1069             <border>5</border> 
    1070           </object> 
    1071           <object class="sizeritem"> 
    1072             <object class="wxStaticText"> 
    1073               <label>Short hint delay:</label> 
    1074             </object> 
    1075             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1076             <border>5</border> 
    1077           </object> 
    1078           <object class="sizeritem"> 
    1079             <object class="wxTextCtrl" name="tfEditorShortHintDelay"/> 
    1080             <flag>wxALL|wxEXPAND</flag> 
    1081             <border>5</border> 
    1082           </object> 
    1083           <object class="sizeritem"> 
    1084             <object class="wxStaticText"> 
    1085               <label>milliseconds</label> 
    1086             </object> 
    1087             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1088             <border>5</border> 
    1089           </object> 
    1090           <growablecols>1</growablecols> 
    1091         </object> 
    1092         <option>0</option> 
    1093         <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    1094       </object> 
    1095947      <object class="sizeritem"> 
    1096948        <object class="wxCheckBox" name="cbAutoUnbullets"> 
     
    19931845              <label>Change these only if you know what you are doing!</label> 
    19941846              <fg>#A80000</fg> 
    1995         </object> 
     1847              <font> 
     1848                <family>normal</family> 
     1849                <style>default</style> 
     1850                <weight>bold</weight> 
     1851                <underlined>0</underlined> 
     1852              </font> 
     1853            </object> 
    19961854            <option>0</option> 
    19971855            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     
    20201878        <border>0</border> 
    20211879      </object> 
     1880      <object class="sizeritem"> 
     1881        <object class="wxStaticBoxSizer"> 
     1882          <orient>wxVERTICAL</orient> 
     1883          <label></label> 
     1884          <object class="sizeritem"> 
     1885            <object class="wxStaticText"> 
     1886              <label>Editor timing</label> 
     1887              <font> 
     1888                <family>normal</family> 
     1889                <style>default</style> 
     1890                <weight>bold</weight> 
     1891                <underlined>0</underlined> 
     1892              </font> 
     1893            </object> 
     1894            <option>0</option> 
     1895            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1896            <border>5</border> 
     1897      </object> 
     1898          <object class="sizeritem"> 
     1899            <object class="wxFlexGridSizer"> 
     1900              <cols>3</cols> 
     1901              <object class="sizeritem"> 
     1902                <object class="wxStaticText"> 
     1903                  <label>Sync. highlighting limit:</label> 
     1904            </object> 
     1905                <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1906                <border>5</border> 
     1907          </object> 
     1908              <object class="sizeritem"> 
     1909                <object class="wxTextCtrl" name="tfSyncHighlightingByteLimit"/> 
     1910                <flag>wxALL|wxEXPAND</flag> 
     1911                <border>5</border> 
     1912          </object> 
     1913              <object class="sizeritem"> 
     1914                <object class="wxStaticText"> 
     1915                  <label>bytes</label> 
     1916            </object> 
     1917                <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1918                <border>5</border> 
     1919          </object> 
     1920              <object class="sizeritem"> 
     1921                <object class="wxStaticText"> 
     1922                  <label>Highlight start delay:</label> 
     1923            </object> 
     1924                <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1925                <border>5</border> 
     1926          </object> 
     1927              <object class="sizeritem"> 
     1928                <object class="wxTextCtrl" name="tfAsyncHighlightingDelay"/> 
     1929                <flag>wxALL|wxEXPAND</flag> 
     1930                <border>5</border> 
     1931          </object> 
     1932              <object class="sizeritem"> 
     1933                <object class="wxStaticText"> 
     1934                  <label>second(s)</label> 
     1935            </object> 
     1936                <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1937                <border>5</border> 
     1938          </object> 
     1939              <object class="sizeritem"> 
     1940                <object class="wxStaticText"> 
     1941                  <label>Short hint delay:</label> 
     1942            </object> 
     1943                <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1944                <border>5</border> 
     1945          </object> 
     1946              <object class="sizeritem"> 
     1947                <object class="wxTextCtrl" name="tfEditorShortHintDelay"/> 
     1948                <flag>wxALL|wxEXPAND</flag> 
     1949                <border>5</border> 
     1950          </object> 
     1951              <object class="sizeritem"> 
     1952                <object class="wxStaticText"> 
     1953                  <label>milliseconds</label> 
     1954            </object> 
     1955                <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1956                <border>5</border> 
     1957          </object> 
     1958              <growablecols>1</growablecols> 
     1959            </object> 
     1960            <option>0</option> 
     1961            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1962      </object> 
     1963        </object> 
     1964        <option>0</option> 
     1965        <flag>wxALL|wxEXPAND</flag> 
     1966        <border>0</border> 
     1967      </object> 
    20221968      <object class="spacer"> 
    20231969        <size>5,5</size> 
    20241970      </object> 
    20251971      <object class="sizeritem"> 
     1972        <object class="wxCheckBox" name="cbSingleProcess"> 
     1973          <label>Single process per user*</label> 
     1974        </object> 
     1975        <option>0</option> 
     1976        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1977        <border>5</border> 
     1978      </object> 
     1979      <object class="sizeritem"> 
     1980        <object class="wxCheckBox" name="cbTreeNoCycles"> 
     1981          <label>No cycles in tree</label> 
     1982        </object> 
     1983        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1984        <border>5</border> 
     1985      </object> 
     1986      <object class="sizeritem"> 
     1987        <object class="wxCheckBox" name="cbProcessAutoGenerated"> 
     1988          <label>Process auto-generated areas</label> 
     1989          <hidden>1</hidden> 
     1990        </object> 
     1991        <option>0</option> 
     1992        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     1993        <border>5</border> 
     1994      </object> 
     1995      <object class="sizeritem"> 
    20261996        <object class="wxCheckBox" name="cbEditorUseImeWorkaround"> 
    20271997          <label>Use IME workaround for editor input*</label> 
     
    20412011        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    20422012        <border>5</border> 
     2013      </object> 
     2014    </object> 
     2015  </object> 
     2016  <object class="wxPanel" name="OptionsPageAutosave"> 
     2017    <object class="wxBoxSizer"> 
     2018      <orient>wxVERTICAL</orient> 
     2019      <object class="sizeritem"> 
     2020        <object class="wxCheckBox" name="cbAutoSave"> 
     2021          <label>Autosave active</label> 
     2022        </object> 
     2023        <option>0</option> 
     2024        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2025        <border>5</border> 
     2026      </object> 
     2027      <object class="sizeritem"> 
     2028        <object class="wxFlexGridSizer"> 
     2029          <object class="sizeritem"> 
     2030            <object class="wxStaticText"> 
     2031              <label>Delay after key pressed:</label> 
     2032            </object> 
     2033            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2034            <border>5</border> 
     2035          </object> 
     2036          <object class="sizeritem"> 
     2037            <object class="wxTextCtrl" name="tfAutoSaveDelayKeyPressed"/> 
     2038            <flag>wxALL|wxEXPAND</flag> 
     2039            <border>5</border> 
     2040          </object> 
     2041          <object class="sizeritem"> 
     2042            <object class="wxStaticText"> 
     2043              <label>second(s)</label> 
     2044            </object> 
     2045            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2046            <border>5</border> 
     2047          </object> 
     2048          <cols>3</cols> 
     2049          <object class="sizeritem"> 
     2050            <object class="wxStaticText"> 
     2051              <label>Delay after page dirty:</label> 
     2052            </object> 
     2053            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2054            <border>5</border> 
     2055          </object> 
     2056          <object class="sizeritem"> 
     2057            <object class="wxTextCtrl" name="tfAutoSaveDelayDirty"/> 
     2058            <flag>wxALL|wxEXPAND</flag> 
     2059            <border>5</border> 
     2060          </object> 
     2061          <object class="sizeritem"> 
     2062            <object class="wxStaticText"> 
     2063              <label>second(s)</label> 
     2064            </object> 
     2065            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2066            <border>5</border> 
     2067          </object> 
     2068        </object> 
     2069        <option>0</option> 
     2070        <flag>wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    20432071      </object> 
    20442072    </object> 
     
    21522180      </object> 
    21532181      <object class="sizeritem"> 
     2182        <object class="wxStaticLine"/> 
     2183        <option>0</option> 
     2184        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2185      </object> 
     2186      <object class="sizeritem"> 
     2187        <object class="wxFlexGridSizer"> 
     2188          <cols>2</cols> 
     2189          <growablecols>1</growablecols> 
     2190          <object class="sizeritem"> 
     2191            <object class="wxStaticText"> 
     2192              <label>Wiki icon:</label> 
     2193            </object> 
     2194            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2195            <border>5</border> 
     2196          </object> 
     2197          <object class="sizeritem"> 
     2198            <object class="wxTextCtrl" name="tfWikiIcon"/> 
     2199            <flag>wxALL|wxEXPAND</flag> 
     2200            <border>5</border> 
     2201          </object> 
     2202          <object class="sizeritem"> 
     2203            <object class="wxStaticText"> 
     2204              <label>Wiki-bound hotkey:</label> 
     2205            </object> 
     2206            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2207            <border>5</border> 
     2208          </object> 
     2209          <object class="sizeritem"> 
     2210            <object class="wxTextCtrl" name="tfHotKeyShowHideByWiki"/> 
     2211            <flag>wxALL|wxEXPAND</flag> 
     2212            <border>5</border> 
     2213          </object> 
     2214          <object class="sizeritem"> 
     2215            <object class="wxStaticText"> 
     2216              <label>Wiki language:</label> 
     2217            </object> 
     2218            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2219            <border>5</border> 
     2220          </object> 
     2221          <object class="sizeritem"> 
     2222            <object class="wxChoice" name="chWikiWikiLanguage"> 
     2223              <content/> 
     2224            </object> 
     2225            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2226            <border>5</border> 
     2227          </object> 
     2228        </object> 
     2229        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2230      </object> 
     2231    </object> 
     2232  </object> 
     2233  <object class="wxPanel" name="OptionsPageCwHeadings"> 
     2234    <object class="wxBoxSizer"> 
     2235      <orient>wxVERTICAL</orient> 
     2236      <object class="sizeritem"> 
    21542237        <object class="wxStaticText" name=""> 
    2155           <label>Title of new pages</label> 
     2238          <label>Heading of new pages</label> 
    21562239          <font> 
    21572240            <size>8</size> 
     
    21722255          <object class="sizeritem"> 
    21732256            <object class="wxStaticText"> 
    2174               <label>Title prefix:</label> 
     2257              <label>Heading prefix:</label> 
    21752258            </object> 
    21762259            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     
    21842267          <object class="sizeritem"> 
    21852268            <object class="wxStaticText"> 
    2186               <label>Wiki word to title:</label> 
     2269              <label>Wiki word to heading:</label> 
    21872270            </object> 
    21882271            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     
    22172300        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    22182301      </object> 
     2302      <object class="spacer"> 
     2303        <size>0,5</size> 
     2304      </object> 
     2305      <object class="sizeritem"> 
     2306        <object class="wxStaticText" name=""> 
     2307          <label>Headings as aliases</label> 
     2308          <font> 
     2309            <size>8</size> 
     2310            <style>default</style> 
     2311            <weight>bold</weight> 
     2312            <family>normal</family> 
     2313            <underlined>0</underlined> 
     2314          </font> 
     2315        </object> 
     2316        <option>0</option> 
     2317        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2318        <border>5</border> 
     2319      </object> 
    22192320      <object class="sizeritem"> 
    22202321        <object class="wxBoxSizer"> 
    22212322          <orient>wxHORIZONTAL</orient> 
     2323          <object class="sizeritem"> 
     2324            <object class="wxStaticText"> 
     2325              <label>Up to heading depth:</label> 
     2326            </object> 
     2327            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2328            <border>5</border> 
     2329          </object> 
     2330          <object class="sizeritem"> 
     2331            <object class="wxSpinCtrl" name="scHeadingsAsAliasesDepth"> 
     2332              <value>0</value> 
     2333              <min>0</min> 
     2334              <max>15</max> 
     2335            </object> 
     2336            <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     2337            <border>5</border> 
     2338          </object> 
    22222339        </object> 
    22232340        <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    22242341      </object> 
    2225       <object class="sizeritem"> 
    2226         <object class="wxFlexGridSizer"> 
    2227           <cols>2</cols> 
    2228           <growablecols>1</growablecols> 
    2229           <object class="sizeritem"> 
    2230             <object class="wxStaticText"> 
    2231               <label>Wiki icon:</label> 
    2232             </object> 
    2233             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    2234             <border>5</border> 
    2235           </object> 
    2236           <object class="sizeritem"> 
    2237             <object class="wxTextCtrl" name="tfWikiIcon"/> 
    2238             <flag>wxALL|wxEXPAND</flag> 
    2239             <border>5</border> 
    2240           </object> 
    2241           <object class="sizeritem"> 
    2242             <object class="wxStaticText"> 
    2243               <label>Wiki-bound hotkey:</label> 
    2244             </object> 
    2245             <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    2246             <border>5</border> 
    2247           </object> 
    2248           <object class="sizeritem"> 
    2249             <object class="wxTextCtrl" name="tfHotKeyShowHideByWiki"/> 
    2250             <flag>wxALL|wxEXPAND</flag> 
    2251             <border>5</border> 
    2252           </object> 
    2253         </object> 
    2254         <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
    2255       </object> 
    22562342    </object> 
    22572343  </object> 
    2258   <object class="wxPanel" name="OptionsPageCwFileStorage"> 
     2344  <object class="wxPanel" name="OptionsPageCwAdvanced"> 
    22592345    <object class="wxBoxSizer"> 
    22602346      <orient>wxVERTICAL</orient> 
     
    50015087    </object> 
    50025088  </object> 
     5089  <object class="wxDialog" name="NewWikiSettingsDialog"> 
     5090    <title>Basic wiki settings</title> 
     5091    <centered>1</centered> 
     5092    <style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style> 
     5093    <object class="wxBoxSizer"> 
     5094      <orient>wxVERTICAL</orient> 
     5095      <object class="sizeritem"> 
     5096        <object class="wxStaticText"> 
     5097          <label>Database type:</label> 
     5098            </object> 
     5099        <flag>wxALL|wxEXPAND</flag> 
     5100        <border>5</border> 
     5101          </object> 
     5102      <object class="sizeritem"> 
     5103        <object class="wxListBox" name="lbDatabaseType"> 
     5104          <content/> 
     5105        </object> 
     5106        <option>1</option> 
     5107        <flag>wxALL|wxEXPAND</flag> 
     5108        <border>5</border> 
     5109      </object> 
     5110      <object class="sizeritem"> 
     5111        <object class="wxStaticLine"/> 
     5112        <option>0</option> 
     5113        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     5114        <border>5</border> 
     5115      </object> 
     5116      <object class="sizeritem"> 
     5117        <object class="wxStaticText"> 
     5118          <label>Wiki language:</label> 
     5119            </object> 
     5120        <flag>wxALL|wxEXPAND</flag> 
     5121        <border>5</border> 
     5122          </object> 
     5123      <object class="sizeritem"> 
     5124        <object class="wxListBox" name="lbWikiLanguage"> 
     5125          <content/> 
     5126        </object> 
     5127        <option>1</option> 
     5128        <flag>wxALL|wxEXPAND</flag> 
     5129        <border>5</border> 
     5130      </object> 
     5131      <object class="sizeritem"> 
     5132        <object class="wxStaticText"> 
     5133          <label>(Use selected defaults if you are unsure)</label> 
     5134            </object> 
     5135        <flag>wxALL|wxEXPAND</flag> 
     5136        <border>5</border> 
     5137          </object> 
     5138      <object class="sizeritem"> 
     5139        <object class="wxBoxSizer"> 
     5140          <orient>wxHORIZONTAL</orient> 
     5141          <object class="sizeritem"> 
     5142            <object class="wxButton" name="btnOk"> 
     5143              <label>OK</label> 
     5144              <default>1</default> 
     5145              <style></style> 
     5146            </object> 
     5147            <flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag> 
     5148            <border>5</border> 
     5149          </object> 
     5150          <object class="sizeritem"> 
     5151            <object class="wxButton" name="btnCancel"> 
     5152              <label>Cancel</label> 
     5153            </object> 
     5154            <flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag> 
     5155            <border>5</border> 
     5156          </object> 
     5157        </object> 
     5158        <option>0</option> 
     5159        <flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag> 
     5160      </object> 
     5161    </object> 
     5162  </object> 
    50035163  <object class="wxPanel" name="LogWindow"> 
    50045164    <object class="wxBoxSizer"> 
  • branches/mbutscher/next/WikidPadStarter.py

    r174 r178  
    11#!/bin/python 
    22 
    3 import sys, os, traceback, os.path, glob, shutil 
     3import sys, os, traceback, os.path, glob, shutil, imp, warnings 
    44os.stat_float_times(True) 
    55 
     
    88#     sys.path.append(r"C:\Daten\Projekte\Wikidpad\Next20\lib") 
    99 
     10 
     11# Switch off warnings about my special import management 
     12warnings.simplefilter('ignore', RuntimeWarning) 
     13 
     14 
     15_realImport = __builtins__["__import__"] 
     16 
     17def _retrieveModule(nameComps, path): 
     18    """ 
     19    Returns <module>, <subPath (if package)> 
     20    """ 
     21    if sys.modules.has_key(".".join(nameComps)): 
     22        foundModule = sys.modules[".".join(nameComps)]  # ??? 
     23    else: 
     24        foundModule = None 
     25 
     26     
     27    if len(nameComps) == 0: 
     28        f, impPath, desc = imp.find_module("__init__", [path]) 
     29    else: 
     30#         print "--_retrieveModule13", repr((nameComps, path)) 
     31        try: 
     32            f, impPath, desc = imp.find_module(nameComps[-1], [path]) 
     33#             print "--_retrieveModule15", repr((f, impPath, desc)) 
     34        finally: 
     35            pass 
     36 
     37    if desc[2] == imp.SEARCH_ERROR: 
     38#         print "--_retrieveModule27" 
     39        raise ImportError 
     40 
     41    if desc[2] != imp.PKG_DIRECTORY: 
     42        if foundModule is not None: 
     43            f.close() 
     44            return foundModule, None 
     45 
     46        try: 
     47#             print "--_retrieveModule32" 
     48            module = imp.load_module(".".join(nameComps), f, impPath, 
     49                    desc) 
     50#             print "--_retrieveModule34" 
     51            sys.modules[".".join(nameComps)] = module 
     52#             print "--_retrieveModule36" 
     53            return module, None 
     54        finally: 
     55            if f is not None: 
     56                f.close() 
     57    else: 
     58        path = impPath 
     59        if foundModule is not None: 
     60            return foundModule, path 
     61 
     62        f, impPath, desc = imp.find_module("__init__", [path]) 
     63        try: 
     64            module = imp.load_module(".".join(nameComps), f, impPath, 
     65                    desc) 
     66            sys.modules[".".join(nameComps)] = module 
     67            return module, path 
     68        finally: 
     69            if f is not None: 
     70                f.close() 
     71 
     72 
     73 
     74def _retrieveFinalModule(modComps, path, importComps): 
     75    if importComps == [""]: 
     76        importComps = [] 
     77 
     78#     print "--_retrieveFinalModule2", repr((modComps, importComps)) 
     79 
     80    if sys.modules.has_key(".".join(modComps + importComps)): 
     81#         print "--_retrieveFinalModule5" 
     82        module = sys.modules[".".join(modComps + importComps)] 
     83        return module, os.path.dirname(module.__file__)  # ??? 
     84 
     85    if sys.modules.has_key(".".join(modComps)): 
     86        module = sys.modules[".".join(modComps)]  # ??? 
     87    else: 
     88        f, impPath, desc = imp.find_module("__init__", [path]) 
     89        try: 
     90            module = imp.load_module(".".join(modComps), f, impPath, 
     91                    desc) 
     92            sys.modules[".".join(modComps)] = module 
     93        finally: 
     94            if f is not None: 
     95                f.close() 
     96 
     97#     print "--_retrieveFinalModule14", repr((modComps, importComps, path)) 
     98 
     99    if len(importComps) == 0: 
     100        return module, path 
     101 
     102    while len(importComps) > 0: 
     103        parentModule = module 
     104 
     105#         print "--_retrieveFinalModule33", repr((modComps + importComps[:1], path)) 
     106        module, nextPath = _retrieveModule(modComps + importComps[:1], path) 
     107#         print "--_retrieveFinalModule35", repr((module, nextPath)) 
     108        if module is None: 
     109            raise ImportError()  # TODO Own error message 
     110 
     111        if not parentModule.__dict__.has_key(importComps[0]): 
     112            parentModule.__dict__[importComps[0]] = module 
     113 
     114        path = nextPath 
     115        modComps.append(importComps[0]) 
     116        del importComps[0] 
     117 
     118        if nextPath is None: 
     119            if len(importComps) != 0: 
     120                raise ImportError()  # TODO Own error message 
     121 
     122            return module, path 
     123 
     124 
     125    return module, path 
     126 
     127 
     128 
     129def _newImport(name, globals=None, locals=None, fromlist=None, level=-1): 
     130    """ 
     131    Replaces the internal __import__ function to allow relaxed checks for 
     132    relative imports in plugins. 
     133    """ 
     134    if level <= 0: 
     135        return _realImport(name, globals, locals, fromlist, level) 
     136     
     137#         print "--import", repr((name, globals.get("__name__") if globals is not None else None, 
     138#                 globals.get("__file__") if globals is not None else None, fromlist, level)) 
     139 
     140#     except ImportError, ie: 
     141 
     142    modComps = globals["__name__"].split(".") 
     143    if not modComps[0].startswith("cruelimport"): # a tag to recognize 
     144        return _realImport(name, globals, locals, fromlist, level) 
     145     
     146    imp.acquire_lock() 
     147    try: 
     148#         print "--_newImport4", repr((name, globals.get("__name__") if globals is not None else None, 
     149#                 globals.get("__file__") if globals is not None else None, fromlist, level)) 
     150 
     151        ilevel = level 
     152        path = globals["__file__"] 
     153 
     154        while ilevel > 0 and len(modComps) > 0: 
     155            path = os.path.dirname(path) 
     156            del modComps[-1] 
     157            ilevel -= 1 
     158 
     159        if ilevel > 0: 
     160            raise 
     161         
     162        if not fromlist:   # is this possible? 
     163            raise ie 
     164 
     165        # if len(modComps) == 0: 
     166            # do ? 
     167        importComps = name.split(".") 
     168        if importComps == [""]: 
     169            importComps = [] 
     170             
     171#         print "--_newImport27", repr((modComps, path, importComps)) 
     172 
     173        module, path = _retrieveFinalModule(modComps, path, importComps) 
     174         
     175#         print "--_newImport29", repr((module, path)) 
     176 
     177        for frm in fromlist: 
     178            if frm == "*": 
     179                continue 
     180            if not module.__dict__.has_key(frm): 
     181                try: 
     182#                     print "--_newImport34", repr((modComps, frm, path)) 
     183                    submod = _retrieveModule(modComps + [frm], path) 
     184#                     print "--_newImport37", repr(submod) 
     185                    module.__dict__[frm] = submod 
     186                except ImportError: 
     187#                     print "--_newImport42" 
     188                    pass 
     189 
     190#         print "--_newImport49", repr((module, path)) 
     191 
     192        return module 
     193    except: 
     194        traceback.print_exc() 
     195        raise 
     196    finally: 
     197        imp.release_lock() 
     198 
     199 
     200 
     201__builtins__["__import__"] = _newImport 
    10202 
    11203from Consts import VERSION_STRING, VERSION_TUPLE 
     
    22214 
    23215 
    24 # create a Trace object, telling it what to ignore, and whether to 
    25 # do tracing or line-counting or both. 
     216# create a Trace object 
    26217import trace 
    27218__builtins__["tracer"] = trace.Trace( 
     
    29220    trace=1, 
    30221    count=0) 
    31  
    32  
    33222 
    34223 
  • branches/mbutscher/next/extensions/autoNew.py

    r174 r178  
    5656    kb = wiki.getKeyBindings() 
    5757     
    58     return ((autoNewNumbered, _(u"Maintain|Create new page") + u"\t" + 
     58    return ((autoNewNumbered, _(u"Create new page") + u"\t" + 
    5959            kb.Plugin_AutoNew_Numbered, _(u"Create new page")),) 
    6060 
  • branches/mbutscher/next/lib/pwiki/AdditionalDialogs.py

    r174 r178  
    1818from StringOps import uniToGui, guiToUni, mbcsEnc, mbcsDec, \ 
    1919        escapeForIni, unescapeForIni, escapeHtml, strftimeUB, pathEnc 
     20from wikidata import DbBackendUtils 
     21 
    2022from WikiExceptions import * 
    2123import Exporters, Importers 
     
    3133    Called for "Append/Prepend wiki word" in tree node context menu 
    3234    """ 
    33  
    3435    def __init__(self, pWiki, parent, ID, title=u"Select Wiki Word", 
    3536                 pos=wx.DefaultPosition, size=wx.DefaultSize, 
     
    409410        self.activateSelectedWikiWords(3) 
    410411 
    411  
    412412OpenWikiWordDialog.runModal = staticmethod(runDialogModalFactory(OpenWikiWordDialog)) 
    413413 
     414 
     415 
     416class ChooseWikiWordDialog(wx.Dialog): 
     417    """ 
     418    Used to allow selection from list of parents, parentless words, children 
     419    or bookmarked words. 
     420    """ 
     421    def __init__(self, pWiki, ID, words, motionType, title="Choose Wiki Word", 
     422                 pos=wx.DefaultPosition, size=wx.DefaultSize): 
     423        d = wx.PreDialog() 
     424        self.PostCreate(d) 
     425         
     426        self.pWiki = pWiki 
     427        res = wx.xrc.XmlResource.Get() 
     428        res.LoadOnDialog(self, self.pWiki, "ChooseWikiWordDialog") 
     429         
     430        self.ctrls = XrcControls(self) 
     431         
     432        self.SetTitle(title) 
     433        self.ctrls.staTitle.SetLabel(title) 
     434         
     435        self.motionType = motionType 
     436        self.words = words 
     437        wordsgui = map(uniToGui, words) 
     438         
     439        self.ctrls.lb.Set(wordsgui) 
     440 
     441        self.ctrls.btnOk.SetId(wx.ID_OK) 
     442        self.ctrls.btnCancel.SetId(wx.ID_CANCEL) 
     443         
     444        # Fixes focus bug under Linux 
     445        self.SetFocus() 
     446 
     447        wx.EVT_BUTTON(self, GUI_ID.btnDelete, self.OnDelete) 
     448        wx.EVT_BUTTON(self, GUI_ID.btnNewTab, self.OnNewTab) 
     449        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk) 
     450        wx.EVT_LISTBOX_DCLICK(self, GUI_ID.lb, self.OnOk) 
     451 
     452 
     453    def OnDelete(self, evt): 
     454        sellen = len(self.ctrls.lb.GetSelections()) 
     455        if sellen > 0: 
     456            answer = wx.MessageBox( 
     457                    _(u"Do you want to delete %i wiki page(s)?") % sellen, 
     458                    (u"Delete Wiki Page(s)"), 
     459                    wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION, self) 
     460 
     461            if answer != wx.YES: 
     462                return 
     463 
     464            self.pWiki.saveAllDocPages() 
     465            for s in self.ctrls.lb.GetSelections(): 
     466                delword = self.words[s] 
     467                # Un-alias word 
     468                delword = self.pWiki.getWikiData().getUnAliasedWikiWord(delword) 
     469 
     470                if delword is not None: 
     471                    page = self.pWiki.getWikiDocument().getWikiPage(delword) 
     472                    page.deletePage() 
     473                     
     474                    # self.pWiki.getWikiData().deleteWord(delword) 
     475         
     476                    # trigger hooks 
     477                    self.pWiki.hooks.deletedWikiWord(self.pWiki, delword) 
     478                     
     479#             self.pWiki.pageHistory.goAfterDeletion() 
     480 
     481            self.EndModal(wx.ID_OK) 
     482 
     483 
     484    def OnOk(self, evt): 
     485        self.activateSelected(False) 
     486#         sels = self.ctrls.lb.GetSelections() 
     487#         if len(sels) != 1: 
     488#             return # We can only go to exactly one wiki word 
     489#              
     490#         wikiWord = self.words[sels[0]] 
     491#         try: 
     492#             self.pWiki.openWikiPage(wikiWord, forceTreeSyncFromRoot=True, 
     493#                     motionType=self.motionType) 
     494#         finally: 
     495#             self.EndModal(GUI_ID.btnDelete) 
     496 
     497 
     498    def OnNewTab(self, evt): 
     499        self.activateSelected(True) 
     500 
     501         
     502    def activateSelected(self, allNewTabs): 
     503        """ 
     504        allNewTabs -- True: All selected words go to newly created tabs, 
     505                False: The first selected word changes current tab 
     506        """ 
     507        selIdxs = self.ctrls.lb.GetSelections() 
     508        if len(selIdxs) == 0: 
     509            return 
     510 
     511        try: 
     512            if not allNewTabs: 
     513                self.pWiki.openWikiPage(self.words[selIdxs[0]], 
     514                        forceTreeSyncFromRoot=True, motionType=self.motionType) 
     515 
     516                selWords = [self.words[idx] for idx in selIdxs[1:]] 
     517            else: 
     518                selWords = [self.words[idx] for idx in selIdxs] 
     519 
     520            for word in selWords: 
     521                self.pWiki.activatePageByUnifiedName(u"wikipage/" + word, 2) 
     522        finally: 
     523            self.EndModal(wx.ID_OK) 
     524 
     525  
    414526  
    415527 
     
    12361348 
    12371349 
    1238 class ChooseWikiWordDialog(wx.Dialog): 
    1239     """ 
    1240     Used to allow selection from list of parents, parentless words, children 
    1241     or bookmarked words. 
    1242     """ 
    1243     def __init__(self, pWiki, ID, words, motionType, title="Choose Wiki Word", 
    1244                  pos=wx.DefaultPosition, size=wx.DefaultSize): 
    1245         d = wx.PreDialog() 
    1246         self.PostCreate(d) 
    1247          
    1248         self.pWiki = pWiki 
    1249         res = wx.xrc.XmlResource.Get() 
    1250         res.LoadOnDialog(self, self.pWiki, "ChooseWikiWordDialog") 
    1251          
    1252         self.ctrls = XrcControls(self) 
    1253          
    1254         self.SetTitle(title) 
    1255         self.ctrls.staTitle.SetLabel(title) 
    1256          
    1257         self.motionType = motionType 
    1258         self.words = words 
    1259         wordsgui = map(uniToGui, words) 
    1260          
    1261         self.ctrls.lb.Set(wordsgui) 
    1262  
    1263         self.ctrls.btnOk.SetId(wx.ID_OK) 
    1264         self.ctrls.btnCancel.SetId(wx.ID_CANCEL) 
    1265          
    1266         # Fixes focus bug under Linux 
    1267         self.SetFocus() 
    1268  
    1269         wx.EVT_BUTTON(self, GUI_ID.btnDelete, self.OnDelete) 
    1270         wx.EVT_BUTTON(self, GUI_ID.btnNewTab, self.OnNewTab) 
    1271         wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk) 
    1272         wx.EVT_LISTBOX_DCLICK(self, GUI_ID.lb, self.OnOk) 
    1273  
    1274  
    1275     def OnDelete(self, evt): 
    1276         sellen = len(self.ctrls.lb.GetSelections()) 
    1277         if sellen > 0: 
    1278             answer = wx.MessageBox( 
    1279                     _(u"Do you want to delete %i wiki page(s)?") % sellen, 
    1280                     (u"Delete Wiki Page(s)"), 
    1281                     wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION, self) 
    1282  
    1283             if answer != wx.YES: 
    1284                 return 
    1285  
    1286             self.pWiki.saveAllDocPages() 
    1287             for s in self.ctrls.lb.GetSelections(): 
    1288                 delword = self.words[s] 
    1289                 # Un-alias word 
    1290                 delword = self.pWiki.getWikiData().getUnAliasedWikiWord(delword) 
    1291  
    1292                 if delword is not None: 
    1293                     page = self.pWiki.getWikiDocument().getWikiPage(delword) 
    1294                     page.deletePage() 
    1295                      
    1296                     # self.pWiki.getWikiData().deleteWord(delword) 
    1297          
    1298                     # trigger hooks 
    1299                     self.pWiki.hooks.deletedWikiWord(self.pWiki, delword) 
    1300                      
    1301 #             self.pWiki.pageHistory.goAfterDeletion() 
    1302  
    1303             self.EndModal(wx.ID_OK) 
    1304  
    1305  
    1306     def OnOk(self, evt): 
    1307         self.activateSelected(False) 
    1308 #         sels = self.ctrls.lb.GetSelections() 
    1309 #         if len(sels) != 1: 
    1310 #             return # We can only go to exactly one wiki word 
    1311 #              
    1312 #         wikiWord = self.words[sels[0]] 
    1313 #         try: 
    1314 #             self.pWiki.openWikiPage(wikiWord, forceTreeSyncFromRoot=True, 
    1315 #                     motionType=self.motionType) 
    1316 #         finally: 
    1317 #             self.EndModal(GUI_ID.btnDelete) 
    1318  
    1319  
    1320     def OnNewTab(self, evt): 
    1321         self.activateSelected(True) 
    1322  
    1323          
    1324     def activateSelected(self, allNewTabs): 
    1325         """ 
    1326         allNewTabs -- True: All selected words go to newly created tabs, 
    1327                 False: The first selected word changes current tab 
    1328         """ 
    1329         selIdxs = self.ctrls.lb.GetSelections() 
    1330         if len(selIdxs) == 0: 
    1331             return 
    1332  
    1333         try: 
    1334             if not allNewTabs: 
    1335                 self.pWiki.openWikiPage(self.words[selIdxs[0]], 
    1336                         forceTreeSyncFromRoot=True, motionType=self.motionType) 
    1337  
    1338                 selWords = [self.words[idx] for idx in selIdxs[1:]] 
    1339             else: 
    1340                 selWords = [self.words[idx] for idx in selIdxs] 
    1341  
    1342             for word in selWords: 
    1343                 self.pWiki.activatePageByUnifiedName(u"wikipage/" + word, 2) 
    1344         finally: 
    1345             self.EndModal(wx.ID_OK) 
    1346  
    1347  
    1348  
    13491350def _children(win, indent=0): 
    13501351    print " " * indent + repr(win), win.GetId() 
    13511352    for c in win.GetChildren(): 
    13521353        _children(c, indent=indent+2) 
     1354 
     1355 
     1356 
     1357class NewWikiSettings(wx.Dialog): 
     1358    """ 
     1359    Dialog to choose options when creating a new wiki or when a wiki with 
     1360    damaged configuration file is opened. 
     1361    """ 
     1362    DEFAULT_GREY = 1 
     1363 
     1364    def __init__(self, parent, ID, mainControl, defDbHandler=None, 
     1365            defWikiLang=None, title="", pos=wx.DefaultPosition, 
     1366            size=wx.DefaultSize): 
     1367        d = wx.PreDialog() 
     1368        self.PostCreate(d) 
     1369 
     1370        self.mainControl = mainControl 
     1371        self.value = None, None 
     1372 
     1373#         self.listPagesOperation = ListWikiPagesOperation() 
     1374        res = wx.xrc.XmlResource.Get() 
     1375        res.LoadOnDialog(self, parent, "NewWikiSettingsDialog") 
     1376 
     1377        self.ctrls = XrcControls(self) 
     1378 
     1379        # Retrieve lists of db backends and wiki languages 
     1380        self.dbHandlers = DbBackendUtils.listHandlers() 
     1381        self.wikiLanguages = wx.GetApp().listWikiLanguageDescriptions() 
     1382 
     1383        errMsg = "" 
     1384 
     1385        if len(self.dbHandlers) == 0: 
     1386            errMsg += 'No data handler available' 
     1387        if len(self.wikiLanguages) == 0: 
     1388            errMsg += 'No wiki language handler available' 
     1389 
     1390        if errMsg: 
     1391            self.mainControl.displayErrorMessage(errMsg) 
     1392            self.EndModal(wx.ID_CANCEL) 
     1393            return 
     1394 
     1395        if defDbHandler is not NewWikiSettings.DEFAULT_GREY: 
     1396            self.ctrls.lbDatabaseType.Set([h[1] for h in self.dbHandlers]) 
     1397            for i, h in enumerate(self.dbHandlers): 
     1398                if h[0] == defDbHandler: 
     1399                    self.ctrls.lbDatabaseType.SetSelection(i) 
     1400                    break 
     1401            else: 
     1402                self.ctrls.lbDatabaseType.SetSelection(0) 
     1403        else: 
     1404            self.ctrls.lbDatabaseType.Enable(False) 
     1405            self.ctrls.lbDatabaseType.SetBackgroundColour(wx.LIGHT_GREY) 
     1406 
     1407        if defWikiLang is not NewWikiSettings.DEFAULT_GREY: 
     1408            self.ctrls.lbWikiLanguage.Set([l[1] for l in self.wikiLanguages]) 
     1409            for i, l in enumerate(self.wikiLanguages): 
     1410                if l[0] == defWikiLang: 
     1411                    self.ctrls.lbWikiLanguage.SetSelection(i) 
     1412                    break 
     1413            else: 
     1414                self.ctrls.lbWikiLanguage.SetSelection(0) 
     1415        else: 
     1416            self.ctrls.lbWikiLanguage.Enable(False) 
     1417            self.ctrls.lbWikiLanguage.SetBackgroundColour(wx.LIGHT_GREY) 
     1418 
     1419        self.ctrls.btnOk.SetId(wx.ID_OK) 
     1420        self.ctrls.btnCancel.SetId(wx.ID_CANCEL) 
     1421 
     1422        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk) 
     1423 
     1424 
     1425    def GetValue(self): 
     1426        return self.value 
     1427 
     1428    def OnOk(self, evt): 
     1429        dbSel = self.ctrls.lbDatabaseType.GetSelection() 
     1430        langSel = self.ctrls.lbWikiLanguage.GetSelection() 
     1431         
     1432        dbH = None 
     1433        wlH = None 
     1434         
     1435        if dbSel != wx.NOT_FOUND: 
     1436            dbH = self.dbHandlers[dbSel][0] 
     1437        if langSel != wx.NOT_FOUND: 
     1438            wlH = self.wikiLanguages[langSel][0] 
     1439         
     1440        self.value = dbH, wlH 
     1441 
     1442        self.EndModal(wx.ID_OK) 
     1443 
     1444NewWikiSettings.runModal = staticmethod(runDialogModalFactory(NewWikiSettings)) 
     1445 
    13531446 
    13541447 
  • branches/mbutscher/next/lib/pwiki/Configuration.py

    r175 r178  
    613613 
    614614    # Editor options 
    615     ("main", "sync_highlight_byte_limit"): "5120",  # Size limit when to start asyn. highlighting in editor 
     615    ("main", "sync_highlight_byte_limit"): "400",  # Size limit when to start asyn. highlighting in editor 
    616616    ("main", "async_highlight_delay"): "0.2",  # Delay after keypress before starting async. highlighting 
    617617    ("main", "editor_shortHint_delay"): "500",  # Delay in milliseconds until the short hint defined for a wikiword is displayed 
     
    714714    ("main", "windowmode"): "0", 
    715715    ("main", "frame_stayOnTop"): "False",  # Should frame stay on top of all other windows? 
    716     ("main", "lowresources"): "0",   # The value must be a number, not a truth value! 
    717716    ("main", "showontray"): "0", 
    718717    ("main", "minimize_on_closeButton"): "False", # Minimize if the close button ("X") is pressed   
     
    735734    ("wiki_db", "data_dir"): u"data", 
    736735    ("main", "wiki_name"): None, 
     736    ("main", "wiki_wikiLanguage"): "wikidpad_default_2_0", # Internal name of wiki language of the wiki 
    737737    ("main", "last_wiki_word"): None, # Show this wiki word as leftmost wiki word on startup if first_wiki_word is empty 
    738738    ("main", "tree_last_root_wiki_word"): None, # Last root word of wiki tree 
     
    762762    ("main", "log_window_autoshow"): "Gray", # Automatically show log window if messages added? 
    763763 
     764    ("main", "headingsAsAliases_depth"): "0",  # Maximum heading depth for which aliases should be generated for 
     765            # each heading up to and including this depth. 
     766 
    764767    # For file storage (esp. identity check) 
    765768    ("main", "fileStorage_identity_modDateMustMatch"): "False",  # Modification date must match for file to be identical 
  • branches/mbutscher/next/lib/pwiki/DocPagePresenter.py

    r177 r178  
    215215        evtprops["addToHistory"] = addToHistory 
    216216        evtprops["forceTreeSyncFromRoot"] = forceTreeSyncFromRoot 
    217          
     217 
    218218        langHelper = wx.GetApp().createWikiLanguageHelper( 
    219219                self.getWikiDocument().getWikiDefaultWikiLanguage()) 
    220                  
    221         errMsg = langHelper.checkForInvalidWikiWord(wikiWord, 
    222                 self.getWikiDocument()) 
     220 
     221        errMsg = None 
     222 
     223        # The "if" ensures that existing pages can be opened even 
     224        # if syntax is (or became) incompatible 
     225        if not self.getWikiDocument().isDefinedWikiPage(wikiWord): 
     226            errMsg = langHelper.checkForInvalidWikiWord(wikiWord, 
     227                    self.getWikiDocument()) 
    223228 
    224229        if errMsg is not None: 
  • branches/mbutscher/next/lib/pwiki/DocPages.py

    r177 r178  
    482482                    self.liveTextPlaceHold = object() 
    483483 
     484    def checkFileSignatureAndMarkDirty(self, fireEvent=True): 
     485        return True 
    484486 
    485487 
     
    555557            if len(self.txtEditors) == 0: 
    556558                with self.textOperationLock: 
    557                     if self.isDefined() and not self.getWikiDocument()\ 
    558                             .checkFileSignatureForWikiWordAndMarkDirty( 
    559                             self.wikiWord): 
     559                    if not self.checkFileSignatureAndMarkDirty(): 
    560560                        self.initiateUpdate() 
    561561 
     
    765765                self.getWikiData().deleteWord(self.getWikiWord()) 
    766766 
    767             callInMainThreadAsync(self.fireMiscEventKeys, 
     767            wx.CallAfter(self.fireMiscEventKeys, 
    768768                    ("deleted page", "deleted wiki page")) 
    769769 
     
    787787 
    788788 
    789     def checkFileSignature(self): 
    790         """ 
    791         Check if file signature is valid and send an event if not 
    792         """ 
    793         with self.textOperationLock: 
    794             valid = self.getWikiData().validateFileSignatureForWord( 
    795                     self.wikiWord, setMetaDataDirty=False) 
    796                      
    797             if valid: 
    798                 return True 
    799  
    800             self.markMetaDataDirty() 
    801          
    802         callInMainThreadAsync(self.fireMiscEventKeys, 
    803                 ("checked file signature invalid",)) 
    804  
    805         return False 
     789#     def checkFileSignature(self): 
     790#         """ 
     791#         Check if file signature is valid and send an event if not 
     792#         """ 
     793#         with self.textOperationLock: 
     794#             if not self.isDefined(): 
     795#                 return True  # ? 
     796#  
     797#             valid = self.getWikiData().validateFileSignatureForWord( 
     798#                     self.wikiWord, setMetaDataDirty=False) 
     799#                      
     800#             if valid: 
     801#                 return True 
     802#  
     803#             self.markMetaDataDirty() 
     804#          
     805#         callInMainThreadAsync(self.fireMiscEventKeys, 
     806#                 ("checked file signature invalid",)) 
     807#  
     808#         return False 
    806809 
    807810 
     
    813816#             return self.getWikiData().validateFileSignatureForWord( 
    814817#                     self.wikiWord, setMetaDataDirty=True) 
     818 
     819 
     820    def checkFileSignatureAndMarkDirty(self, fireEvent=True): 
     821        """ 
     822        First checks if file signature is valid, if not, the 
     823        "metadataprocessed" field of the word is set to 0 to mark 
     824        meta-data as not up-to-date. At last the signature is 
     825        refreshed. 
     826         
     827        This all is done inside the lock of the WikiData so it is 
     828        somewhat atomically. 
     829        """ 
     830        with self.textOperationLock: 
     831            if self.wikiDocument.isReadOnlyEffect(): 
     832                return True  # TODO Error message? 
     833     
     834            if not self.isDefined(): 
     835                return True  # TODO Error message? 
     836     
     837            wikiData = self.getWikiData() 
     838            word = self.wikiWord 
     839 
     840            proxyAccessLock = getattr(wikiData, "proxyAccessLock", None) 
     841            if proxyAccessLock is not None: 
     842                proxyAccessLock.acquire() 
     843            try: 
     844                valid = wikiData.validateFileSignatureForWord(word) 
     845                 
     846                if valid: 
     847                    return True 
     848     
     849                wikiData.setMetaDataState(word, 
     850                        Consts.WIKIWORDMETADATA_STATE_DIRTY) 
     851                wikiData.refreshFileSignatureForWord(word) 
     852            finally: 
     853                if proxyAccessLock is not None: 
     854                    proxyAccessLock.release() 
     855 
     856            editor = self.getTxtEditor() 
     857         
     858        if editor is not None: 
     859            # TODO Check for deadlocks 
     860            callInMainThread(editor.handleInvalidFileSignature, self) 
     861 
     862        if fireEvent: 
     863            wx.CallAfter(self.fireMiscEventKeys, 
     864                    ("checked file signature invalid",)) 
     865 
     866        return False 
     867 
    815868 
    816869 
     
    10261079 
    10271080                pageAst = self.getLivePageAstIfAvailable() 
    1028 #                 if pageAst is not None: 
    1029 #                     return pageAst 
    1030  
    1031 #                 # Current state 
    1032 #                 text = self.getLiveText() 
    1033 #  
    1034 #                 # AST state 
    1035 #                 pageAst = self.livePageAst 
    1036 #                 baseText = self.livePageBaseText 
    1037 #                 baseFormatDetails = self.livePageBaseFormatDetails 
    1038 #  
    1039 #                 if pageAst is not None and len(text) == len(baseText) and \ 
    1040 #                         formatDetails.isEquivTo(baseFormatDetails) and \ 
    1041 #                         text == baseText: 
    1042 #                     return pageAst 
    10431081 
    10441082            if pageAst is not None: 
     
    10621100 
    10631101                self.livePageAst = pageAst 
    1064 #                     self.livePageBaseText = text 
    10651102                self.livePageBasePlaceHold = liveTextPlaceHold 
    10661103                self.livePageBaseFormatDetails = formatDetails 
    10671104 
    10681105 
    1069         # with self.textOperationLock: 
    1070 #             clt = time.clock() 
    10711106        if self.isReadOnlyEffect(): 
    10721107            threadstop.testRunning() 
    10731108            return pageAst 
    10741109 
    1075         if False and allowMetaDataUpdate:   # TODO: Option 
    1076             self._refreshMetaData(pageAst, formatDetails, fireEvent=fireEvent, 
    1077                     threadstop=threadstop) 
    1078  
    1079 #         self.refreshPropertiesFromPageAst(pageAst, threadstop=threadstop) 
    1080 #  
    1081 #         formatDetails2 = self.getFormatDetails() 
    1082 #         if not formatDetails.isEquivTo(formatDetails2): 
    1083 #             # Formatting details have changed -> stop and wait for 
    1084 #             # new round to update 
    1085 #             threadstop.testRunning() 
    1086 #             return pageAst 
    1087 #  
    1088 #         self.refreshMainDbCacheFromPageAst(pageAst, fireEvent=fireEvent, 
    1089 #                 threadstop=threadstop) 
    1090 #  
    1091 # #             print "--refreshTime14", repr(time.clock()-clt) 
    1092 #         with self.textOperationLock: 
    1093 #             threadstop.testRunning() 
    1094 #             if self.saveDirtySince is None: 
    1095 #                 self.getWikiData().setMetaDataProcessed(1) 
    1096 #                 self.updateDirtySince = None 
    1097 #  
    1098 #             return pageAst 
     1110#         if False and allowMetaDataUpdate:   # TODO: Option 
     1111#             self._refreshMetaData(pageAst, formatDetails, fireEvent=fireEvent, 
     1112#                     threadstop=threadstop) 
    10991113 
    11001114        with self.textOperationLock: 
     
    11421156        return self.refreshMainDbCacheFromPageAst(pageAst, fireEvent=fireEvent, 
    11431157                threadstop=threadstop) 
    1144  
    1145 #             print "--refreshTime14", repr(time.clock()-clt) 
    1146  
    1147  
    1148 #         with self.textOperationLock: 
    1149 #             threadstop.testRunning() 
    1150 #             if self.saveDirtySince is None: 
    1151 #                 self.getWikiData().setMetaDataProcessed(1) 
    1152 #                 self.updateDirtySince = None 
    1153 #                 return True 
    1154 #          
    1155 #             return False 
    11561158 
    11571159 
     
    11991201        for node in propNodes: 
    12001202            for propKey, propValue in node.props: 
    1201 #                 if propKey == u"alias": 
    1202 #                     if not langHelper.checkForInvalidWikiWord(propValue, 
    1203 #                             self.getWikiDocument()): 
    1204 #                          
    1205 #                         addProperty(u"alias", propValue) 
    1206 #                 else: 
    12071203                addProperty(propKey, propValue) 
    12081204 
     
    12101206            threadstop.testRunning() 
    12111207 
    1212 #             self.props = props 
    12131208            self.props = None 
    1214  
    1215 #             propAliases = self.props.get("alias") 
    1216 #             if propAliases is not None: 
    1217 #                 for alias in propAliases: 
    1218 #                     self.getWikiData().setAsAlias(alias) 
    12191209 
    12201210        try: 
     
    12741264                childRelationSet.add(toWord) 
    12751265 
    1276 #         for t in pageAst.iterDeep(): 
    1277 #             if t.name == "todoEntry": 
    1278 #                 addTodo(t.key + t.delimiter + t.valueNode.getString()) 
    1279 #             elif t.name == "wikiWord": 
    1280 #                 addChildRelationship(t.wikiWord, t.pos) 
    1281  
     1266        # Add todo entries 
    12821267        todoTokens = pageAst.iterDeepByName("todoEntry") 
    12831268        for t in todoTokens: 
     
    12861271        threadstop.testRunning() 
    12871272 
     1273        # Add child relations 
    12881274        wwTokens = pageAst.iterDeepByName("wikiWord") 
    12891275        for t in wwTokens: 
     
    12921278        threadstop.testRunning() 
    12931279         
    1294 #         matchTerms = [(self.wikiWord, 0, self.wikiWord, -1)] 
     1280        # Add aliases to match terms 
    12951281        matchTerms = [] 
    12961282 
     
    13091295                matchTerms.append((v, ALIAS_TYPE, self.wikiWord, -1)) 
    13101296 
    1311         with self.textOperationLock: 
    1312             clt = time.clock() 
     1297        # Add headings to match terms if wanted 
     1298        depth = self.wikiDocument.getWikiConfig().getint( 
     1299                "main", "headingsAsAliases_depth") 
     1300 
     1301        if depth > 0: 
     1302            HEADALIAS_TYPE = Consts.WIKIWORDMATCHTERMS_TYPE_FROM_CONTENT 
     1303            for node in pageAst.iterFlatByName("heading"): 
     1304                threadstop.testRunning() 
     1305                if node.level > depth: 
     1306                    continue 
     1307 
     1308                title = node.getString() 
     1309                if title.endswith(u"\n"): 
     1310                    title = title[:-1] 
     1311                 
     1312                matchTerms.append((title, HEADALIAS_TYPE, self.wikiWord, 
     1313                        node.pos)) 
     1314 
     1315        with self.textOperationLock: 
    13131316            threadstop.testRunning() 
    13141317 
    1315 #             self.todos = todos 
    1316 #             self.childRelations = childRelations 
    1317 #             self.childRelationSet = childRelationSet 
    13181318            self.todos = None 
    13191319            self.childRelations = None 
  • branches/mbutscher/next/lib/pwiki/DocStructureCtrl.py

    r177 r178  
    106106 
    107107         
    108 #         if oldSizeVisible: 
    109 #             self.docPagePresenterSink.disconnect() 
    110 #         else: 
    111 #             self.docPagePresenterSink.setEventSource( 
    112 #                     self.mainControl.getCurrentDocPagePresenter().getMiscEvent()) 
    113 #             self.updateList() 
    114  
    115  
    116108    def miscEventHappened(self, miscevt): 
    117109        """ 
  • branches/mbutscher/next/lib/pwiki/Exporters.py

    r174 r178  
    15921592                self.outAppend(u"<pre>%s</pre>\n" % 
    15931593                        escapeHtmlNoBreaks( 
    1594                         mode.findFlatByName("preText").getString()), True, 
     1594                        node.findFlatByName("preText").getString()), True, 
    15951595                        not self.asIntHtmlPreview) 
    15961596                if self.asIntHtmlPreview: 
  • branches/mbutscher/next/lib/pwiki/Localization.py

    r173 r178  
    504504            return 
    505505         
     506        if findLangListIndex(locEntry) == -1: 
     507            continue 
     508 
    506509        path = os.path.join(appDir, "WikidPad_" + locEntry + ".po") 
    507510        if not os.path.exists(pathEnc(path)): 
    508511            continue 
    509          
     512 
    510513        try: 
    511514            md = buildMessageDict(path) 
  • branches/mbutscher/next/lib/pwiki/MainApp.py

    r169 r178  
    213213        Localization.loadI18nDict(self.wikiAppDir, self.globalConfig.get( 
    214214                "main", "gui_language", u"")) 
    215  
    216         self.lowResources = self.globalConfig.getboolean("main", "lowresources") 
    217215 
    218216        if self.globalConfig.getboolean("main", "single_process"): 
     
    309307        # Build icon cache 
    310308        iconDir = os.path.join(self.wikiAppDir, "icons") 
    311         self.iconCache = IconCache(iconDir, self.lowResources) 
    312          
     309        self.iconCache = IconCache(iconDir) 
     310 
    313311        # Create plugin manager for application-wide plugins 
    314         self.pluginManager = PluginManager() 
     312        dirs = ( os.path.join(self.globalConfigSubDir, u'user_extensions'), 
     313                os.path.join(self.wikiAppDir, u'user_extensions'), 
     314                os.path.join(self.wikiAppDir, u'extensions') ) 
     315        self.pluginManager = PluginManager(dirs) 
    315316 
    316317        # Register app-wide plugin APIs 
     
    321322                ("Options", 1), ("registerOptions",)) 
    322323 
    323         describeWikiParserApi = self.pluginManager.registerPluginAPI( 
    324                 ("WikiParser", 1), ("describeWikiParser",)) 
     324        describeWikiLanguageApi = self.pluginManager.registerPluginAPI( 
     325                ("WikiParser", 1), ("describeWikiLanguage",)) 
    325326 
    326327        # Load plugins 
    327328#         dirs = ( os.path.join(self.wikiAppDir, u'user_extensions'), 
    328329#                 os.path.join(self.wikiAppDir, u'extensions') ) 
    329         dirs = ( os.path.join(self.globalConfigSubDir, u'user_extensions'), 
    330                 os.path.join(self.wikiAppDir, u'user_extensions'), 
    331                 os.path.join(self.wikiAppDir, u'extensions') ) 
    332  
    333         self.pluginManager.loadPlugins( dirs, [ u'KeyBindings.py', 
     330 
     331        self.pluginManager.loadPlugins([ u'KeyBindings.py', 
    334332                u'EvalLibrary.py'] ) 
    335333 
     
    351349                insertionDescriptions) 
    352350 
    353         wikiParserDescriptions = reduce(lambda a, b: a+list(b), 
    354                 describeWikiParserApi.describeWikiParser(1, self), []) 
    355  
    356         self.wikiParserDescDict = dict(( (item[0], item) 
    357                 for item in wikiParserDescriptions )) 
     351        wikiLanguageDescriptions = reduce(lambda a, b: a+list(b), 
     352                describeWikiLanguageApi.describeWikiLanguage(1, self), []) 
     353 
     354        self.wikiLanguageDescDict = dict(( (item[0], item) 
     355                for item in wikiLanguageDescriptions )) 
    358356 
    359357        self.collator = None 
     
    401399 
    402400 
    403     def getWikiParserDescription(self, intLanguageName): 
     401    def getWikiLanguageDescription(self, intLanguageName): 
    404402        """ 
    405403        Returns the parser description tuple as provided by a WikiParser plugin 
    406404        or None if intLanguageName not found. 
    407405        """ 
    408         return self.wikiParserDescDict.get(intLanguageName) 
     406        return self.wikiLanguageDescDict.get(intLanguageName) 
     407 
     408    def listWikiLanguageDescriptions(self): 
     409        """ 
     410        Return list of internal names of all available wiki languages 
     411        """ 
     412        if self.wikiLanguageDescDict.has_key("wikidpad_default_2_0"): 
     413            return [self.getWikiLanguageDescription("wikidpad_default_2_0")] + \ 
     414                    [l for l in self.wikiLanguageDescDict.values() 
     415                    if l[0] != "wikidpad_default_2_0"] 
     416        else: 
     417            return self.wikiLanguageDescDict.values() 
     418 
    409419 
    410420    def createWikiParser(self, intLanguageName, debugMode=False): 
     
    412422        Must be thread-safe! 
    413423        """ 
    414         desc = self.getWikiParserDescription(intLanguageName) 
     424        desc = self.getWikiLanguageDescription(intLanguageName) 
    415425        if desc is None: 
    416426            return None 
     
    437447        Must be thread-safe 
    438448        """ 
    439         desc = self.getWikiParserDescription(intLanguageName) 
     449        desc = self.getWikiLanguageDescription(intLanguageName) 
    440450        if desc is None: 
    441451            return None 
     
    555565        return self.wikiAppDir 
    556566 
    557     def getLowResources(self): 
    558         """ 
    559         Return state of the low resources global setting 
    560         """ 
    561         return self.lowResources 
    562  
    563567    def getIconCache(self): 
    564568        """ 
  • branches/mbutscher/next/lib/pwiki/OptionsDialog.py

    r175 r178  
    345345    # 
    346346    #     guilang: special choice for GUI language 
     347    #     wikilang: special choice for wiki language 
    347348 
    348349    # ttdf and color0 entries have a 4th item with the name 
    349     #     of the "..." button to call a dialog to set. 
     350    #     of the "..." button to call for a dialog to set. 
    350351    # selt entries have a list with the internal config names (unicode) of the 
    351352    #     possible choices as 4th item. 
     
    427428            ("html_body_background", "tfHtmlBgImage", "t"), 
    428429            ("html_header_doctype", "tfHtmlDocType", "t"), 
    429  
    430  
    431             ("auto_save", "cbAutoSave", "b"), 
    432             ("auto_save_delay_key_pressed", "tfAutoSaveDelayKeyPressed", "i0+"), 
    433             ("auto_save_delay_dirty", "tfAutoSaveDelayDirty", "i0+"), 
    434430 
    435431 
     
    530526            ("wikiLockFile_ignore", "cbWikiLockFileIgnore", "b"), 
    531527            ("wikiLockFile_create", "cbWikiLockFileCreate", "b"), 
     528 
     529 
    532530            ("editor_useImeWorkaround", "cbEditorUseImeWorkaround", "b"), 
    533531 
    534532 
     533            ("auto_save", "cbAutoSave", "b"), 
     534            ("auto_save_delay_key_pressed", "tfAutoSaveDelayKeyPressed", "i0+"), 
     535            ("auto_save_delay_dirty", "tfAutoSaveDelayDirty", "i0+"), 
     536 
     537 
    535538            # wiki-specific options 
     539 
     540# "wiki_wikiLanguage" 
    536541 
    537542            ("footnotes_as_wikiwords", "cbFootnotesAsWws", "b"), 
    538543            ("first_wiki_word", "tfFirstWikiWord", "t"), 
     544 
     545 
     546            ("export_default_dir", "tfExportDefaultDir", "t"), 
     547 
     548            ("tree_expandedNodes_rememberDuration", 
     549                    "chTreeExpandedNodesRememberDuration", "seli"), 
     550 
     551            ("tree_force_scratchpad_visibility", 
     552                    "cbTreeForceScratchpadVisibility", "b"), 
     553 
     554            ("option/wiki/log_window_autoshow", "cbLogWindowAutoShowWiki", "b3"), 
     555 
     556            ("wiki_icon", "tfWikiIcon", "t"), 
     557            ("hotKey_showHide_byWiki", "tfHotKeyShowHideByWiki", "t"), 
     558            ("wiki_wikiLanguage", "chWikiWikiLanguage", "wikilang"), 
    539559 
    540560            ("wikiPageTitlePrefix", "tfWikiPageTitlePrefix", "t"), 
    541561            ("wikiPageTitle_creationMode", "chWikiPageTitleCreationMode", "seli"), 
    542562            ("wikiPageTitle_fromLinkTitle", "cbWikiPageTitleFromLinkTitle", "b"), 
    543  
    544             ("export_default_dir", "tfExportDefaultDir", "t"), 
    545  
    546             ("tree_expandedNodes_rememberDuration", 
    547                     "chTreeExpandedNodesRememberDuration", "seli"), 
    548  
    549             ("tree_force_scratchpad_visibility", 
    550                     "cbTreeForceScratchpadVisibility", "b"), 
    551  
    552             ("option/wiki/log_window_autoshow", "cbLogWindowAutoShowWiki", "b3"), 
    553  
    554             ("wiki_icon", "tfWikiIcon", "t"), 
    555  
    556             ("hotKey_showHide_byWiki", "tfHotKeyShowHideByWiki", "t"), 
    557  
     563            ("headingsAsAliases_depth", "scHeadingsAsAliasesDepth", "spin"), 
    558564 
    559565            ("fileStorage_identity_modDateMustMatch", "cbFsModDateMustMatch", "b"), 
     
    578584            ("fileLauncher_path", "tfFileLauncherPath", "t"), 
    579585    ) 
    580      
    581586 
    582587 
     
    588593            ("OptionsPageHtml", N_(u"  HTML preview/export")), 
    589594            ("OptionsPageHtmlHeader", N_(u"    HTML header")), 
    590             ("OptionsPageAutosave", N_(u"  Autosave")), 
    591595            ("OptionsPageEditor", N_(u"  Editor")), 
    592596            ("OptionsPageEditorColors", N_(u"    Editor Colors")), 
     
    597601            ("OptionsPageSearching", N_(u"  Searching")),   
    598602            ("OptionsPageAdvanced", N_(u"  Advanced")),   
     603            ("OptionsPageAutosave", N_(u"    Autosave")), 
    599604            ("OptionsPageCurrentWiki", N_(u"Current Wiki")), 
    600             ("OptionsPageCwFileStorage", N_(u"  File Storage")) 
     605            ("OptionsPageCwHeadings", N_(u"  Headings")), 
     606            ("OptionsPageCwAdvanced", N_(u"  Advanced")) 
    601607    ) 
    602608 
     
    726732                self.ctrls[c].SetSelection( 
    727733                        Localization.findLangListIndex(optValue) + 1) 
    728  
     734            elif t == "wikilang":   # wiki language choice 
     735                # Fill choice with options and find previous selection 
     736                optValue = self.pWiki.getConfig().get("main", o) 
     737                sel = -1 
     738                for i, ld in enumerate( 
     739                        wx.GetApp().listWikiLanguageDescriptions()): 
     740                    self.ctrls[c].Append(ld[1]) 
     741                    if ld[0] == optValue: 
     742                        sel = i 
     743                 
     744                if sel > -1: 
     745                    # Then select previous setting                 
     746                    self.ctrls[c].SetSelection(sel) 
    729747 
    730748            # Register events for "..." buttons 
     
    740758 
    741759        # Options with special treatment 
    742         self.ctrls.cbLowResources.SetValue( 
    743                 self.pWiki.getConfig().getint("main", "lowresources") != 0) 
    744  
    745760        self.ctrls.cbNewWindowWikiUrl.SetValue( 
    746761                self.pWiki.getConfig().getint("main", 
     
    941956                            Localization.getLangList()[idx - 1][0]) 
    942957 
     958            elif t == "wikilang":    # GUI language choice 
     959                idx = self.ctrls[c].GetSelection() 
     960                self.pWiki.getConfig().set("main", o, 
     961                        wx.GetApp().listWikiLanguageDescriptions()[idx][0]) 
     962 
    943963        # Options with special treatment (after standard handling) 
    944         if self.ctrls.cbLowResources.GetValue(): 
    945             self.pWiki.getConfig().set("main", "lowresources", "1") 
    946         else: 
    947             self.pWiki.getConfig().set("main", "lowresources", "0") 
    948  
    949964        if self.ctrls.cbNewWindowWikiUrl.GetValue(): 
    950965            self.pWiki.getConfig().set("main", "new_window_on_follow_wiki_url", "1") 
  • branches/mbutscher/next/lib/pwiki/PersonalWikiFrame.py

    r177 r178  
    2929 
    3030from wikidata import DbBackendUtils, WikiDataManager 
     31 
     32# To generate py2exe dependency 
     33import WikiDocument 
    3134 
    3235import OsAbstract 
     
    5558 
    5659from AdditionalDialogs import * 
     60import AdditionalDialogs 
    5761from OptionsDialog import OptionsDialog 
    5862from SearchAndReplaceDialogs import * 
     
    264268 
    265269        # setup plugin manager and hooks API 
    266         self.pluginManager = PluginManager() 
     270        dirs = ( join(self.globalConfigSubDir, u'user_extensions'), 
     271                join(self.wikiAppDir, u'user_extensions'), 
     272                join(self.wikiAppDir, u'extensions') ) 
     273        self.pluginManager = PluginManager(dirs) 
     274 
    267275        self.hooks = self.pluginManager.registerPluginAPI(("hooks",1), 
    268276            ["startup", "newWiki", "createdWiki", "openWiki", "openedWiki",  
     
    323331        self.autoSaveDelayAfterDirty = self.configuration.getint( 
    324332                "main", "auto_save_delay_dirty") 
    325  
    326         # Should reduce resources usage (less icons) 
    327         # Do not set self.lowResources after initialization here! 
    328         self.lowResources = wx.GetApp().getLowResources() 
    329333 
    330334        # get the position of the splitter 
     
    396400        self.Show(True) 
    397401 
    398         if self.lowResources and self.IsIconized(): 
    399             self.resourceSleep() 
    400  
    401402        EVT_REMOTE_COMMAND(self, self.OnRemoteCommand) 
    402403 
     
    410411        self.evalLib = self.getExtension('EvalLibrary', u'EvalLibrary.py') 
    411412        self.presentationExt = self.getExtension('Presentation', u'Presentation.py') 
    412         dirs = ( join(self.globalConfigSubDir, u'user_extensions'), 
    413                 join(self.wikiAppDir, u'user_extensions'), 
    414                 join(self.wikiAppDir, u'extensions') ) 
    415         self.pluginManager.loadPlugins( dirs, [ u'KeyBindings.py', 
     413        self.pluginManager.loadPlugins([ u'KeyBindings.py', 
    416414                u'EvalLibrary.py' ] ) 
    417415 
     
    644642 
    645643        menuitem = wx.MenuItem(menu, menuID, label, text, kind) 
    646         # if icondesc:  # (not self.lowResources) and 
    647644        bitmap = self.resolveIconDescriptor(icondesc) 
    648645        if bitmap: 
     
    763760        if wikiData is not None: 
    764761            if wikiData.checkCapability("rebuild") == 1: 
    765                 self.addMenuItem(maintenanceMenu, _(u'&Update cache...'), 
    766                         _(u'Update cache were marked as not up to date'), 
    767                         lambda evt: self.rebuildWiki(onlyDirty=True), 
    768                         menuID=GUI_ID.MENU_UPDATE_WIKI_CACHE, 
    769                         updatefct=self.OnUpdateDisReadOnlyWiki) 
    770  
    771762                self.addMenuItem(maintenanceMenu, _(u'&Rebuild Wiki...'), 
    772763                        _(u'Rebuild this wiki and its cache completely'), 
     
    775766                        updatefct=self.OnUpdateDisReadOnlyWiki) 
    776767 
    777                 self.addMenuItem(maintenanceMenu, _(u'&Initiate update'), 
     768                self.addMenuItem(maintenanceMenu, _(u'&Update cache...'), 
     769                        _(u'Update cache where marked as not up to date'), 
     770                        lambda evt: self.rebuildWiki(onlyDirty=True), 
     771                        menuID=GUI_ID.MENU_UPDATE_WIKI_CACHE, 
     772                        updatefct=self.OnUpdateDisReadOnlyWiki) 
     773 
     774                self.addMenuItem(maintenanceMenu, _(u'&Initiate update...'), 
    778775                        _(u'Initiate full cache update which is done mainly ' 
    779776                        u'in background'), 
     
    17281725                lambda evt: self.viewParents(self.getCurrentWikiWord())) 
    17291726 
    1730         self.addMenuItem(navigateMenu, _(u'List &Child...') + u'\t' + 
     1727        self.addMenuItem(navigateMenu, _(u'List &Children...') + u'\t' + 
    17311728                self.keyBindings.ViewChildren, 
    17321729                _(u'List children of current wiki word'), 
     
    20292026        wx.EVT_KEY_DOWN(self.fastSearchField, self.OnFastSearchKeyDown) 
    20302027 
    2031         icon = self.lookupSystemIcon("pin") 
     2028        icon = self.lookupSystemIcon("tb_wikize") 
    20322029        tb.AddSimpleTool(GUI_ID.CMD_FORMAT_WIKIZE_SELECTED, icon, 
    20332030                _(u"Wikize Selected Word ") + self.keyBindings.MakeWikiWord, 
     
    25612558 
    25622559    def OnIconize(self, evt): 
    2563         if self.lowResources: 
    2564             if self.IsIconized(): 
    2565                 self.resourceSleep() 
    2566             else: 
    2567                 self.resourceWakeup() 
    2568  
    25692560        if self.configuration.getboolean("main", "showontray"): 
    25702561            self.Show(not self.IsIconized()) 
     
    25742565 
    25752566    def OnMaximize(self, evt): 
    2576         if self.lowResources: 
    2577             self.resourceWakeup() 
    2578  
    25792567        evt.Skip() 
    25802568 
     
    26262614    def newWiki(self, wikiName, wikiDir): 
    26272615        "creates a new wiki" 
    2628         wdhandlers = DbBackendUtils.listHandlers() 
    2629         if len(wdhandlers) == 0: 
     2616        if len(DbBackendUtils.listHandlers()) == 0: 
    26302617            self.displayErrorMessage( 
    26312618                    _(u'No data handler available to create database.')) 
     
    26532640 
    26542641        if createIt: 
    2655             # Ask for the data handler to use 
    2656             index = wx.GetSingleChoiceIndex(_(u"Choose database type"), 
    2657                     _(u"Choose database type"), [wdh[1] for wdh in wdhandlers], 
    2658                     self) 
    2659             if index == -1: 
     2642#             # Ask for the data handler to use 
     2643#             index = wx.GetSingleChoiceIndex(_(u"Choose database type"), 
     2644#                     _(u"Choose database type"), [wdh[1] for wdh in wdhandlers], 
     2645#                     self) 
     2646#             if index == -1: 
     2647#                 return 
     2648#  
     2649#             wdhName = wdhandlers[index][0] 
     2650 
     2651            wdhName, wlangName = AdditionalDialogs.NewWikiSettings.runModal( 
     2652                    self, -1, self) 
     2653                     
     2654            if wdhName is None: 
    26602655                return 
    26612656 
    2662             wdhName = wdhandlers[index][0] 
    2663                  
    2664 #             wikiDataFactory, createWikiDbFunc = DbBackendUtils.getHandler(self,  
    2665 #                     wdhName) 
    2666 #                      
    2667 #             if wikiDataFactory is None: 
    2668 #                 self.displayErrorMessage( 
    2669 #                         'Data handler %s not available' % wdh[0]) 
    2670 #                 return 
    2671              
    26722657 
    26732658            # create the new dir for the wiki 
     
    27182703                    wikiConfig.set("main", "last_wiki_word", wikiName) 
    27192704                    wikiConfig.set("main", "wiki_database_type", wdhName) 
     2705                    wikiConfig.set("main", "wiki_wikiLanguage", wlangName) 
    27202706                    wikiConfig.set("wiki_db", "data_dir", "data") 
    27212707                    wikiConfig.save() 
     
    27262712                    self.openWiki(configFileLoc) 
    27272713                    p = self.wikiDataManager.createWikiPage(u"WikiSettings") 
    2728                     text = _(u"""++ Wiki Settings 
    2729  
    2730  
    2731 These are your default global settings. 
    2732  
    2733 [global.importance.low.color: grey] 
    2734 [global.importance.high.bold: true] 
    2735 [global.contact.icon: contact] 
    2736 [global.wrap: 70] 
    2737  
    2738 [icon: cog] 
    2739 """)  # TODO Localize differently? 
     2714 
     2715                    langHelper = wx.GetApp().createWikiLanguageHelper( 
     2716                            self.getWikiDefaultWikiLanguage()) 
     2717 
     2718                    text = langHelper.getNewDefaultWikiSettingsPage(self) 
    27402719#                     p.save(text, False) 
    27412720#                     p.update(text, False) 
     
    28452824            dbtype = None 
    28462825         
     2826        wikiLang = None 
     2827         
    28472828        ignoreLock = self.getConfig().getboolean("main", "wikiLockFile_ignore", 
    28482829                False) 
     
    28532834            try: 
    28542835                wikiDataManager = WikiDataManager.openWikiDocument( 
    2855                         cfgPath, dbtype, ignoreLock, createLock) 
     2836                        cfgPath, dbtype, wikiLang, ignoreLock, createLock) 
    28562837                frmcode, frmtext = wikiDataManager.checkDatabaseFormat() 
    28572838                if frmcode == 2: 
     
    28742855                break 
    28752856            except (UnknownDbHandlerException, DbHandlerNotAvailableException), e: 
    2876                 # Could not get handler name from wiki config file 
     2857                # Could not get a handler name from wiki config file 
    28772858                # (probably old database) or required handler not available, 
    28782859                # so ask user 
    28792860                self.displayErrorMessage(unicode(e)) 
    2880                 dbtype = self._askForDbType() 
     2861                dbtype, dummy = AdditionalDialogs.NewWikiSettings.runModal( 
     2862                        self, -1, self, dbtype, 
     2863                        AdditionalDialogs.NewWikiSettings.DEFAULT_GREY) 
     2864#                 dbtype = self._askForDbType() 
    28812865                if dbtype is None: 
    28822866                    return False 
    2883                      
     2867 
     2868                continue # Try again 
     2869            except UnknownWikiLanguageException, e: 
     2870                # Could not get a handler name from wiki config file 
     2871                # (probably old database) or required handler not available, 
     2872                # so ask user 
     2873                self.displayErrorMessage(unicode(e)) 
     2874                dummy, wikiLang = AdditionalDialogs.NewWikiSettings.runModal( 
     2875                        self, -1, self, 
     2876                        AdditionalDialogs.NewWikiSettings.DEFAULT_GREY, wikiLang) 
     2877#                 dbtype = self._askForDbType() 
     2878                if wikiLang is None: 
     2879                    return False 
     2880 
    28842881                continue # Try again 
    28852882            except LockedWikiException, e: 
     
    45954592 
    45964593 
    4597     def initiateFullUpdate(self): 
     4594    def initiateFullUpdate(self, skipConfirm=False): 
    45984595        if self.isReadOnlyWiki(): 
    45994596            return 
    46004597 
    4601         try: 
    4602             self.saveAllDocPages() 
    4603             progresshandler = wxGuiProgressHandler( 
    4604                     _(u"     Initiating update     "), 
    4605                     _(u"     Initiating update     "), 0, self) 
    4606             self.getWikiDataManager().initiateFullUpdate(progresshandler) 
    4607      
    4608 #         self.tree.collapse() 
    4609 #  
    4610 #         # TODO Adapt for functional pages 
    4611 #         if self.getCurrentWikiWord() is not None: 
    4612 #             self.openWikiPage(self.getCurrentWikiWord(), 
    4613 #                     forceTreeSyncFromRoot=True) 
    4614 #         self.tree.expandRoot() 
    4615         except (IOError, OSError, DbAccessError), e: 
    4616             self.lostAccess(e) 
    4617             raise 
    4618         except Exception, e: 
    4619             self.displayErrorMessage(_(u"Error initiating update"), e) 
    4620             traceback.print_exc() 
     4598        if not skipConfirm: 
     4599            result = wx.MessageBox(_(u"Are you sure you want to start a full " 
     4600                    u"rebuild of wiki in background?<d"), 
     4601                    _(u'Initiate update'), 
     4602                    wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION, self) 
     4603 
     4604        if skipConfirm or result == wx.YES : 
     4605            try: 
     4606                self.saveAllDocPages() 
     4607                progresshandler = wxGuiProgressHandler( 
     4608                        _(u"     Initiating update     "), 
     4609                        _(u"     Initiating update     "), 0, self) 
     4610                self.getWikiDataManager().initiateFullUpdate(progresshandler) 
     4611         
     4612    #         self.tree.collapse() 
     4613    #  
     4614    #         # TODO Adapt for functional pages 
     4615    #         if self.getCurrentWikiWord() is not None: 
     4616    #             self.openWikiPage(self.getCurrentWikiWord(), 
     4617    #                     forceTreeSyncFromRoot=True) 
     4618    #         self.tree.expandRoot() 
     4619            except (IOError, OSError, DbAccessError), e: 
     4620                self.lostAccess(e) 
     4621                raise 
     4622            except Exception, e: 
     4623                self.displayErrorMessage(_(u"Error initiating update"), e) 
     4624                traceback.print_exc() 
    46214625 
    46224626 
     
    50385042        if self.windowLayouter is not None: 
    50395043            self.windowLayouter.layout() 
    5040             if self.lowResources: 
    5041                 self.resourceWakeup() 
    5042  
    50435044 
    50445045 
  • branches/mbutscher/next/lib/pwiki/PluginManager.py

    r166 r178  
    1 import os, sys, traceback 
     1from __future__ import with_statement 
     2 
     3import os, sys, traceback, os.path 
     4 
     5# sys.path.append(ur"C:\Daten\Projekte\Wikidpad\Next20\extensions") 
    26 
    37import wx 
    48 
    5 from StringOps import mbcsEnc, pathEnc 
     9from .StringOps import mbcsEnc, pathEnc 
    610 
    711"""The PluginManager and PluginAPI classes implement a generic plugin framework. 
     
    1216   Example code: 
    1317    
    14    pm = PluginManager() 
     18   pm = PluginManager(["dir1, "dir2"]) 
    1519   api = pm.registerPluginAPI(("myAPI",1), ["init", "call1", "call2", "exit"]) 
    16    pm.loadPlugins(["dir1, "dir2"], ["notloadme", "andnotme"]) 
     20   pm.loadPlugins(["notloadme", "andnotme"]) 
    1721   api.init("hello") 
    1822   api.exit() 
     
    97101class PluginManager(object): 
    98102    """manages all PluginAPIs and plugins.""" 
    99     def __init__(self): 
     103    def __init__(self, directories): 
    100104        self.pluginAPIs = {} 
    101         self.plugins = {}       
     105        self.plugins = {}   
     106        self.directories = directories 
    102107         
    103108    def registerPluginAPI(self, name, functions): 
     
    127132            del self.plugins[name] 
    128133         
    129     def loadPlugins(self, directories, excludeFiles): 
     134    def loadPlugins(self, excludeFiles): 
    130135        """load and register plugins with apis. the directories in the list 
    131136           directories are searched in order for all files ending with .py or  
     
    137142           directories are searched in order for plugins. Therefore plugins 
    138143           appearing in earlier directories are not loaded from later ones.""" 
     144        import imp 
    139145        exclusions = excludeFiles[:] 
    140         for directory in directories: 
     146        for dirNum, directory in enumerate(self.directories): 
     147            sys.path.append(os.path.dirname(directory)) 
    141148            if not os.access(mbcsEnc(directory, "replace")[0], os.F_OK): 
    142149                continue 
     
    149156                    continue 
    150157                if os.path.isfile(fullname) and ext == '.py': 
    151                     module = self.importCode(open(pathEnc(fullname)), moduleName) 
    152                 elif os.path.isdir(fullname): 
    153                     module = self.importDirectory(fullname) 
     158                    with open(fullname) as f: 
     159                        packageName = "cruelimportExtensionsPackage%i" % dirNum 
     160 
     161                        module = imp.load_module(packageName + "." + moduleName, f, 
     162                                pathEnc(fullname), (".py", "r", imp.PY_SOURCE)) 
    154163                if module and hasattr(module, "WIKIDPAD_PLUGIN"): 
    155164                    if self.registerPlugin(module): 
    156165                        exclusions.append(name) 
     166            del sys.path[-1] 
    157167           
    158168    def importDirectory(self, name, add_to_sys_modules = False):  
     
    165175            del sys.modules[name] 
    166176        return module 
    167          
    168     def importCode(self,code,name,add_to_sys_modules = False): 
    169         """ 
    170         Import dynamically generated code as a module. code is the 
    171         object containing the code (a string, a file handle or an 
    172         actual compiled code object, same types as accepted by an 
    173         exec statement). The name is the name to give to the module, 
    174         and the final argument says wheter to add it to sys.modules 
    175         or not. If it is added, a subsequent import statement using 
    176         name will return this module. If it is not added to sys.modules 
    177         import will try to load it in the normal fashion. 
    178  
    179         import foo 
    180  
    181         is equivalent to 
    182  
    183         foofile = open("/path/to/foo.py") 
    184         foo = importCode(foofile,"foo",1) 
    185  
    186         Returns a newly generated module. 
    187         """ 
    188         import imp 
    189  
    190         module = imp.new_module(name) 
    191  
    192         exec code in module.__dict__ 
    193         if add_to_sys_modules: 
    194             sys.modules[name] = module 
    195  
    196         return module 
     177 
     178 
     179#     def importCode(self,code,name,add_to_sys_modules = False): 
     180#         """ 
     181#         Import dynamically generated code as a module. code is the 
     182#         object containing the code (a string, a file handle or an 
     183#         actual compiled code object, same types as accepted by an 
     184#         exec statement). The name is the name to give to the module, 
     185#         and the final argument says wheter to add it to sys.modules 
     186#         or not. If it is added, a subsequent import statement using 
     187#         name will return this module. If it is not added to sys.modules 
     188#         import will try to load it in the normal fashion. 
     189#  
     190#         import foo 
     191#  
     192#         is equivalent to 
     193#  
     194#         foofile = open("/path/to/foo.py") 
     195#         foo = importCode(foofile,"foo",1) 
     196#  
     197#         Returns a newly generated module. 
     198#         """ 
     199#         import imp 
     200#  
     201#         module = imp.new_module(name) 
     202#  
     203#         exec code in module.__dict__ 
     204#         if add_to_sys_modules: 
     205#             sys.modules[name] = module 
     206#  
     207#         return module 
    197208 
    198209 
  • branches/mbutscher/next/lib/pwiki/SpellChecker.py

    r174 r178  
    1010    import EnchantDriver 
    1111except ImportError: 
    12     traceback.print_exc() 
     12#     traceback.print_exc() 
    1313    Dict = None 
    1414 
  • branches/mbutscher/next/lib/pwiki/StringOps.py

    r173 r178  
    2222 
    2323import re as _re # import pwiki.srePersistent as reimport pwiki.srePersistent as _re 
     24from WikiExceptions import * 
     25 
    2426 
    2527LINEEND_SPLIT_RE = _re.compile(r"\r\n?|\n", _re.UNICODE) 
     
    104106 
    105107 
    106 # if isWindows() and not isWin9x(): 
    107108if os.path.supports_unicode_filenames: 
    108109    def dummy(s): 
     
    123124            return None 
    124125        return mbcsDec(s, "replace")[0] 
     126 
     127if isWindows(): 
     128    if not os.path.supports_unicode_filenames: 
     129        raise InternalError("This Python version does not support unicode pathes") 
     130     
     131    # To process pathes longer than 255 characters, Windows (NT and following) 
     132    # expects an absolute path prefixed with \\?\ 
     133 
     134    def longPathEnc(s): 
     135        if s is None: 
     136            return None 
     137        if s.startswith("\\\\?\\"): 
     138            return s 
     139 
     140        return u"\\\\?\\" + os.path.abspath(s) 
     141 
     142    def longPathDec(s): 
     143        if s is None: 
     144            return None 
     145        if s.startswith("\\\\?\\"): 
     146            return s[4:] 
     147 
     148        return s 
     149 
     150else: 
     151    longPathEnc = pathEnc 
     152    longPathDec = pathDec 
    125153 
    126154 
     
    11191147    else: 
    11201148        baseQuoted = [] 
    1121      
     1149 
    11221150    overallLength = sum(len(bq) for bq in baseQuoted) + len(suffix) 
    1123      
     1151 
    11241152    # Shorten baseQuoted if needed. This method ensures that no half-quoted 
    11251153    # character (e.g. "@3") is remaining 
     
    11521180        yield beforeRandom + createRandomString(randomLength) + suffix 
    11531181 
    1154  
     1182u'C:\\Daten\\Projekte\\Wikidpad\\Next20\\WikidPadHelpOS\\data\\Now a%21%22\xa7$%25&=%3F\xb4`\xb4%27 Wikiword can contain (nearly) every%21%21^\xb0character. And it can be longer and longer and longer. At the moment there may be problems with HTML export of very long wikiwords, but I hope to get this working in a future.wiki' 
    11551183 
    11561184 
     
    12771305    br = b[4+l : ] 
    12781306    return (s, br) 
     1307 
     1308 
     1309# def orderBySuggestion(strs, sugg): 
     1310#     """ 
     1311#     Order string iterable  strs  in a way that all strings also present in 
     1312#     sequence  sugg  come first in resulting list, then the strings from strs 
     1313#     which are not in  sugg  in arbitrary order. 
     1314#     """ 
     1315#     s = set(strs) 
     1316#     result = [] 
     1317#     for e in sugg: 
     1318#         if e in s: 
     1319#             result.append(e) 
     1320#             s.remove(e) 
     1321#      
     1322#     for e in s: 
     1323#         result.append(e) 
     1324#      
     1325#     return result 
     1326 
    12791327 
    12801328 
  • branches/mbutscher/next/lib/pwiki/WikiExceptions.py

    r169 r178  
    5555class UnknownDbHandlerException(Exception): pass 
    5656 
     57 
     58# See WikiDataManager.py. Thrown if requested handler for wiki language isn't 
     59#     available 
     60class UnknownWikiLanguageException(Exception): pass 
     61class WrongWikiLanguageException(Exception): pass 
     62 
     63 
    5764class MissingConfigurationFileException(Exception): pass 
    5865class BadConfigurationFileException(Exception): pass 
    5966class LockedWikiException(Exception): pass 
     67 
    6068 
    6169class NotCurrentThreadException(Exception): pass 
  • branches/mbutscher/next/lib/pwiki/WikiHtmlView.py

    r175 r178  
    1515from Configuration import isWindows, MIDDLE_MOUSE_CONFIG_TO_TABMODE, isOSX 
    1616 
     17import DocPages 
    1718from TempFileSet import TempFileSet 
    1819 
     
    261262                pass 
    262263 
     264        wikiPage = self.presenter.getDocPage() 
     265        if isinstance(wikiPage, 
     266                (DocPages.DataCarryingPage, DocPages.AliasWikiPage)) and \ 
     267                not wikiPage.checkFileSignatureAndMarkDirty(): 
     268            # Valid wiki page and invalid signature -> rebuild HTML page 
     269            self.outOfSync = True 
     270 
    263271        if self.outOfSync: 
    264272            self.currentLoadedWikiWord = None 
    265273     
    266             wikiPage = self.presenter.getDocPage() 
    267274            if wikiPage is None: 
    268275                return  # TODO Do anything else here? 
     
    277284 
    278285            self.currentLoadedWikiWord = word 
    279             content = self.presenter.getLiveText() 
     286#             content = self.presenter.getLiveText() 
    280287 
    281288            html = self.exporterInstance.exportWikiPageToHtmlString(wikiPage) 
  • branches/mbutscher/next/lib/pwiki/WikiHtmlViewIE.py

    r174 r178  
    3838        pathnameFromUrl 
    3939 
     40import DocPages 
    4041from TempFileSet import TempFileSet 
    4142 
     
    210211#                 pass 
    211212 
    212          
     213        wikiPage = self.presenter.getDocPage() 
     214        if isinstance(wikiPage, 
     215                (DocPages.DataCarryingPage, DocPages.AliasWikiPage)) and \ 
     216                not wikiPage.checkFileSignatureAndMarkDirty(): 
     217            # Valid wiki page and invalid signature -> rebuild HTML page 
     218            self.outOfSync = True 
     219 
    213220        if self.outOfSync: 
    214221#             self.currentLoadedWikiWord = None 
     
    219226                return 
    220227 
    221             wikiPage = self.presenter.getDocPage() 
    222228            if wikiPage is None: 
    223229                self.currentLoadedWikiWord = None 
  • branches/mbutscher/next/lib/pwiki/WikiTreeCtrl.py

    r177 r178  
    11261126        self.contextMenuWikiWords.AppendSeparator() 
    11271127 
     1128#         # Build icon menu (low resource version) 
     1129#         # Add only menu item for icon select dialog 
     1130#         menuID = wx.NewId() 
     1131#         self.contextMenuWikiWords.Append(menuID, _(u'Add icon attribute'), 
     1132#                 _(u'Open icon select dialog')) 
     1133#         wx.EVT_MENU(self, menuID, lambda evt: self.pWiki.showSelectIconDialog()) 
     1134 
    11281135        # Build icon menu 
    1129         if self.pWiki.lowResources: 
    1130             # Add only menu item for icon select dialog 
    1131             menuID = wx.NewId() 
    1132             self.contextMenuWikiWords.Append(menuID, _(u'Add icon attribute'), 
    1133                     _(u'Open icon select dialog')) 
    1134             wx.EVT_MENU(self, menuID, lambda evt: self.pWiki.showSelectIconDialog()) 
    1135         else: 
    1136             # Build full submenu for icons 
    1137             iconsMenu, self.cmdIdToIconName = \ 
    1138                     PropertyHandling.buildIconsSubmenu(wx.GetApp().getIconCache()) 
    1139             for cmi in self.cmdIdToIconName.keys(): 
    1140                 wx.EVT_MENU(self, cmi, self.OnInsertIconAttribute) 
    1141  
    1142             self.contextMenuWikiWords.AppendMenu(wx.NewId(), 
    1143                     _(u'Add icon attribute'), iconsMenu) 
     1136        # Build full submenu for icons 
     1137        iconsMenu, self.cmdIdToIconName = \ 
     1138                PropertyHandling.buildIconsSubmenu(wx.GetApp().getIconCache()) 
     1139        for cmi in self.cmdIdToIconName.keys(): 
     1140            wx.EVT_MENU(self, cmi, self.OnInsertIconAttribute) 
     1141 
     1142        self.contextMenuWikiWords.AppendMenu(wx.NewId(), 
     1143                _(u'Add icon attribute'), iconsMenu) 
    11441144 
    11451145        # Build submenu for colors 
  • branches/mbutscher/next/lib/pwiki/WikiTxtCtrl.py

    r177 r178  
    361361        self.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d" % 
    362362                self.presenter.getDefaultFontFaces()) 
    363                  
     363 
    364364#         self.setFoldingActive(self.foldingActive) 
    365365 
     
    418418        self.wikiPageSink = wxKeyFunctionSink(( 
    419419                ("updated wiki page", self.onWikiPageUpdated),   # fired by a WikiPage 
    420                 ("checked file signature invalid", self.onFileSignatureInvalid),   # fired by a WikiPage 
    421420        )) 
    422421 
    423422 
    424423        wx.stc.EVT_STC_STYLENEEDED(self, ID, self.OnStyleNeeded) 
     424        wx.stc.EVT_STC_CHARADDED(self, ID, self.OnCharAdded) 
    425425        wx.stc.EVT_STC_MODIFIED(self, ID, self.OnModified) 
    426426        wx.stc.EVT_STC_USERLISTSELECTION(self, ID, self.OnUserListSelection) 
     
    11521152 
    11531153 
    1154     def onFileSignatureInvalid(self, miscevt): 
    1155         docPage = self.getLoadedDocPage() 
    1156         if docPage is None or \ 
     1154    def handleInvalidFileSignature(self, docPage): 
     1155        """ 
     1156        Called directly from a doc page to repair the editor state if an 
     1157        invalid file signature was detected. 
     1158         
     1159        docPage -- calling docpage 
     1160        """ 
     1161        if docPage is not self.getLoadedDocPage() or \ 
    11571162                not isinstance(docPage, 
    1158                         (DocPages.WikiPage, DocPages.AliasWikiPage)): 
     1163                        (DocPages.DataCarryingPage, DocPages.AliasWikiPage)): 
    11591164            return 
    11601165         
     
    23992404 
    24002405 
     2406    def OnCharAdded(self, evt): 
     2407        "When the user presses enter reindent to the previous level" 
     2408 
     2409#         currPos = self.GetScrollPos(wxVERTICAL) 
     2410         
     2411        evt.Skip() 
     2412        key = evt.GetKey() 
     2413 
     2414        if key == 10: 
     2415            text = self.GetText() 
     2416            wikiDocument = self.presenter.getWikiDocument() 
     2417            bytePos = self.GetCurrentPos() 
     2418            lineStartBytePos = self.PositionFromLine(self.LineFromPosition(bytePos)) 
     2419 
     2420            lineStartCharPos = len(self.GetTextRange(0, lineStartBytePos)) 
     2421            charPos = lineStartCharPos + len(self.GetTextRange(lineStartBytePos, 
     2422                    bytePos)) 
     2423 
     2424            autoUnbullet = self.presenter.getConfig().getboolean("main", 
     2425                    "editor_autoUnbullets", False) 
     2426 
     2427            settings = { 
     2428                    "autoUnbullet": autoUnbullet, 
     2429                    "autoBullets": self.autoBullets, 
     2430                    "autoIndent": self.autoIndent 
     2431                    } 
     2432 
     2433            self.wikiLanguageHelper.handleNewLineAfterEditor(self, text, 
     2434                    charPos, lineStartCharPos, wikiDocument, settings) 
     2435 
     2436 
     2437 
    24012438    def OnKeyDown(self, evt): 
    24022439        key = evt.GetKeyCode() 
     
    24352472                    return 
    24362473                evt.Skip() 
    2437             elif key == wx.WXK_RETURN: 
     2474            elif key == wx.WXK_RETURN and not self.AutoCompActive(): 
    24382475                text = self.GetText() 
    24392476                wikiDocument = self.presenter.getWikiDocument() 
     
    24542491                        } 
    24552492                 
    2456                 if self.wikiLanguageHelper.handleNewLine(self, text, 
     2493                if self.wikiLanguageHelper.handleNewLineBeforeEditor(self, text, 
    24572494                        charPos, lineStartCharPos, wikiDocument, settings): 
    24582495                    evt.Skip() 
     
    25282565        if wikiPage is None: 
    25292566            return 
    2530         if not isinstance(wikiPage, (DocPages.WikiPage, DocPages.AliasWikiPage)): 
     2567        if not isinstance(wikiPage, 
     2568                (DocPages.DataCarryingPage, DocPages.AliasWikiPage)): 
    25312569            return 
    25322570 
    2533         wikiPage.checkFileSignature() 
    2534  
    2535  
    2536 #     def OnMouseWheel(self, evt): 
    2537 #         evt.Skip() 
    2538  
     2571        wikiPage.checkFileSignatureAndMarkDirty() 
    25392572 
    25402573 
     
    25422575        text = evt.GetText() 
    25432576        toerase = self.autoCompBackBytesMap[text] 
    2544              
     2577 
    25452578        self.SetSelection(self.GetCurrentPos() - toerase, self.GetCurrentPos()) 
    2546          
     2579 
    25472580        self.ReplaceSelection(text) 
    25482581 
     
    26432676            threadstop=DUMBTHREADSTOP): 
    26442677        try: 
    2645             pageAst = self.getLoadedDocPage().getLivePageAst( 
    2646                     threadstop=threadstop) 
     2678            docPage = self.getLoadedDocPage() 
     2679            if docPage is None: 
     2680                return 
     2681 
     2682            pageAst = docPage.getLivePageAst(threadstop=threadstop) 
    26472683 
    26482684            nodes = pageAst.findNodesForCharPos(charPos) 
  • branches/mbutscher/next/lib/pwiki/WindowsHacks.py

    r166 r178  
    259259 
    260260        return result.value[4:] 
    261  
    262  
    263261 
    264262 
  • branches/mbutscher/next/lib/pwiki/timeView/TimePresentationBase.py

    r166 r178  
    1616 
    1717class TimePresentationBase: 
     18    """ 
     19    Basic functionality for a timeline or calendar panel. 
     20    """ 
    1821    def __init__(self, mainControl, wikiWordFilter): 
    1922         
  • branches/mbutscher/next/lib/pwiki/timeView/TimelinePanel.py

    r173 r178  
    5252        self.clientHeight = self.GetClientSizeTuple()[1] 
    5353         
    54         self.visibleItemCount = (self.clientHeight - 4) // self.itemHeight 
     54        self.visibleItemCount = (self.clientHeight - 6) // self.itemHeight 
    5555         
    5656        self.contextMenuWikiWords = IdRecycler()  # {menuid: wiki word to go to} 
     
    107107 
    108108        self.clientHeight = size.GetHeight() 
     109 
     110        if self.clientHeight - 6 < self.itemHeight: 
     111            # Doesn't make sense to calculate further 
     112            # This may especially happen for the initial call on Linux 
     113            return 
    109114 
    110115        self.visibleItemCount = (self.clientHeight - 6) // self.itemHeight 
     
    375380        self.listMaxWordCount = maxWordCount 
    376381        self.listContent = content 
    377  
    378  
    379  
    380 #     def OnEraseBg(self, evt): 
    381 #         dc = evt.GetDC() 
    382 #         return 
    383382 
    384383 
  • branches/mbutscher/next/lib/pwiki/wikidata/DbBackendUtils.py

    r166 r178  
    1010    _handlers = [] 
    1111 
     12    hdls = WikiData_original_sqlite.listAvailableWikiDataHandlers() 
     13    for h in hdls: 
     14        _handlers.append((h[0], h[1], 
     15                WikiData_original_sqlite.getWikiDataHandler)) 
     16 
    1217    hdls = WikiData_compact_sqlite.listAvailableWikiDataHandlers() 
    1318    for h in hdls: 
     
    1924        _handlers.append((h[0], h[1], 
    2025                WikiData_original_gadfly.getWikiDataHandler)) 
    21  
    22     hdls = WikiData_original_sqlite.listAvailableWikiDataHandlers() 
    23     for h in hdls: 
    24         _handlers.append((h[0], h[1], 
    25                 WikiData_original_sqlite.getWikiDataHandler)) 
    26  
    2726 
    2827def listHandlers(): 
  • branches/mbutscher/next/lib/pwiki/wikidata/WikiDataManager.py

    r177 r178  
    6565 
    6666 
    67 def openWikiDocument(wikiConfigFilename, dbtype=None, 
     67def openWikiDocument(wikiConfigFilename, dbtype=None, wikiLang=None, 
    6868        ignoreLock=False, createLock=True): 
    6969    """ 
     
    7171    one 
    7272    dbtype -- internal name of database type 
    73     wikiName -- Name of the wiki to create 
     73    wikiLang -- internal name of wiki language 
    7474    dataDir -- directory for storing the data files 
    7575    overwrite -- Should already existing data be overwritten 
     
    8282            # Same database can't be opened twice with different db handlers 
    8383            raise WrongDbHandlerException(_(u"Database is already in use " 
    84                     u"with handler '%s'. Can't open with different handler.") % 
     84                    u'with database handler "%s". ' 
     85                    u"Can't open with different handler.") % 
    8586                    wdm.getDbtype()) 
     87 
     88        if wikiLang is not None and wikiLang != wdm.getWikiDefaultWikiLanguage(): 
     89            raise WrongWikiLanguageException(_(u"Database is already in use " 
     90                    u'with wiki language handler "%s". ' 
     91                    u"Can't open with different handler.") % 
     92                    wdm.getWikiDefaultWikiLanguage()) 
    8693 
    8794        wdm.incRefCount() 
    8895        return wdm 
    8996 
    90     wdm = WikiDataManager(wikiConfigFilename, dbtype, ignoreLock, 
     97    wdm = WikiDataManager(wikiConfigFilename, dbtype, wikiLang, ignoreLock, 
    9198            createLock) 
    9299 
     
    302309    """ 
    303310 
    304     def __init__(self, wikiConfigFilename, dbtype, ignoreLock=False, 
     311    def __init__(self, wikiConfigFilename, dbtype, wikiLangName, ignoreLock=False, 
    305312            createLock=True): 
    306313        MiscEventSourceMixin.__init__(self) 
     
    380387            self._releaseLockFile() 
    381388            raise DbHandlerNotAvailableException( 
    382                     _(u'Required data handler %s unknown to WikidPad') % wikidhName) 
     389                    _(u'Required data handler "%s" unknown to WikidPad') % wikidhName) 
    383390 
    384391        wikiDataFactory, createWikiDbFunc = DbBackendUtils.getHandler(wikidhName) 
     
    386393            self._releaseLockFile() 
    387394            raise NoDbHandlerException( 
    388                     _(u"Required data handler %s not available") % wikidhName) 
    389  
     395                    _(u'Error on initializing data handler "%s"') % wikidhName) 
     396 
     397        if wikiLangName is None: 
     398            wikiLangName = wikiConfig.get("main", "wiki_wikiLanguage", 
     399                    "wikidpad_default_2_0") 
     400        else: 
     401            wikiConfig.set("main", "wiki_wikiLanguage", wikiLangName) 
     402 
     403        if GetApp().getWikiLanguageDescription(wikiLangName) is None: 
     404            self._releaseLockFile() 
     405            raise UnknownWikiLanguageException( 
     406                    _(u'Required wiki language handler "%s" not available') % 
     407                            wikiLangName) 
     408 
     409        self.wikiLangName = wikiLangName 
    390410        self.ensureWikiTempDir() 
    391          
     411 
    392412#         dbExecutor = GetApp().getDbExecutor() 
    393413#         wikiData = dbExecutor(wikiDataFactory, self, dataDir, self.getWikiTempDir()) 
     
    500520 
    501521 
    502                  
    503  
    504  
    505522    def incRefCount(self): 
    506523        self.refCount += 1 
     
    591608        """ 
    592609        Returns the internal name of the default wiki language of this wiki. 
    593         Single pages may have different languages (not implmented yet). 
    594         """ 
    595         # TODO! Configurable 
    596         return "wikidpad_default_2_0" 
     610         
     611        Single pages may have different languages (not implemented yet). 
     612        """ 
     613        return self.getWikiConfig().get("main", "wiki_wikiLanguage", 
     614                "wikidpad_default_2_0") 
    597615 
    598616    def getPageTitlePrefix(self): 
     
    956974 
    957975 
     976    # TODO Remove if not needed 
    958977    def checkFileSignatureForWikiWordAndMarkDirty(self, word): 
    959978        """ 
  • branches/mbutscher/next/lib/pwiki/wikidata/compact_sqlite/WikiData.py

    r177 r178  
    3737 
    3838 
    39 from pwiki.StringOps import getBinCompactForDiff, applyBinCompact, pathEnc, pathDec,\ 
    40         binCompactToCompact, fileContentToUnicode, utf8Enc, utf8Dec, \ 
     39from pwiki.StringOps import getBinCompactForDiff, applyBinCompact, longPathEnc, \ 
     40        longPathDec, binCompactToCompact, fileContentToUnicode, utf8Enc, utf8Dec, \ 
    4141        uniWithNone, loadEntireTxtFile, Conjunction, lineendToInternal 
    4242 
     
    5555 
    5656        try: 
    57             if (not exists(pathEnc(dbfile))): 
     57            if (not exists(longPathEnc(dbfile))): 
    5858                DbStructure.createWikiDB(None, dataDir)  # , True 
    5959        except (IOError, OSError, sqlite.Error), e: 
     
    6161            raise DbWriteAccessError(e) 
    6262 
    63         dbfile = pathDec(dbfile) 
     63        dbfile = longPathDec(dbfile) 
    6464        try: 
    6565            self.connWrap = DbStructure.ConnectWrapSyncCommit( 
     
    256256                # Word does not exist -> record creation date 
    257257                self.connWrap.execSql("insert or replace into wikiwordcontent" 
    258                     "(word, content, modified, created, wordnormcase) " 
    259                     "values (?,?,?,?,?)", 
    260                     (word, sqlite.Binary(content), moddate, creadate, word.lower())) 
     258                    "(word, content, modified, created) " 
     259                    "values (?,?,?,?)", 
     260                    (word, sqlite.Binary(content), moddate, creadate)) 
    261261        except (IOError, OSError, sqlite.Error), e: 
    262262            traceback.print_exc() 
     
    271271        """ 
    272272        try: 
    273             self.connWrap.execSql("update wikiwordcontent set word = ?, wordnormcase = ? " 
    274                     "where word = ?", (newWord, newWord.lower(), oldWord)) 
     273            self.connWrap.execSql("update wikiwordcontent set word = ? " 
     274                    "where word = ?", (newWord, oldWord)) 
    275275     
    276276            self.cachedContentNames = None 
     
    18591859        self.connWrap.syncCommit() 
    18601860 
    1861         fnames = glob.glob(pathEnc(join(self.dataDir, '*.wiki'))) 
     1861        fnames = glob.glob(longPathEnc(join(self.dataDir, '*.wiki'))) 
    18621862        for fn in fnames: 
    1863             word = pathDec(basename(fn)).replace('.wiki', '') 
     1863            word = longPathDec(basename(fn)).replace('.wiki', '') 
    18641864 
    18651865            content = fileContentToUnicode(loadEntireTxtFile(fn)) 
  • branches/mbutscher/next/lib/pwiki/wikidata/original_gadfly/DbStructure.py

    r177 r178  
    879879            if not uniqueCtl.has_key(w): 
    880880                connwrap.execSqlInsert("wikiwords", ("word", "created",  
    881                         "modified", "presentationdatablock", "wordnormcase"), 
    882                         (w, c, m, "", "")) 
     881                        "modified", "presentationdatablock"), 
     882                        (w, c, m, "")) 
    883883#                 connwrap.execSql("insert into wikiwords(word, created, modified) " 
    884884#                         "values (?, ?, ?)", (w, c, m)) 
  • branches/mbutscher/next/lib/pwiki/wikidata/original_gadfly/WikiData.py

    r177 r178  
    1414 
    1515 
    16 from os import mkdir, unlink, rename, stat    # listdir 
    1716from os.path import exists, join, basename 
    18 import os.path 
     17import os, os.path 
    1918 
    2019from time import time, localtime 
     
    4039from pwiki import SearchAndReplace 
    4140 
    42 from pwiki.StringOps import pathEnc, pathDec, utf8Enc, utf8Dec, BOM_UTF8, \ 
     41from pwiki.StringOps import longPathEnc, longPathDec, utf8Enc, utf8Dec, BOM_UTF8, \ 
    4342        fileContentToUnicode, loadEntireTxtFile, loadEntireFile, \ 
    4443        writeEntireFile, Conjunction, iterCompatibleFilename, \ 
     
    231230#             oldFileName = pathDec(oldFileName) 
    232231 
    233             fileName = self.createWikiWordFileName(word) 
     232            fileName = self.createWikiWordFileName(newWord) 
    234233            newFilePath = os.path.join(head, fileName) 
    235234 
    236             os.rename(pathEnc(os.path.join(self.dataDir, oldFilePath)), 
    237                     pathEnc(os.path.join(self.dataDir, newFilePath))) 
     235            os.rename(longPathEnc(os.path.join(self.dataDir, oldFilePath)), 
     236                    longPathEnc(os.path.join(self.dataDir, newFilePath))) 
    238237 
    239238            self.cachedContentNames = None 
     
    260259            self.cachedContentNames = None 
    261260            if exists(fileName): 
    262                 unlink(fileName) 
     261                os.unlink(fileName) 
    263262        except (IOError, OSError, ValueError), e: 
    264263            traceback.print_exc() 
     
    903902            for path in self.connWrap.execSqlQuerySingleColumn( 
    904903                    "select filepath from wikiwords"): 
    905                 if not os.path.exists(pathEnc(os.path.join(self.dataDir, path))): 
     904                if not os.path.exists(longPathEnc(os.path.join(self.dataDir, path))): 
    906905                    self.connWrap.execSql("delete from wikiwords " 
    907906                            "where filepath = ?", (path,)) 
     
    912911            for path in (diskFiles - dbFiles): 
    913912                fullPath = os.path.join(self.dataDir, path) 
    914                 st = stat(pathEnc(fullPath)) 
     913                st = os.stat(longPathEnc(fullPath)) 
    915914                 
    916915                wikiWord = self._findNewWordForFile(path) 
     
    971970    def _getAllWikiFileNamesFromDisk(self):   # Used for rebuilding wiki 
    972971        try: 
    973             files = glob.glob(pathEnc(join(self.dataDir, 
     972            files = glob.glob(longPathEnc(join(self.dataDir, 
    974973                    u'*' + self.pagefileSuffix))) 
    975974 
    976             return [pathDec(basename(fn)) for fn in files] 
     975            return [longPathDec(basename(fn)) for fn in files] 
    977976             
    978977#             result = [] 
     
    10251024        path = self.getWikiWordFileNameRaw(wikiWord) 
    10261025         
    1027         return pathEnc(join(self.dataDir, path)) 
     1026        return longPathEnc(join(self.dataDir, path)) 
    10281027 
    10291028 
     
    10421041                if len(existing) > 0: 
    10431042                    continue 
    1044                 if exists(pathEnc(join(self.dataDir, fileName))): 
     1043                if exists(longPathEnc(join(self.dataDir, fileName))): 
    10451044                    continue 
    10461045     
     
    17981797                    if len(existing) > 0: 
    17991798                        continue 
    1800                     if exists(pathEnc(join(self.dataDir, fileName))): 
     1799                    if exists(longPathEnc(join(self.dataDir, fileName))): 
    18011800                        continue 
    18021801 
     
    18401839            if filePath is not None: 
    18411840                # The entry is in an external file, so delete it 
    1842                 os.unlink(join(self.dataDir, filePath)) 
     1841                os.unlink(longPathEnc(join(self.dataDir, filePath))) 
    18431842                self.connWrap.execSql( 
    18441843                        "delete from datablocksexternal " 
     
    20602059            protocol 
    20612060        """ 
    2062         DbStructure.rebuildIndices()   # ? 
     2061        DbStructure.rebuildIndices(self.connWrap)   # ? 
    20632062 
    20642063 
  • branches/mbutscher/next/lib/pwiki/wikidata/original_sqlite/WikiData.py

    r177 r178  
    1414 
    1515 
    16 from os import mkdir, unlink, listdir, rename, stat, utime 
    1716from os.path import exists, join, basename 
    18 import os.path 
     17import os, os.path 
    1918 
    2019from time import time, localtime 
     
    3534#     pass 
    3635 
    37 from pwiki.StringOps import getBinCompactForDiff, applyBinCompact, pathEnc, \ 
    38         pathDec, binCompactToCompact, fileContentToUnicode, utf8Enc, utf8Dec, \ 
     36from pwiki.StringOps import getBinCompactForDiff, applyBinCompact, longPathEnc, \ 
     37        longPathDec, binCompactToCompact, fileContentToUnicode, utf8Enc, utf8Dec, \ 
    3938        BOM_UTF8, uniWithNone, loadEntireTxtFile, loadEntireFile, writeEntireFile, \ 
    4039        Conjunction, iterCompatibleFilename, \ 
     
    5453         
    5554        try: 
    56             if (not exists(pathEnc(dbfile))): 
     55            if (not exists(longPathEnc(dbfile))): 
    5756                DbStructure.createWikiDB(None, dataDir)  # , True 
    5857        except (IOError, OSError, sqlite.Error), e: 
     
    6059            raise DbWriteAccessError(e) 
    6160 
    62         dbfile = pathDec(dbfile) 
     61        dbfile = longPathDec(dbfile) 
    6362        try: 
    6463            self.connWrap = DbStructure.ConnectWrapSyncCommit( 
     
    209208            traceback.print_exc() 
    210209            raise DbReadAccessError(e) 
    211              
     210 
    212211        try: 
    213212            if len(data) < 1: 
     
    265264#             oldFileName = pathDec(oldFileName) 
    266265 
    267             fileName = self.createWikiWordFileName(word) 
     266            fileName = self.createWikiWordFileName(newWord) 
    268267            newFilePath = os.path.join(head, fileName) 
    269268 
    270             os.rename(pathEnc(os.path.join(self.dataDir, oldFilePath)), 
    271                     pathEnc(os.path.join(self.dataDir, newFilePath))) 
     269            os.rename(longPathEnc(os.path.join(self.dataDir, oldFilePath)), 
     270                    longPathEnc(os.path.join(self.dataDir, newFilePath))) 
    272271 
    273272            self.cachedContentNames = None 
     
    289288            self.cachedContentNames = None 
    290289            if exists(fileName): 
    291                 unlink(fileName) 
     290                os.unlink(fileName) 
    292291        except (IOError, OSError, sqlite.Error), e: 
    293292            traceback.print_exc() 
     
    974973            for path in self.connWrap.execSqlQuerySingleColumn( 
    975974                    "select filepath from wikiwords"): 
    976                 if not os.path.exists(pathEnc(os.path.join(self.dataDir, path))): 
     975                if not os.path.exists(longPathEnc(os.path.join(self.dataDir, path))): 
    977976                    self.connWrap.execSql("delete from wikiwords " 
    978977                            "where filepath = ?", (path,)) 
     
    982981            for path in (diskFiles - dbFiles): 
    983982                fullPath = os.path.join(self.dataDir, path) 
    984                 st = stat(pathEnc(fullPath)) 
     983                st = os.stat(longPathEnc(fullPath)) 
    985984                 
    986985                wikiWord = self._findNewWordForFile(path) 
     
    10381037    def _getAllWikiFileNamesFromDisk(self):   # Used for rebuilding wiki 
    10391038        try: 
    1040             files = glob.glob(pathEnc(join(self.dataDir, 
     1039            files = glob.glob(longPathEnc(join(self.dataDir, 
    10411040                    u'*' + self.pagefileSuffix))) 
    10421041 
    1043             return [pathDec(basename(fn)) for fn in files] 
     1042            return [longPathDec(basename(fn)) for fn in files] 
    10441043             
    10451044#             result = [] 
     
    10931092        """ 
    10941093        path = self.getWikiWordFileNameRaw(wikiWord) 
    1095         return pathEnc(join(self.dataDir, path)) 
     1094        return longPathEnc(join(self.dataDir, path)) 
    10961095 
    10971096 
     
    11551154            if len(existing) > 0: 
    11561155                continue 
    1157             if exists(pathEnc(join(self.dataDir, fileName))): 
     1156            if exists(longPathEnc(join(self.dataDir, fileName))): 
    11581157                continue 
    11591158 
     
    18781877                    if len(existing) > 0: 
    18791878                        continue 
    1880                     if exists(pathEnc(join(self.dataDir, fileName))): 
     1879                    if exists(longPathEnc(join(self.dataDir, fileName))): 
    18811880                        continue 
    18821881 
     
    19191918            if filePath is not None: 
    19201919                # The entry is in an external file, so delete it 
    1921                 os.unlink(join(self.dataDir, filePath)) 
     1920                os.unlink(longPathEnc(join(self.dataDir, filePath))) 
    19221921                self.connWrap.execSql( 
    19231922                        "delete from datablocksexternal " 
  • branches/mbutscher/next/lib/pwiki/wxHelper.py

    r173 r178  
    515515 
    516516class IconCache: 
    517     def __init__(self, iconDir, lowResources): 
     517    def __init__(self, iconDir): 
    518518        self.iconDir = iconDir 
    519         self.lowResources = lowResources 
    520          
    521         # add the gif handler for gif icon support 
    522 #         wxImage_AddHandler(wxGIFHandler()) 
     519#         self.lowResources = lowResources 
     520         
    523521        # default icon is page.gif 
    524522        icons = ['page.gif'] 
     
    550548                id = self.iconImageList.Add(bitmap, wx.NullBitmap) 
    551549 
    552                 if self.lowResources:   # and not icon.startswith("tb_"): 
    553                     bitmap = None 
     550#                 if self.lowResources:   # and not icon.startswith("tb_"): 
     551#                     bitmap = None 
    554552 
    555553                iconname = icon.replace('.gif', '') 
     
    740738    def __init__(*args, **kwargs): 
    741739        wx.ListCtrl.__init__(*args, **kwargs) 
    742          
     740 
    743741    def GetAllSelected(self): 
    744742        result = [] 
  • branches/mbutscher/next/setup.py

    r166 r178  
    99wikidpad = Target( 
    1010    # used for the versioninfo resource 
    11     version = '1.9', 
     11    version = '2.0', 
    1212    name = 'WikidPad', 
    13     copyright = '(C) 2005-2008 Jason Horman, Michael Butscher, Gerhard Reitmayr', 
     13    copyright = '(C) 2005-2009 Jason Horman, Michael Butscher, Gerhard Reitmayr', 
    1414    description = 'Single user wiki notepad', 
    1515    comments='', 
     
    2727                          "optimize": 2, 
    2828                          "ascii": 1, 
    29                           "excludes": excludes}}, 
     29                          "excludes": excludes, 
     30                          "dll_excludes": ["msvcp90.dll"]}}, 
    3031 
    3132    name='WikidPad', 
    32     version = '1.9beta', 
     33    version = '2.0alpha', 
    3334    author = 'Michael Butscher', 
    3435    author_email = 'mbutscher@gmx.de', 
     
    4546#                 ('lib', glob('sql_mar.*')), 
    4647          ('extensions', glob('extensions/*.*')), 
     48          ('extensions/wikidPadParser', glob('extensions/wikidPadParser/*.*')), 
    4749          ('', ['sqlite3.dll', 'WikidPad.xrc', 'readme_Wic.txt', 'gadfly.zip', 
    4850              'langlist.txt', 'appbase.css'] + glob('WikidPad_*.po')), 
  • branches/mbutscher/next/wikidpad_spelladdon.iss

    r167 r178  
    22SolidCompression=true 
    33AppName=WikidPadSpellAddon 
    4 AppVerName=WikidPad spell addon 1.0beta1 
     4AppVerName=WikidPad spell addon 2.0 
    55DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{22A83C29-58A8-4CAB-8EDC-918D74F8429E%7d_is1,InstallLocation|{pf}\WikidPad} 
    66DefaultGroupName=WikidPad 
    77AppID={{8C751029-AC6E-43AC-B2CE-F13EB8D84DAD} 
    8 VersionInfoVersion=1.0 
    9 VersionInfoTextVersion=WikidPad spell addon 1.0beta1 
     8VersionInfoVersion=2.0 
     9VersionInfoTextVersion=WikidPad spell addon 2.0 
    1010LicenseFile=C:\DATEN\Projekte\Wikidpad\Current\license-spelladdon.txt 
    1111AllowNoIcons=true 
    1212ShowLanguageDialog=auto 
    1313Compression=lzma/ultra 
    14 OutputBaseFilename=WP-SpellAddon-1.0beta1 
     14OutputBaseFilename=WP-SpellAddon-2.0 
    1515InternalCompressLevel=ultra 
    1616AppCopyright= 
     
    4141Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\share\enchant\myspell\fr_FR.dic; DestDir: {app}\share\enchant\myspell 
    4242Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\share\enchant\ispell\README.txt; DestDir: {app}\share\enchant\ispell 
    43 Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\libglib-2.0-0.dll; DestDir: {app} 
     43Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\iconv.dll; DestDir: {app} 
    4444Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\intl.dll; DestDir: {app} 
    4545Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\libenchant.dll; DestDir: {app} 
    46 Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\iconv.dll; DestDir: {app} 
     46Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\libglib-2.0-0.dll; DestDir: {app} 
    4747Source: ..\..\..\..\Programme\Python26\Lib\site-packages\enchant\libgmodule-2.0-0.dll; DestDir: {app} 
     48 
    4849Source: license-spelladdon.txt; DestDir: {app} 
  • branches/mbutscher/next/wikidpad_unicode.iss

    r166 r178  
    55Source: dist\icons\*.gif; DestDir: {app}\icons\; Components: Program_files; Flags: onlyifdoesntexist 
    66Source: dist\icons\pwiki.ico; DestDir: {app}\icons\; Components: Program_files; Flags: onlyifdoesntexist 
    7 Source: dist\WikidPadHelp\*; DestDir: {app}\WikidPadHelp\; Components: Gadfly\Help; Flags: recursesubdirs ignoreversion 
    8 Source: dist\w9xpopen.exe; DestDir: {app}; Components: Program_files 
     7Source: dist\WikidPadHelp\*; DestDir: {app}\WikidPadHelp\; Components: Program_files; Flags: recursesubdirs ignoreversion 
     8; Source: dist\w9xpopen.exe; DestDir: {app}; Components: Program_files 
    99Source: dist\license.txt; DestDir: {app}; Components: Program_files 
    10 Source: dist\readme_Wic.txt; DestDir: {app}; Components: Program_files 
    11 Source: dist\python24.dll; DestDir: {app}; Components: Program_files 
    12 Source: dist\MSVCR71.dll; DestDir: {app}; Components: Program_files 
    13 Source: dist\sqlite3.dll; DestDir: {app}; Components: Sqlite 
    14 Source: dist\wxmsw26uh_stc_vc.dll; DestDir: {app}; Components: Program_files 
    15 Source: dist\wxmsw26uh_vc.dll; DestDir: {app}; Components: Program_files 
    16 Source: dist\_activex.pyd; DestDir: {app}; Components: Program_files 
    17 Source: dist\_controls_.pyd; DestDir: {app}; Components: Program_files 
    18 Source: dist\_core_.pyd; DestDir: {app}; Components: Program_files 
     10; Source: dist\readme_Wic.txt; DestDir: {app}; Components: Program_files 
     11Source: dist\python26.dll; DestDir: {app}; Components: Program_files 
     12; Source: dist\MSVCR71.dll; DestDir: {app}; Components: Program_files 
     13Source: dist\sqlite3.dll; DestDir: {app}; Components: Program_files 
     14Source: dist\wxmsw28uh_adv_vc.dll; DestDir: {app}; Components: Program_files 
     15Source: dist\wxmsw28uh_core_vc.dll; DestDir: {app}; Components: Program_files 
     16Source: dist\wxmsw28uh_html_vc.dll; DestDir: {app}; Components: Program_files 
     17Source: dist\wxmsw28uh_stc_vc.dll; DestDir: {app}; Components: Program_files 
     18Source: dist\wxmsw28uh_xrc_vc.dll; DestDir: {app}; Components: Program_files 
     19Source: dist\wxbase28uh_net_vc.dll; DestDir: {app}; Components: Program_files 
     20Source: dist\wxbase28uh_vc.dll; DestDir: {app}; Components: Program_files 
     21Source: dist\wxbase28uh_xml_vc.dll; DestDir: {app}; Components: Program_files 
    1922Source: dist\_ctypes.pyd; DestDir: {app}; Components: Program_files 
    20 Source: dist\_gdi_.pyd; DestDir: {app}; Components: Program_files 
    21 Source: dist\_html.pyd; DestDir: {app}; Components: Program_files 
    22 Source: dist\_misc_.pyd; DestDir: {app}; Components: Program_files 
     23Source: dist\_hashlib.pyd; DestDir: {app}; Components: Program_files 
    2324Source: dist\pyexpat.pyd; DestDir: {app}; Components: Program_files 
    2425Source: dist\_socket.pyd; DestDir: {app}; Components: Program_files 
    25 Source: dist\_stc.pyd; DestDir: {app}; Components: Program_files 
    26 Source: dist\_windows_.pyd; DestDir: {app}; Components: Program_files 
    27 Source: dist\_xrc.pyd; DestDir: {app}; Components: Program_files 
    28 Source: dist\zlib.pyd; DestDir: {app}; Components: Program_files 
     26Source: dist\select.pyd; DestDir: {app}; Components: Program_files 
     27Source: dist\wx._controls_.pyd; DestDir: {app}; Components: Program_files 
     28Source: dist\wx._core_.pyd; DestDir: {app}; Components: Program_files 
     29Source: dist\wx._gdi_.pyd; DestDir: {app}; Components: Program_files 
     30Source: dist\wx._html.pyd; DestDir: {app}; Components: Program_files 
     31Source: dist\wx._misc_.pyd; DestDir: {app}; Components: Program_files 
     32Source: dist\wx._stc.pyd; DestDir: {app}; Components: Program_files 
     33Source: dist\wx._windows_.pyd; DestDir: {app}; Components: Program_files 
     34Source: dist\wx._xrc.pyd; DestDir: {app}; Components: Program_files 
    2935Source: dist\WikidPad.xrc; DestDir: {app}; Components: Program_files 
    3036Source: dist\WikidPad_*.po; DestDir: {app}; Components: Program_files; Flags: ignoreversion sortfilesbyextension 
    3137Source: dist\langlist.txt; DestDir: {app}; Components: Program_files; Flags: ignoreversion 
    32 Source: dist\gadfly.zip; DestDir: {app}; Components: Gadfly 
     38Source: dist\gadfly.zip; DestDir: {app}; Components: Program_files 
    3339Source: dist\library.zip; DestDir: {app}; Components: Program_files 
    3440[Dirs] 
    3541Name: {app}\extensions; Components: Program_files 
    3642Name: {app}\icons; Components: Program_files 
    37 Name: {app}\WikidPadHelp; Components: Gadfly\Help 
    38 Name: {app}\WikidPadHelp\data; Components: Gadfly\Help 
    39 Name: {app}\WikidPadHelp\files 
     43Name: {app}\WikidPadHelp; Components: Program_files 
     44Name: {app}\WikidPadHelp\data; Components: Program_files 
     45Name: {app}\WikidPadHelp\files; Components: Program_files 
    4046Name: {app}\export; Components: Program_files 
     47[Components] 
     48Name: Program_files; Description: Main program files; Flags: fixed; Types: custom compact full 
    4149[Setup] 
    4250SolidCompression=true 
    4351AppName=WikidPad 
    44 AppVerName=WikidPad 1.9beta20 
     52AppVerName=WikidPad 2.0alpha1 
    4553DefaultDirName={pf}\WikidPad 
    4654DefaultGroupName=WikidPad 
    4755AppID={{22A83C29-58A8-4CAB-8EDC-918D74F8429E} 
    48 VersionInfoVersion=1.9.20.0 
    49 VersionInfoTextVersion=WikidPad 1.9beta20 
     56VersionInfoVersion=2.0.1.0 
     57VersionInfoTextVersion=WikidPad 2.0alpha1 
    5058LicenseFile=C:\DATEN\Projekte\Wikidpad\Current\license.txt 
    5159AllowNoIcons=true 
    5260ShowLanguageDialog=yes 
    53 Compression=lzma/ultra 
    54 OutputBaseFilename=WikidPad-1.9beta20 
    55 InternalCompressLevel=ultra 
    56 AppCopyright=© 2005-2008 Jason Horman, Michael Butscher, Gerhard Reitmayr 
     61Compression=lzma/fast 
     62OutputBaseFilename=WikidPad-2.0alpha1 
     63InternalCompressLevel=none 
     64AppCopyright=© 2005-2009 Jason Horman, Michael Butscher, Gerhard Reitmayr 
    5765UsePreviousAppDir=true 
    58 [Components] 
    59 Name: Program_files; Description: Main program files; Flags: fixed; Types: custom compact full 
    60 Name: Gadfly; Description: Gadfly database; Types: custom compact full 
    61 Name: Gadfly\Help; Description: Help wiki; Types: custom compact full 
    62 Name: Sqlite; Description: Sqlite database; Types: custom compact full 
    6366[Icons] 
    64 Name: {code:IconDest|Dummy}\WikidPad; Filename: {app}\WikidPad.exe; IconFilename: {app}\icons\pwiki.ico; Components: Program_files Gadfly\Help; IconIndex: 0 
     67Name: {code:IconDest|Dummy}\WikidPad; Filename: {app}\WikidPad.exe; IconFilename: {app}\icons\pwiki.ico; Components: Program_files; IconIndex: 0 
    6568Name: {code:IconDest|Dummy}\{cm:UninstallProgram, WikidPad}; Filename: {uninstallexe} 
    6669[Registry] 
     
    9093[InstallDelete] 
    9194Name: {app}\regexpr.cache; Type: files 
    92 Name: {app}\icons\tb_data file.gif; Type: files 
    9395[UninstallDelete] 
    9496Name: {app}\regexpr.cache; Type: files