annotate MoinMoin/Page.py @ 5250:00ca621ffbc2 1.9.0rc1

updated underlay
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Nov 2009 00:40:45 +0100
parents d60888cbfb22
children ff8bda185098
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - Page class
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
4
1909
be140a589f11 improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1908
diff changeset
5 Page is used for read-only access to a wiki page. For r/w access see PageEditor.
be140a589f11 improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1908
diff changeset
6 A Page object is used to access a wiki page (in general) as well as to access
be140a589f11 improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1908
diff changeset
7 some specific revision of a wiki page.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
8
1909
be140a589f11 improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1908
diff changeset
9 The RootPage is some virtual page located at / and is mainly used to do namespace
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
10 operations like getting the page list.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
12 Currently, this is all a big mixture between high-level page code, intermediate
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
13 data/underlay layering code, caching code and low-level filesystem storage code.
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
14 To see the filesystem storage layout we use, best is to look into data/pages/
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
15 (underlay dir uses the same format).
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
16
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
17 TODO:
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
18 * Cleanly separate the code into packages for:
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
19 * Page (or rather: Item)
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
20 * Layering
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
21 * Cache
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
22 * Storage
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
23 * ACLs should be handled on a low layer, raising an Exception when access
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
24 is denied, so we won't have security issues just because someone forgot to check
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
25 user.may.read(secretpage).
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
26 * The distinction between a item and a item revision should be clearer.
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
27 * Items can be anything, not just wiki pages, but also files of any mimetype.
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
28 The mimetype hierarchy should be modelled by a MimeTypeItem class hierarchy.
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
29
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1909
diff changeset
30 @copyright: 2000-2004 by Juergen Hermann <jh@web.de>,
3127
ea5383222f2f refactored misc. modules to use own logger instead of request.log
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3110
diff changeset
31 2005-2008 by MoinMoin:ThomasWaldmann,
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
32 2006 by MoinMoin:FlorianFesti,
1993
93877b7d87b9 fixing copyright headers:unified my name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1964
diff changeset
33 2007 by MoinMoin:ReimarBauer
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36
3285
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
37 import os, re, codecs
3110
a48929a5036c logging: make it work correctly by doing logging configuration very early
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3085
diff changeset
38
a48929a5036c logging: make it work correctly by doing logging configuration very early
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3085
diff changeset
39 from MoinMoin import log
a48929a5036c logging: make it work correctly by doing logging configuration very early
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3085
diff changeset
40 logging = log.getLogger(__name__)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 from MoinMoin import config, caching, user, util, wikiutil
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43 from MoinMoin.logfile import eventlog
1801
3369445b4aa8 move the dircache stuff to MoinMoin.util.filesys and disable it on win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1796
diff changeset
44 from MoinMoin.util import filesys
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45
1126
fd05b2dc86a4 Now it even works on Python < 2.5
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1124
diff changeset
46 def is_cache_exception(e):
fd05b2dc86a4 Now it even works on Python < 2.5
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1124
diff changeset
47 args = e.args
fd05b2dc86a4 Now it even works on Python < 2.5
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1124
diff changeset
48 return not (len(args) != 1 or args[0] != 'CacheNeedsUpdate')
fd05b2dc86a4 Now it even works on Python < 2.5
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1124
diff changeset
49
1618
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
50
1624
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
51 class ItemCache:
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
52 """ Cache some page item related data, as meta data or pagelist
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
53
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
54 We only cache this to RAM in request.cfg (this is the only kind of
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
55 server object we have), because it might be too big for pickling it
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
56 in and out.
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
57 """
1624
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
58 def __init__(self, name):
1632
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
59 """ Initialize ItemCache object.
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
60 @param name: name of the object, used for display in logging and
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
61 influences behaviour of refresh().
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
62 """
1624
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
63 self.name = name
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
64 self.cache = {}
1836
42fb37416fe8 fix race condition for ItemCache.news
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1830
diff changeset
65 self.log_pos = None # TODO: initialize this to EOF pos of log
42fb37416fe8 fix race condition for ItemCache.news
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1830
diff changeset
66 # to avoid reading in the whole log on first request
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
67 self.requests = 0
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
68 self.hits = 0
1853
3ddf2193a16e reduced cache logging
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1836
diff changeset
69 self.loglevel = logging.NOTSET
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
70
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
71 def putItem(self, request, name, key, data):
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
72 """ Remembers some data for item name under a key.
1632
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
73 @param request: currently unused
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
74 @param name: name of the item (page), unicode
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
75 @param key: used as secondary access key after name
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
76 @param data: the data item that should be remembered
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
77 """
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1639
diff changeset
78 d = self.cache.setdefault(name, {})
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1639
diff changeset
79 d[key] = data
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
80
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
81 def getItem(self, request, name, key):
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
82 """ Returns some item stored for item name under key.
1632
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
83 @param request: the request object
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
84 @param name: name of the item (page), unicode
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
85 @param key: used as secondary access key after name
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
86 @return: the data or None, if there is no such name or key.
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
87 """
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
88 self.refresh(request)
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
89 try:
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
90 data = self.cache[name][key]
1626
189bbdd56620 ItemCache: minor code cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1624
diff changeset
91 self.hits += 1
189bbdd56620 ItemCache: minor code cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1624
diff changeset
92 hit_str = 'hit'
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
93 except KeyError:
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
94 data = None
1626
189bbdd56620 ItemCache: minor code cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1624
diff changeset
95 hit_str = 'miss'
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
96 self.requests += 1
1853
3ddf2193a16e reduced cache logging
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1836
diff changeset
97 logging.log(self.loglevel, "%s cache %s (h/r %2.1f%%) for %r %r" % (
1624
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
98 self.name,
1622
7d199191cb1f use new item meta data cache for acls
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1621
diff changeset
99 hit_str,
1632
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
100 float(self.hits * 100) / self.requests,
1622
7d199191cb1f use new item meta data cache for acls
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1621
diff changeset
101 name,
7d199191cb1f use new item meta data cache for acls
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1621
diff changeset
102 key,
7d199191cb1f use new item meta data cache for acls
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1621
diff changeset
103 ))
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
104 return data
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
105
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
106 def refresh(self, request):
1632
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
107 """ Refresh the cache - if anything has changed in the wiki, we see it
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
108 in the edit-log and either delete cached data for the changed items
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
109 (for 'meta') or the complete cache ('pagelists').
f89736ab2c8e ItemCache: CHANGES entry, epydoc comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1631
diff changeset
110 @param request: the request object
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
111 """
4149
769850545997 Removed request.editlog
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3620
diff changeset
112 from MoinMoin.logfile import editlog
769850545997 Removed request.editlog
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3620
diff changeset
113 elog = editlog.EditLog(request)
1836
42fb37416fe8 fix race condition for ItemCache.news
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1830
diff changeset
114 old_pos = self.log_pos
42fb37416fe8 fix race condition for ItemCache.news
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1830
diff changeset
115 new_pos, items = elog.news(old_pos)
1624
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
116 if items:
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
117 if self.name == 'meta':
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
118 for item in items:
1853
3ddf2193a16e reduced cache logging
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1836
diff changeset
119 logging.log(self.loglevel, "cache: removing %r" % item)
1624
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
120 try:
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
121 del self.cache[item]
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
122 except:
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
123 pass
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
124 elif self.name == 'pagelists':
1853
3ddf2193a16e reduced cache logging
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1836
diff changeset
125 logging.log(self.loglevel, "cache: clearing pagelist cache")
1624
0b0b94e1680f cache pagelist using new cache mechanism
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1623
diff changeset
126 self.cache = {}
1836
42fb37416fe8 fix race condition for ItemCache.news
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1830
diff changeset
127 self.log_pos = new_pos # important to do this at the end -
42fb37416fe8 fix race condition for ItemCache.news
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1830
diff changeset
128 # avoids threading race conditions
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
129
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
130
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
131 class Page(object):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
132 """ Page - Manage an (immutable) page associated with a WikiName.
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
133 To change a page's content, use the PageEditor class.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
134 """
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
135 def __init__(self, request, page_name, **kw):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
136 """ Create page object.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
137
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
138 Note that this is a 'lean' operation, since the text for the page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
139 is loaded on demand. Thus, things like `Page(name).link_to()` are
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
140 efficient.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
141
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
142 @param page_name: WikiName of the page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
143 @keyword rev: number of older revision
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
144 @keyword formatter: formatter instance or mimetype str,
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
145 None or no kw arg will use default formatter
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
146 @keyword include_self: if 1, include current user (default: 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
147 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
148 self.request = request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
149 self.cfg = request.cfg
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
150 self.page_name = page_name
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
151 self.rev = kw.get('rev', 0) # revision of this page
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
152 self.include_self = kw.get('include_self', 0)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
153
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
154 formatter = kw.get('formatter', None)
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
155 if isinstance(formatter, (str, unicode)): # mimetype given
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
156 mimetype = str(formatter)
622
8fba6d15a2f5 make request.(html_)formatter available early and use it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 620
diff changeset
157 self.formatter = None
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
158 self.output_mimetype = mimetype
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
159 self.default_formatter = mimetype == "text/html"
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
160 elif formatter is not None: # formatter instance given
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
161 self.formatter = formatter
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
162 self.default_formatter = 0
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
163 self.output_mimetype = "text/todo" # TODO where do we get this value from?
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
164 else:
622
8fba6d15a2f5 make request.(html_)formatter available early and use it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 620
diff changeset
165 self.formatter = None
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
166 self.default_formatter = 1
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
167 self.output_mimetype = "text/html"
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
168
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
169 self.output_charset = config.charset # correct for wiki pages
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1564
diff changeset
170
1627
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
171 self._text_filename_force = None
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
172 self.hilite_re = None
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
173
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
174 self.__body = None # unicode page body == metadata + data
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
175 self.__body_modified = 0 # was __body modified in RAM so it differs from disk?
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
176 self.__meta = None # list of raw tuples of page metadata (currently: the # stuff at top of the page)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
177 self.__pi = None # dict of preprocessed page metadata (processing instructions)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
178 self.__data = None # unicode page data = body - metadata
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
179
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
180 self.reset()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
181
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
182 def reset(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
183 """ Reset page state """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
184 page_name = self.page_name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
185 # page_name quoted for file system usage, needs to be reset to
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
186 # None when pagename changes
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
187
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
188 qpagename = wikiutil.quoteWikinameFS(page_name)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
189 self.page_name_fs = qpagename
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
190
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
191 # the normal and the underlay path used for this page
1618
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
192 normalpath = os.path.join(self.cfg.data_dir, "pages", qpagename)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
193 if not self.cfg.data_underlay_dir is None:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
194 underlaypath = os.path.join(self.cfg.data_underlay_dir, "pages", qpagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
195 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
196 underlaypath = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
197
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
198 # TUNING - remember some essential values
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
199
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
200 # does the page come from normal page storage (0) or from
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
201 # underlay dir (1) (can be used as index into following list)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
202 self._underlay = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
203
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
204 # path to normal / underlay page dir
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
205 self._pagepath = [normalpath, underlaypath]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
206
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
207 # now we define some properties to lazy load some attributes on first access:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
208
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
209 def get_body(self):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
210 if self.__body is None:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
211 # try to open file
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
212 try:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
213 f = codecs.open(self._text_filename(), 'rb', config.charset)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
214 except IOError, er:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
215 import errno
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
216 if er.errno == errno.ENOENT:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
217 # just doesn't exist, return empty text (note that we
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
218 # never store empty pages, so this is detectable and also
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
219 # safe when passed to a function expecting a string)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
220 return ""
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
221 else:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
222 raise
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
223
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
224 # read file content and make sure it is closed properly
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
225 try:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
226 text = f.read()
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
227 text = self.decodeTextMimeType(text)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
228 self.__body = text
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
229 finally:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
230 f.close()
2057
c071cddde1e4 Added a cosmetic newline to test if push works.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2036
diff changeset
231 return self.__body
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
232
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
233 def set_body(self, newbody):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
234 self.__body = newbody
1885
9e4aeac3abff Page: if we set a new body, we need to invalidate old meta and old data
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1882
diff changeset
235 self.__meta = None
9e4aeac3abff Page: if we set a new body, we need to invalidate old meta and old data
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1882
diff changeset
236 self.__data = None
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
237 body = property(fget=get_body, fset=set_body) # complete page text
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
238
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
239 def get_meta(self):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
240 if self.__meta is None:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
241 self.__meta, self.__data = wikiutil.get_processing_instructions(self.body)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
242 return self.__meta
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
243 meta = property(fget=get_meta) # processing instructions, ACLs (upper part of page text)
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
244
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
245 def get_data(self):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
246 if self.__data is None:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
247 self.__meta, self.__data = wikiutil.get_processing_instructions(self.body)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
248 return self.__data
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
249 data = property(fget=get_data) # content (lower part of page text)
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
250
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
251 def get_pi(self):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
252 if self.__pi is None:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
253 self.__pi = self.parse_processing_instructions()
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
254 return self.__pi
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
255 pi = property(fget=get_pi) # processed meta stuff
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
256
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
257 def getlines(self):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
258 """ Return a list of all lines in body.
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
259
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
260 @rtype: list
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
261 @return: list of strs body_lines
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
262 """
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
263 return self.body.split('\n')
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
264
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
265 def get_raw_body(self):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
266 """ Load the raw markup from the page file.
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
267
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
268 @rtype: unicode
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
269 @return: raw page contents of this page, unicode
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
270 """
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
271 return self.body
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
272
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
273 def get_raw_body_str(self):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
274 """ Returns the raw markup from the page file, as a string.
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
275
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
276 @rtype: str
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
277 @return: raw page contents of this page, utf-8-encoded
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
278 """
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
279 return self.body.encode("utf-8")
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
280
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
281 def set_raw_body(self, body, modified=0):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
282 """ Set the raw body text (prevents loading from disk).
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
283
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
284 TODO: this should not be a public function, as Page is immutable.
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
285
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
286 @param body: raw body text
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
287 @param modified: 1 means that we internally modified the raw text and
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
288 that it is not in sync with the page file on disk. This is
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
289 used e.g. by PageEditor when previewing the page.
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
290 """
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
291 self.body = body
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
292 self.__body_modified = modified
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
293
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
294 def get_current_from_pagedir(self, pagedir):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
295 """ Get the current revision number from an arbitrary pagedir.
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
296 Does not modify page object's state, uncached, direct disk access.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
297 @param pagedir: the pagedir with the 'current' file to read
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
298 @return: int currentrev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
299 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
300 revfilename = os.path.join(pagedir, 'current')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
301 try:
1619
a103f4d38ce5 cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1618
diff changeset
302 revfile = file(revfilename)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
303 revstr = revfile.read().strip()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
304 revfile.close()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
305 rev = int(revstr)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
306 except:
1796
57f12932915f cleaning up comments, minor refactorings in heading formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
307 rev = 99999999 # XXX do some better error handling
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
308 return rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
309
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
310 def get_rev_dir(self, pagedir, rev=0):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
311 """ Get a revision of a page from an arbitrary pagedir.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
312
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
313 Does not modify page object's state, uncached, direct disk access.
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
314
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
315 @param pagedir: the path to the page storage area
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
316 @param rev: int revision to get (default is 0 and means the current
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
317 revision (in this case, the real revint is returned)
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
318 @return: (str path to file of the revision,
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
319 int realrevint,
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
320 bool exists)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
321 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
322 if rev == 0:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
323 rev = self.get_current_from_pagedir(pagedir)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
324
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
325 revstr = '%08d' % rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
326 pagefile = os.path.join(pagedir, 'revisions', revstr)
1681
fc03cd8ff0f3 avoid accessing invalid page revisions, tune caching code (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1675
diff changeset
327 if rev != 99999999:
fc03cd8ff0f3 avoid accessing invalid page revisions, tune caching code (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1675
diff changeset
328 exists = os.path.exists(pagefile)
fc03cd8ff0f3 avoid accessing invalid page revisions, tune caching code (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1675
diff changeset
329 if exists:
fc03cd8ff0f3 avoid accessing invalid page revisions, tune caching code (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1675
diff changeset
330 self._setRealPageName(pagedir)
fc03cd8ff0f3 avoid accessing invalid page revisions, tune caching code (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1675
diff changeset
331 else:
fc03cd8ff0f3 avoid accessing invalid page revisions, tune caching code (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1675
diff changeset
332 exists = False
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
333 return pagefile, rev, exists
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
334
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
335 def _setRealPageName(self, pagedir):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
336 """ Set page_name to the real case of page name
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
337
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
338 On case insensitive file system, "pagename" exists even if the
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
339 real page name is "PageName" or "PAGENAME". This leads to
1619
a103f4d38ce5 cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1618
diff changeset
340 confusion in urls, links and logs.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
341 See MoinMoinBugs/MacHfsPlusCaseInsensitive
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
342
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
343 Correct the case of the page name. Elements created from the
1619
a103f4d38ce5 cosmetic changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1618
diff changeset
344 page name in reset() are not updated because it's too messy, and
3085
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
345 this fix seems to be enough for now.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
346
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
347 Problems to fix later:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
348
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 - ["helponnavigation"] link to HelpOnNavigation but not
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
350 considered as backlink.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
351
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
352 @param pagedir: the storage path to the page directory
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
353 """
3085
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
354 if self._text_filename_force is None:
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
355 # we only do this for normal pages, but not for the MissingPage,
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
356 # because the code below is wrong in that case
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
357 realPath = util.filesys.realPathCase(pagedir)
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
358 if realPath is not None:
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
359 realPath = wikiutil.unquoteWikiname(realPath)
fdb68a8f92da fix wrong pagename when creating new pages on Mac OS X (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3013
diff changeset
360 self.page_name = realPath[-len(self.page_name):]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
361
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
362 def get_rev(self, use_underlay=-1, rev=0):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
363 """ Get information about a revision.
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
364
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
365 filename, number, and (existance test) of this page and revision.
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
366
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
367 @param use_underlay: -1 == auto, 0 == normal, 1 == underlay
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
368 @param rev: int revision to get (default is 0 and means the current
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
369 revision (in this case, the real revint is returned)
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
370 @return: (str path to current revision of page,
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
371 int realrevint,
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
372 bool exists)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
373 """
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
374 def layername(underlay):
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
375 if underlay == -1:
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
376 return 'layer_auto'
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
377 elif underlay == 0:
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
378 return 'layer_normal'
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
379 else: # 1
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
380 return 'layer_underlay'
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
381
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
382 request = self.request
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
383 cache_name = self.page_name
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
384 cache_key = layername(use_underlay)
1627
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
385 if self._text_filename_force is None:
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
386 cache_data = request.cfg.cache.meta.getItem(request, cache_name, cache_key)
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
387 if cache_data and (rev == 0 or rev == cache_data[1]):
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
388 # we got the correct rev data from the cache
1716
9a3290aeff36 fixed cached inconsistency caused by DeletePage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1698
diff changeset
389 #logging.debug("got data from cache: %r %r %r" % cache_data)
1627
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
390 return cache_data
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
391
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
392 # Figure out if we should use underlay or not, if needed.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
393 if use_underlay == -1:
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
394 underlay, pagedir = self.getPageStatus(check_create=0)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
395 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
396 underlay, pagedir = use_underlay, self._pagepath[use_underlay]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
397
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
398 # Find current revision, if automatic selection is requested.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
399 if rev == 0:
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
400 realrev = self.get_current_from_pagedir(pagedir)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
402 realrev = rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
404 data = self.get_rev_dir(pagedir, realrev)
1627
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
405 if rev == 0 and self._text_filename_force is None:
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
406 # we only save the current rev to the cache
1621
cce18ece4ce7 use itemname and key for item meta data cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1620
diff changeset
407 request.cfg.cache.meta.putItem(request, cache_name, cache_key, data)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
408
1620
a86f20280204 implement and use ItemMetaDataCache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1619
diff changeset
409 return data
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
410
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
411 def current_rev(self):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
412 """ Return number of current revision.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
413
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
414 This is the same as get_rev()[1].
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
415
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
416 @return: int revision
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
417 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
418 pagefile, rev, exists = self.get_rev()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 return rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
420
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
421 def get_real_rev(self):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
422 """ Returns the real revision number of this page.
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
423 A rev==0 is translated to the current revision.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
424
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
425 @returns: revision number > 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
426 @rtype: int
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
427 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
428 if self.rev == 0:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
429 return self.current_rev()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
430 return self.rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
431
1698
35ebda626b4b getPageBasePath: add default value for use_underlay and improve docstring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1693
diff changeset
432 def getPageBasePath(self, use_underlay=-1):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
433 """ Get full path to a page-specific storage area. `args` can
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
434 contain additional path components that are added to the base path.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
435
1698
35ebda626b4b getPageBasePath: add default value for use_underlay and improve docstring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1693
diff changeset
436 @param use_underlay: force using a specific pagedir, default -1
35ebda626b4b getPageBasePath: add default value for use_underlay and improve docstring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1693
diff changeset
437 -1 = automatically choose page dir
35ebda626b4b getPageBasePath: add default value for use_underlay and improve docstring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1693
diff changeset
438 1 = use underlay page dir
35ebda626b4b getPageBasePath: add default value for use_underlay and improve docstring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1693
diff changeset
439 0 = use standard page dir
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
440 @rtype: string
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
441 @return: int underlay,
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
442 str the full path to the storage area
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
443 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
444 standardpath, underlaypath = self._pagepath
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
445 if underlaypath is None:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
446 use_underlay = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
447
1618
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
448 if use_underlay == -1: # automatic
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
449 if self._underlay is None:
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
450 underlay, path = 0, standardpath
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
451 pagefile, rev, exists = self.get_rev(use_underlay=0)
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
452 if not exists:
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
453 pagefile, rev, exists = self.get_rev(use_underlay=1)
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
454 if exists:
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
455 underlay, path = 1, underlaypath
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
456 self._underlay = underlay
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
457 else:
1618
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
458 underlay = self._underlay
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
459 path = self._pagepath[underlay]
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
460 else: # normal or underlay
e682a1ea7a68 remove hierarchical page storage support, split new RootPage class off from Page class
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1605
diff changeset
461 underlay, path = use_underlay, self._pagepath[use_underlay]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
462
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
463 return underlay, path
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
464
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
465 def getPageStatus(self, *args, **kw):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
466 """ Get full path to a page-specific storage area. `args` can
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
467 contain additional path components that are added to the base path.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
468
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
469 @param args: additional path components
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
470 @keyword use_underlay: force using a specific pagedir, default '-1'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
471 -1 = automatically choose page dir
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
472 1 = use underlay page dir
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
473 0 = use standard page dir
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
474 @keyword check_create: if true, ensures that the path requested really exists
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
475 (if it doesn't, create all directories automatically).
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
476 (default true)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
477 @keyword isfile: is the last component in args a filename? (default is false)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
478 @rtype: string
354
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
479 @return: (int underlay (1 if using underlay, 0 otherwise),
4eddf2f2c513 Merged doc string optimisations from MoinMoin:RichardDarst/DocPatches
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 335
diff changeset
480 str the full path to the storage area )
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
481 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
482 check_create = kw.get('check_create', 1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
483 isfile = kw.get('isfile', 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
484 use_underlay = kw.get('use_underlay', -1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
485 underlay, path = self.getPageBasePath(use_underlay)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
486 fullpath = os.path.join(*((path, ) + args))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
487 if check_create:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
488 if isfile:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
489 dirname, filename = os.path.split(fullpath)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
490 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
491 dirname = fullpath
2930
dc0f45b10ae6 fix os.path.exists() vs. os.makedirs() race
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2845
diff changeset
492 try:
1428
8a89649ab5f0 remove util.filesys.make[dD]irs - not needed any more due to os.umask() use
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1419
diff changeset
493 os.makedirs(dirname)
2930
dc0f45b10ae6 fix os.path.exists() vs. os.makedirs() race
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2845
diff changeset
494 except OSError, err:
dc0f45b10ae6 fix os.path.exists() vs. os.makedirs() race
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2845
diff changeset
495 if not os.path.exists(dirname):
dc0f45b10ae6 fix os.path.exists() vs. os.makedirs() race
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2845
diff changeset
496 raise err
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
497 return underlay, fullpath
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
498
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
499 def getPagePath(self, *args, **kw):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
500 """ Return path to the page storage area. """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
501 return self.getPageStatus(*args, **kw)[1]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
502
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
503 def _text_filename(self, **kw):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
504 """ The name of the page file, possibly of an older page.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
505
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
506 @keyword rev: page revision, overriding self.rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
507 @rtype: string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
508 @return: complete filename (including path) to this page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
509 """
1627
82e8a6a2eb1b ItemCache usage: fix handling of Missing[Home]Page
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1626
diff changeset
510 if self._text_filename_force is not None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
511 return self._text_filename_force
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
512 rev = kw.get('rev', 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
513 if not rev and self.rev:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
514 rev = self.rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
515 fname, rev, exists = self.get_rev(-1, rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
516 return fname
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
517
3547
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
518 def editlog_entry(self):
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
519 """ Return the edit-log entry for this Page object (can be an old revision).
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
520 """
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
521 request = self.request
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
522 use_cache = self.rev == 0 # use the cache for current rev
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
523 if use_cache:
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
524 cache_name, cache_key = self.page_name, 'lastlog'
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
525 entry = request.cfg.cache.meta.getItem(request, cache_name, cache_key)
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
526 else:
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
527 entry = None
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
528 if entry is None:
1631
9f02d3c64f48 use ItemCache for page local edit-log, speedup InterWikiMap page handling if page does not exist
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1629
diff changeset
529 from MoinMoin.logfile import editlog
3548
419335c7d8ad optimize Page.editlog_entry(): read log in reverse direction, move str/int conversion outside the loop
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3547
diff changeset
530 wanted_rev = "%08d" % self.get_real_rev()
419335c7d8ad optimize Page.editlog_entry(): read log in reverse direction, move str/int conversion outside the loop
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3547
diff changeset
531 edit_log = editlog.EditLog(request, rootpagename=self.page_name)
419335c7d8ad optimize Page.editlog_entry(): read log in reverse direction, move str/int conversion outside the loop
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3547
diff changeset
532 for entry in edit_log.reverse():
419335c7d8ad optimize Page.editlog_entry(): read log in reverse direction, move str/int conversion outside the loop
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3547
diff changeset
533 if entry.rev == wanted_rev:
3547
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
534 break
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
535 else:
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
536 entry = () # don't use None
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
537 if use_cache:
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
538 request.cfg.cache.meta.putItem(request, cache_name, cache_key, entry)
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
539 return entry
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
540
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
541 def edit_info(self):
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
542 """ Return timestamp/editor info for this Page object (can be an old revision).
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
543
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
544 Note: if you ask about a deleted revision, it will report timestamp and editor
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
545 for the delete action (in the edit-log, this is just a SAVE).
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
546
637
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 635
diff changeset
547 This is used by MoinMoin/xmlrpc/__init__.py.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
548
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
549 @rtype: dict
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
550 @return: timestamp and editor information
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
551 """
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
552 line = self.editlog_entry()
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
553 if line:
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
554 editordata = line.getInterwikiEditorData(self.request)
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
555 if editordata[0] == 'interwiki':
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
556 editor = "%s:%s" % editordata[1]
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
557 else:
4470
ea2aa935fbde cfg.log_remote_addr (default: True) controls whether moin logs remote's IP/hostname to edit-log and event-log
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3620
diff changeset
558 editor = editordata[1] # ip or email or anon
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
559 result = {
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
560 'timestamp': line.ed_time_usecs,
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
561 'editor': editor,
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
562 }
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
563 del line
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
564 else:
3550
65eac5f65a11 Page.edit_info: better return empty dict than None when no edit-log entry is found
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3549
diff changeset
565 result = {}
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
566 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
567
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
568 def last_edit(self, request):
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
569 # XXX usage of last_edit is DEPRECATED - use edit_info()
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
570 if not self.exists(): # XXX doesn't make much sense, but still kept
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
571 return None # XXX here until we remove last_edit()
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3518
diff changeset
572 return self.edit_info()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
573
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
574 def lastEditInfo(self, request=None):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
575 """ Return the last edit info.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
576
3547
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
577 Note: if you ask about a deleted revision, it will report timestamp and editor
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
578 for the delete action (in the edit-log, this is just a SAVE).
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
579
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
580 @param request: the request object (DEPRECATED, unused)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
581 @rtype: dict
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
582 @return: timestamp and editor information
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
583 """
3547
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
584 log = self.editlog_entry()
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
585 if log:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
586 request = self.request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
587 editor = log.getEditor(request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
588 time = wikiutil.version2timestamp(log.ed_time_usecs)
3547
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
589 time = request.user.getFormattedDateTime(time) # Use user time format
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
590 result = {'editor': editor, 'time': time}
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
591 del log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
592 else:
3547
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
593 result = {}
889b37b6441c get rid of broken Page._last_edited(), use Page.editlog_entry() from now on
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3546
diff changeset
594 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
595
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
596 def isWritable(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
597 """ Can this page be changed?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
598
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
599 @rtype: bool
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
600 @return: true, if this page is writable or does not exist
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
601 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
602 return os.access(self._text_filename(), os.W_OK) or not self.exists()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
603
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
604 def isUnderlayPage(self, includeDeleted=True):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
605 """ Does this page live in the underlay dir?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
606
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
607 Return true even if the data dir has a copy of this page. To
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
608 check for underlay only page, use ifUnderlayPage() and not
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
609 isStandardPage()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
610
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
611 @param includeDeleted: include deleted pages
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
612 @rtype: bool
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
613 @return: true if page lives in the underlay dir
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
614 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
615 return self.exists(domain='underlay', includeDeleted=includeDeleted)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
616
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
617 def isStandardPage(self, includeDeleted=True):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
618 """ Does this page live in the data dir?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
619
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
620 Return true even if this is a copy of an underlay page. To check
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
621 for data only page, use isStandardPage() and not isUnderlayPage().
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
622
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
623 @param includeDeleted: include deleted pages
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
624 @rtype: bool
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
625 @return: true if page lives in the data dir
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
626 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
627 return self.exists(domain='standard', includeDeleted=includeDeleted)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
628
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
629 def exists(self, rev=0, domain=None, includeDeleted=False):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
630 """ Does this page exist?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
631
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
632 This is the lower level method for checking page existence. Use
1626
189bbdd56620 ItemCache: minor code cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1624
diff changeset
633 the higher level methods isUnderlayPage and isStandardPage for
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
634 cleaner code.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
635
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
636 @param rev: revision to look for. Default: check current
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
637 @param domain: where to look for the page. Default: look in all,
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
638 available values: 'underlay', 'standard'
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
639 @param includeDeleted: ignore page state, just check its pagedir
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
640 @rtype: bool
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
641 @return: true, if page exists
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
642 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
643 # Edge cases
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
644 if domain == 'underlay' and not self.request.cfg.data_underlay_dir:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
645 return False
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
646
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
647 if includeDeleted:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
648 # Look for page directory, ignore page state
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
649 if domain is None:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
650 checklist = [0, 1]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
651 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
652 checklist = [domain == 'underlay']
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
653 for use_underlay in checklist:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
654 pagedir = self.getPagePath(use_underlay=use_underlay, check_create=0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
655 if os.path.exists(pagedir):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
656 return True
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
657 return False
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
658 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
659 # Look for non-deleted pages only, using get_rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
660 if not rev and self.rev:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
661 rev = self.rev
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
662
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
663 if domain is None:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
664 use_underlay = -1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
665 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
666 use_underlay = domain == 'underlay'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
667 d, d, exists = self.get_rev(use_underlay, rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
668 return exists
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
669
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
670 def size(self, rev=0):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
671 """ Get Page size.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
672
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
673 @rtype: int
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
674 @return: page size, 0 for non-existent pages.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
675 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
676 if rev == self.rev: # same revision as self
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
677 if self.__body is not None:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
678 return len(self.__body)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
679
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
680 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
681 return os.path.getsize(self._text_filename(rev=rev))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
682 except EnvironmentError, e:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
683 import errno
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
684 if e.errno == errno.ENOENT:
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
685 return 0
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
686 raise
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
687
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
688 def mtime_usecs(self):
3549
56b476878a1c Page.mtime_usecs(): reuse .editlog_entry() code and cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3548
diff changeset
689 """ Get modification timestamp of this page (from edit-log, can be for an old revision).
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
690
3549
56b476878a1c Page.mtime_usecs(): reuse .editlog_entry() code and cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3548
diff changeset
691 @rtype: int
56b476878a1c Page.mtime_usecs(): reuse .editlog_entry() code and cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3548
diff changeset
692 @return: mtime of page (or 0 if page / edit-log entry does not exist)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
693 """
3549
56b476878a1c Page.mtime_usecs(): reuse .editlog_entry() code and cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3548
diff changeset
694 entry = self.editlog_entry()
56b476878a1c Page.mtime_usecs(): reuse .editlog_entry() code and cache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3548
diff changeset
695 return entry and entry.ed_time_usecs or 0
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
696
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
697 def mtime_printable(self, request):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
698 """ Get printable (as per user's preferences) modification timestamp of this page.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
699
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
700 @rtype: string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
701 @return: formatted string with mtime of page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
702 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
703 t = self.mtime_usecs()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
704 if not t:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
705 result = "0" # TODO: i18n, "Ever", "Beginning of time"...?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
706 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
707 result = request.user.getFormattedDateTime(
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
708 wikiutil.version2timestamp(t))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
709 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
710
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
711 def split_title(self, force=0):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
712 """ Return a string with the page name split by spaces, if the user wants that.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
713
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
714 @param force: if != 0, then force splitting the page_name
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
715 @rtype: unicode
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
716 @return: pagename of this page, splitted into space separated words
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
717 """
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
718 request = self.request
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
719 if not force and not request.user.wikiname_add_spaces:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
720 return self.page_name
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
721
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
722 # look for the end of words and the start of a new word,
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
723 # and insert a space there
2250
07fdbda38be2 move split_regex to config (so it is compiled only once)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2223
diff changeset
724 splitted = config.split_regex.sub(r'\1 \2', self.page_name)
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
725 return splitted
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
726
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3175
diff changeset
727 def url(self, request, querystr=None, anchor=None, relative=False, **kw):
1816
4a31739bc6e1 Page.url(): removed escaping support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1809
diff changeset
728 """ Return complete URL for this page, including scriptname.
4a31739bc6e1 Page.url(): removed escaping support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1809
diff changeset
729 The URL is NOT escaped, if you write it to HTML, use wikiutil.escape
4a31739bc6e1 Page.url(): removed escaping support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1809
diff changeset
730 (at least if you have a querystr, to escape the & chars).
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
731
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
732 @param request: the request object
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
733 @param querystr: the query string to add after a "?" after the url
102
a54cebaab73e move make / parse query string functions to wikiutil, make unicode-safe
Thomas Waldmann <tw@waldmann-edv.de>
parents: 101
diff changeset
734 (str or dict, see wikiutil.makeQueryString)
1339
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
735 @param anchor: if specified, make a link to this anchor
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3175
diff changeset
736 @param relative: create a relative link (default: False), note that this
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3175
diff changeset
737 changed in 1.7, in 1.6, the default was True.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
738 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
739 @return: complete url of this page, including scriptname
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
740 """
1816
4a31739bc6e1 Page.url(): removed escaping support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1809
diff changeset
741 assert(isinstance(anchor, (type(None), str, unicode)))
1339
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
742 # Create url, excluding scriptname
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
743 url = wikiutil.quoteWikinameURL(self.page_name)
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
744 if querystr:
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
745 if isinstance(querystr, dict):
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
746 action = querystr.get('action', None)
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
747 else:
1796
57f12932915f cleaning up comments, minor refactorings in heading formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
748 action = None # we don't support getting the action out of a str
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
749
102
a54cebaab73e move make / parse query string functions to wikiutil, make unicode-safe
Thomas Waldmann <tw@waldmann-edv.de>
parents: 101
diff changeset
750 querystr = wikiutil.makeQueryString(querystr)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
751
1339
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
752 # make action URLs denyable by robots.txt:
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
753 if action is not None and request.cfg.url_prefix_action is not None:
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
754 url = "%s/%s/%s" % (request.cfg.url_prefix_action, action, url)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
755 url = '%s?%s' % (url, querystr)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
756
4235
a6c315ff8d66 Make more use of werkzeugs Href object for URL-generation in MoinMoin
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4183
diff changeset
757 if not relative:
4242
f61dcab20a3e Reverted use of Href in Page.url (breaks querystrings)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4237
diff changeset
758 url = '%s/%s' % (request.script_root, url)
4235
a6c315ff8d66 Make more use of werkzeugs Href object for URL-generation in MoinMoin
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4183
diff changeset
759
1339
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
760 # Add anchor
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
761 if anchor:
4560
050428d1c044 Fix processing of anchors (fragment identifiers), see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4497
diff changeset
762 fmt = getattr(self, 'formatter', request.html_formatter)
050428d1c044 Fix processing of anchors (fragment identifiers), see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4497
diff changeset
763 if fmt:
050428d1c044 Fix processing of anchors (fragment identifiers), see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4497
diff changeset
764 anchor = fmt.sanitize_to_id(anchor)
050428d1c044 Fix processing of anchors (fragment identifiers), see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4497
diff changeset
765 url = "%s#%s" % (url, anchor)
1339
544b931cd965 new setting url_prefix_action, cleanup page.url/link_to, wikiutil.link_tag
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1311
diff changeset
766
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
767 return url
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
768
1341
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
769 def link_to_raw(self, request, text, querystr=None, anchor=None, **kw):
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
770 """ core functionality of link_to, without the magic """
3235
4c0121050056 fix for previous changeset: this place really needs relative=True
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
771 url = self.url(request, querystr, anchor=anchor, relative=True) # scriptName is added by link_tag
1341
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
772 # escaping is done by link_tag -> formatter.url -> ._open()
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
773 link = wikiutil.link_tag(request, url, text,
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
774 formatter=getattr(self, 'formatter', None), **kw)
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
775 return link
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
776
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
777 def link_to(self, request, text=None, querystr=None, anchor=None, **kw):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
778 """ Return HTML markup that links to this page.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
779
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
780 See wikiutil.link_tag() for possible keyword parameters.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
781
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
782 @param request: the request object
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
783 @param text: inner text of the link - it gets automatically escaped
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
784 @param querystr: the query string to add after a "?" after the url
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
785 @param anchor: if specified, make a link to this anchor
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
786 @keyword on: opening/closing tag only
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
787 @keyword attachment_indicator: if 1, add attachment indicator after link tag
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
788 @keyword css_class: css class to use
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
789 @rtype: string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
790 @return: formatted link
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
791 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
792 if not text:
1776
fc75423e26a8 remove unneeded request param from page.split_title()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1756
diff changeset
793 text = self.split_title()
1341
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
794 text = wikiutil.escape(text)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
795
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
796 # Add css class for non existing page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
797 if not self.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
798 kw['css_class'] = 'nonexistent'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
799
1964
911fe470bfae WordIndex/TitleIndex: fix invalid <a> tag attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
800 attachment_indicator = kw.get('attachment_indicator')
911fe470bfae WordIndex/TitleIndex: fix invalid <a> tag attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
801 if attachment_indicator is None:
911fe470bfae WordIndex/TitleIndex: fix invalid <a> tag attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
802 attachment_indicator = 0 # default is off
911fe470bfae WordIndex/TitleIndex: fix invalid <a> tag attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
803 else:
911fe470bfae WordIndex/TitleIndex: fix invalid <a> tag attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
804 del kw['attachment_indicator'] # avoid having this as <a> tag attribute
911fe470bfae WordIndex/TitleIndex: fix invalid <a> tag attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
805
1341
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
806 link = self.link_to_raw(request, text, querystr, anchor, **kw)
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
807
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
808 # Create a link to attachments if any exist
1964
911fe470bfae WordIndex/TitleIndex: fix invalid <a> tag attribute
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
809 if attachment_indicator:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
810 from MoinMoin.action import AttachFile
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
811 link += AttachFile.getIndicator(request, self.page_name)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
812
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
813 return link
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
814
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
815 def getSubscribers(self, request, **kw):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
816 """ Get all subscribers of this page.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
817
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
818 @param request: the request object
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
819 @keyword include_self: if 1, include current user (default: 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
820 @keyword return_users: if 1, return user instances (default: 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
821 @rtype: dict
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
822 @return: lists of subscribed email addresses in a dict by language key
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
823 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
824 include_self = kw.get('include_self', self.include_self)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
825 return_users = kw.get('return_users', 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
826
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
827 # extract categories of this page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
828 pageList = self.getCategories(request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
829
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
830 # add current page name for list matching
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
831 pageList.append(self.page_name)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
832
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
833 if self.cfg.SecurityPolicy:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
834 UserPerms = self.cfg.SecurityPolicy
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
835 else:
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
836 from MoinMoin.security import Default as UserPerms
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
837
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
838 # get email addresses of the all wiki user which have a profile stored;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
839 # add the address only if the user has subscribed to the page and
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
840 # the user is not the current editor
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
841 userlist = user.getUserList(request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
842 subscriber_list = {}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
843 for uid in userlist:
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
844 if uid == request.user.id and not include_self:
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
845 continue # no self notification
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
846 subscriber = user.User(request, uid)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
847
3300
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
848 # The following tests should be ordered in order of
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
849 # decreasing computation complexity, in particular
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
850 # the permissions check may be expensive; see the bug
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
851 # MoinMoinBugs/GetSubscribersPerformanceProblem
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
852
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
853 # This is a bit wrong if return_users=1 (which implies that the caller will process
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
854 # user attributes and may, for example choose to send an SMS)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
855 # So it _should_ be "not (subscriber.email and return_users)" but that breaks at the moment.
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
856 if not subscriber.email:
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
857 continue # skip empty email addresses
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
858
3300
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
859 # skip people not subscribed
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
860 if not subscriber.isSubscribedTo(pageList):
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
861 continue
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
862
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
863 # skip people who can't read the page
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
864 if not UserPerms(subscriber).read(self.page_name):
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
865 continue
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
866
3300
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
867 # add the user to the list
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
868 lang = subscriber.language or request.cfg.language_default
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
869 if not lang in subscriber_list:
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
870 subscriber_list[lang] = []
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
871 if return_users:
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
872 subscriber_list[lang].append(subscriber)
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
873 else:
f048c3edc164 reorder permission checks to last when getting subscribers
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3298
diff changeset
874 subscriber_list[lang].append(subscriber.email)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
875
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
876 return subscriber_list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
877
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
878 def parse_processing_instructions(self):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
879 """ Parse page text and extract processing instructions,
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
880 return a dict of PIs and the non-PI rest of the body.
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
881 """
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
882 from MoinMoin import i18n
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
883 from MoinMoin import security
2130
283530fa9c52 avoid acl KeyError for xml/xslt pages (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2057
diff changeset
884 request = self.request
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
885 pi = {} # we collect the processing instructions here
2130
283530fa9c52 avoid acl KeyError for xml/xslt pages (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2057
diff changeset
886
2223
eec3c7b6a686 make sure pi['language'] is set, even for xslt pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2215
diff changeset
887 # default language from cfg
eec3c7b6a686 make sure pi['language'] is set, even for xslt pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2215
diff changeset
888 pi['language'] = self.cfg.language_default or "en"
eec3c7b6a686 make sure pi['language'] is set, even for xslt pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2215
diff changeset
889
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
890 body = self.body
2130
283530fa9c52 avoid acl KeyError for xml/xslt pages (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2057
diff changeset
891 # TODO: remove this hack once we have separate metadata and can use mimetype there
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
892 if body.startswith('<?xml'): # check for XML content
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
893 pi['lines'] = 0
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
894 pi['format'] = "xslt"
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
895 pi['formatargs'] = ''
2130
283530fa9c52 avoid acl KeyError for xml/xslt pages (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2057
diff changeset
896 pi['acl'] = security.AccessControlList(request.cfg, []) # avoid KeyError on acl check
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
897 return pi
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
898
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
899 meta = self.meta
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
900
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
901 # default is wiki markup
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
902 pi['format'] = self.cfg.default_markup or "wiki"
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
903 pi['formatargs'] = ''
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
904 pi['lines'] = len(meta)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
905 acl = []
2223
eec3c7b6a686 make sure pi['language'] is set, even for xslt pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2215
diff changeset
906
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
907 for verb, args in meta:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
908 if verb == "format": # markup format
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
909 format, formatargs = (args + ' ').split(' ', 1)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
910 pi['format'] = format.lower()
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
911 pi['formatargs'] = formatargs.strip()
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
912
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
913 elif verb == "acl":
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
914 acl.append(args)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
915
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
916 elif verb == "language":
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
917 # Page language. Check if args is a known moin language
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
918 if args in i18n.wikiLanguages():
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
919 pi['language'] = args
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
920
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
921 elif verb == "refresh":
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
922 if self.cfg.refresh:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
923 try:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
924 mindelay, targetallowed = self.cfg.refresh
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
925 args = args.split()
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
926 if len(args) >= 1:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
927 delay = max(int(args[0]), mindelay)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
928 if len(args) >= 2:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
929 target = args[1]
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
930 else:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
931 target = self.page_name
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
932 if '://' in target:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
933 if targetallowed == 'internal':
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
934 raise ValueError
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
935 elif targetallowed == 'external':
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
936 url = target
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
937 else:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
938 url = Page(request, target).url(request)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
939 pi['refresh'] = (delay, url)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
940 except (ValueError, ):
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
941 pass
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
942
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
943 elif verb == "redirect":
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
944 pi['redirect'] = args
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
945
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
946 elif verb == "deprecated":
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
947 pi['deprecated'] = True
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
948
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
949 elif verb == "openiduser":
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
950 if request.cfg.openid_server_enable_user:
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
951 pi['openid.user'] = args
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
952
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
953 elif verb == "pragma":
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
954 try:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
955 key, val = args.split(' ', 1)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
956 except (ValueError, TypeError):
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
957 pass
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
958 else:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
959 request.setPragma(key, val)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
960
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
961 pi['acl'] = security.AccessControlList(request.cfg, acl)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
962 return pi
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
963
4959
18474c316dd7 mimetype support for Page.send_raw() and "raw" action (thanks to John Marshall for the patch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4899
diff changeset
964 def send_raw(self, content_disposition=None, mimetype=None):
1874
c4eb073a9cca refactor Save, merge save_raw into send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
965 """ Output the raw page data (action=raw).
c4eb073a9cca refactor Save, merge save_raw into send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
966 With no content_disposition, the browser usually just displays the
c4eb073a9cca refactor Save, merge save_raw into send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
967 data on the screen, with content_disposition='attachment', it will
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
968 offer a dialogue to save it to disk (used by Save action).
4959
18474c316dd7 mimetype support for Page.send_raw() and "raw" action (thanks to John Marshall for the patch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4899
diff changeset
969 Supplied mimetype overrides default text/plain.
1874
c4eb073a9cca refactor Save, merge save_raw into send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
970 """
678
48787c662e1a add 404 handling and cache headers for action=raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 664
diff changeset
971 request = self.request
4959
18474c316dd7 mimetype support for Page.send_raw() and "raw" action (thanks to John Marshall for the patch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4899
diff changeset
972 request.mimetype = mimetype or 'text/plain'
678
48787c662e1a add 404 handling and cache headers for action=raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 664
diff changeset
973 if self.exists():
943
274b021f26b1 remove some unused code from send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 941
diff changeset
974 # use the correct last-modified value from the on-disk file
274b021f26b1 remove some unused code from send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 941
diff changeset
975 # to ensure cacheability where supported. Because we are sending
274b021f26b1 remove some unused code from send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 941
diff changeset
976 # RAW (file) content, the file mtime is correct as Last-Modified header.
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
977 request.status_code = 200
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
978 request.last_modified = os.path.getmtime(self._text_filename())
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
979 text = self.encodeTextMimeType(self.body)
3009
e67e97ad578f better no content-length header than a wrong one, fixes truncated action=raw output for non-ascii pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2966
diff changeset
980 #request.setHttpHeader("Content-Length: %d" % len(text)) # XXX WRONG! text is unicode obj, but we send utf-8!
1874
c4eb073a9cca refactor Save, merge save_raw into send_raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
981 if content_disposition:
2845
74c29582f7a1 send_raw: encode filename in utf-8, the same way as AttachFile code does it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2800
diff changeset
982 # TODO: fix the encoding here, plain 8 bit is not allowed according to the RFCs
74c29582f7a1 send_raw: encode filename in utf-8, the same way as AttachFile code does it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2800
diff changeset
983 # There is no solution that is compatible to IE except stripping non-ascii chars
74c29582f7a1 send_raw: encode filename in utf-8, the same way as AttachFile code does it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2800
diff changeset
984 filename_enc = "%s.txt" % self.page_name.encode(config.charset)
4177
632696c3c78d Replaced calls to setHttpHeader
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
985 dispo_string = '%s; filename="%s"' % (content_disposition, filename_enc)
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
986 request.headers.add('Content-Disposition', dispo_string)
678
48787c662e1a add 404 handling and cache headers for action=raw
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 664
diff changeset
987 else:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
988 request.status_code = 404
1069
d7227430c305 fixed and cleaned up http headers usage in Page/PageEditor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1051
diff changeset
989 text = u"Page %s not found." % self.page_name
457
f423a8496ae3 moved action=raw implementation to Page object
Thomas Waldmann <tw@waldmann-edv.de>
parents: 413
diff changeset
990
1069
d7227430c305 fixed and cleaned up http headers usage in Page/PageEditor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1051
diff changeset
991 request.write(text)
457
f423a8496ae3 moved action=raw implementation to Page object
Thomas Waldmann <tw@waldmann-edv.de>
parents: 413
diff changeset
992
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2930
diff changeset
993 def send_page(self, **keywords):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
994 """ Output the formatted page.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
995
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
996 TODO: "kill send_page(), quick" (since 2002 :)
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1956
diff changeset
997
1070
054a3d3d8dfe fix http headers for edit, RenamePage, DeletePage action, raise exception when http_headers is called multiple times
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1069
diff changeset
998 @keyword content_only: if 1, omit http headers, page header and footer
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
999 @keyword content_id: set the id of the enclosing div
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1000 @keyword count_hit: if 1, add an event to the log
3296
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1001 @keyword send_special: if True, this is a special page send
335
e574cc401e89 fixed MoinMoinBugs/IncorrectlyPlacedFootnote. All footnotes are now shown at the very bottom. There is a continuing numbering of all footnotes including the ones on included pages
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 286
diff changeset
1002 @keyword omit_footnotes: if True, do not send footnotes (used by include macro)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1003 """
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1776
diff changeset
1004 request = self.request
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1005 _ = request.getText
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1006 request.clock.start('send_page')
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1007 emit_headers = keywords.get('emit_headers', 1)
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1008 content_only = keywords.get('content_only', 0)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1009 omit_footnotes = keywords.get('omit_footnotes', 0)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1010 content_id = keywords.get('content_id', 'content')
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1011 do_cache = keywords.get('do_cache', 1)
3296
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1012 send_special = keywords.get('send_special', False)
1875
5afb427026ea refactor print_mode, fix/simplify content action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1874
diff changeset
1013 print_mode = keywords.get('print_mode', 0)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1014 if print_mode:
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4242
diff changeset
1015 media = request.values.get('media', 'print')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1016 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1017 media = 'screen'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1018 self.hilite_re = (keywords.get('hilite_re') or
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4242
diff changeset
1019 request.values.get('highlight'))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1020
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1021 # count hit?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1022 if keywords.get('count_hit', 0):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1023 eventlog.EventLog(request).add(request, 'VIEWPAGE', {'pagename': self.page_name})
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1024
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1025 # load the text
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1026 body = self.data
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1027 pi = self.pi
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1028
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1029 if 'redirect' in pi and not (
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4242
diff changeset
1030 'action' in request.values or 'redirect' in request.values or content_only):
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1031 # redirect to another page
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1032 # note that by including "action=show", we prevent endless looping
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1033 # (see code in "request") or any cascaded redirection
4497
6beaf3e083c6 #redirect processing instruction: fix handling of anchors, simplify code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4470
diff changeset
1034 pagename, anchor = wikiutil.split_anchor(pi['redirect'])
6beaf3e083c6 #redirect processing instruction: fix handling of anchors, simplify code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4470
diff changeset
1035 redirect_url = Page(request, pagename).url(request,
6beaf3e083c6 #redirect processing instruction: fix handling of anchors, simplify code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4470
diff changeset
1036 querystr={'action': 'show', 'redirect': self.page_name, },
6beaf3e083c6 #redirect processing instruction: fix handling of anchors, simplify code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4470
diff changeset
1037 anchor=anchor)
5177
84c05e657b47 http_redirect: use code=<int> instead of status=<str> to make api in 1.8 same as in 1.9 / werkzeug
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5175
diff changeset
1038 request.http_redirect(redirect_url, code=301)
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1039 return
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1040
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
1041 # if necessary, load the formatter
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1042 if self.default_formatter:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1043 from MoinMoin.formatter.text_html import Formatter
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1044 self.formatter = Formatter(request, store_pagelinks=1)
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
1045 elif not self.formatter:
1520
563bfe02b04f Removed a lot of ugly MimeType() calls, refactored it into a helper, fixed page rendering for missing parsers.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1428
diff changeset
1046 Formatter = wikiutil.searchAndImportPlugin(request.cfg, "formatter", self.output_mimetype)
563bfe02b04f Removed a lot of ugly MimeType() calls, refactored it into a helper, fixed page rendering for missing parsers.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1428
diff changeset
1047 self.formatter = Formatter(request)
1531
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1048
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1049 # save formatter
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1050 no_formatter = object()
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1051 old_formatter = getattr(request, "formatter", no_formatter)
622
8fba6d15a2f5 make request.(html_)formatter available early and use it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 620
diff changeset
1052 request.formatter = self.formatter
1531
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1053
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1054 self.formatter.setPage(self)
620
cb7deb83447c introduce mimetype arg for show action, keep format action as compat. stub
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
1055 if self.hilite_re:
3285
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
1056 try:
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
1057 self.formatter.set_highlight_re(self.hilite_re)
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
1058 except re.error, err:
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
1059 request.theme.add_msg(_('Invalid highlighting regular expression "%(regex)s": %(error)s') % {
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
1060 'regex': self.hilite_re,
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
1061 'error': str(err),
bfd3f600650b fix highlighting for search results and WantedPages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3279
diff changeset
1062 }, "warning")
3410
81b8a5bb8711 send_page sucks. fix bug with invalid highlight REs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3394
diff changeset
1063 self.hilite_re = None
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1564
diff changeset
1064
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1065 if 'deprecated' in pi:
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1066 # deprecated page, append last backup version to current contents
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1067 # (which should be a short reason why the page is deprecated)
4755
e50adbb534d8 fixed grammar
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4746
diff changeset
1068 request.theme.add_msg(_('The backed up content of this page is deprecated and will rank lower in search results!'), "warning")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1069
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1070 revisions = self.getRevList()
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1071 if len(revisions) >= 2: # XXX shouldn't that be ever the case!? Looks like not.
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1072 oldpage = Page(request, self.page_name, rev=revisions[1])
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1073 body += oldpage.get_raw_body()
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1074 del oldpage
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1075
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1076 lang = self.pi.get('language', request.cfg.language_default)
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1077 request.setContentLanguage(lang)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1078
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2250
diff changeset
1079 # start document output
1069
d7227430c305 fixed and cleaned up http headers usage in Page/PageEditor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1051
diff changeset
1080 page_exists = self.exists()
1070
054a3d3d8dfe fix http headers for edit, RenamePage, DeletePage action, raise exception when http_headers is called multiple times
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1069
diff changeset
1081 if not content_only:
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1082 if emit_headers:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
1083 request.content_type = "%s; charset=%s" % (self.output_mimetype, self.output_charset)
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1084 if page_exists:
3297
d563a49e0054 give 403 status for permission denied pages rather than 200
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3296
diff changeset
1085 if not request.user.may.read(self.page_name):
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
1086 request.status_code = 403
3297
d563a49e0054 give 403 status for permission denied pages rather than 200
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3296
diff changeset
1087 else:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
1088 request.status_code = 200
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1089 if not request.cacheable:
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1090 # use "nocache" headers if we're using a method that is not simply "display"
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1091 request.disableHttpCaching(level=2)
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1092 elif request.user.valid:
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1093 # use nocache headers if a user is logged in (which triggers personalisation features)
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1094 request.disableHttpCaching(level=1)
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1095 else:
1796
57f12932915f cleaning up comments, minor refactorings in heading formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
1096 # TODO: we need to know if a page generates dynamic content -
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1097 # if it does, we must not use the page file mtime as last modified value
1796
57f12932915f cleaning up comments, minor refactorings in heading formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
1098 # The following code is commented because it is incorrect for dynamic pages:
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1099 #lastmod = os.path.getmtime(self._text_filename())
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1784
diff changeset
1100 #request.setHttpHeader("Last-Modified: %s" % util.timefuncs.formathttpdate(lastmod))
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1101 pass
1070
054a3d3d8dfe fix http headers for edit, RenamePage, DeletePage action, raise exception when http_headers is called multiple times
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1069
diff changeset
1102 else:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4177
diff changeset
1103 request.status_code = 404
1069
d7227430c305 fixed and cleaned up http headers usage in Page/PageEditor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1051
diff changeset
1104
3013
6238e1b2fd7f do not send any 404 content to bots (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3009
diff changeset
1105 if not page_exists and self.request.isSpiderAgent:
6238e1b2fd7f do not send any 404 content to bots (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3009
diff changeset
1106 # don't send any 404 content to bots
6238e1b2fd7f do not send any 404 content to bots (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3009
diff changeset
1107 return
6238e1b2fd7f do not send any 404 content to bots (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3009
diff changeset
1108
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1109 request.write(self.formatter.startDocument(self.page_name))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1110
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1111 # send the page header
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1112 if self.default_formatter:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1113 if self.rev:
3154
c9ff5a31b5cd fix some Page object theme.msg_add() calls
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3144
diff changeset
1114 request.theme.add_msg("<strong>%s</strong><br>" % (
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1115 _('Revision %(rev)d as of %(date)s') % {
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1116 'rev': self.rev,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1117 'date': self.mtime_printable(request)
3154
c9ff5a31b5cd fix some Page object theme.msg_add() calls
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3144
diff changeset
1118 }), "info")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1119
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1120 # This redirect message is very annoying.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1121 # Less annoying now without the warning sign.
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4242
diff changeset
1122 if 'redirect' in request.values:
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4242
diff changeset
1123 redir = request.values['redirect']
3154
c9ff5a31b5cd fix some Page object theme.msg_add() calls
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3144
diff changeset
1124 request.theme.add_msg('<strong>%s</strong><br>' % (
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1125 _('Redirected from page "%(page)s"') % {'page':
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2930
diff changeset
1126 wikiutil.link_tag(request, wikiutil.quoteWikinameURL(redir) + "?action=show", self.formatter.text(redir))}), "info")
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1127 if 'redirect' in pi:
3154
c9ff5a31b5cd fix some Page object theme.msg_add() calls
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3144
diff changeset
1128 request.theme.add_msg('<strong>%s</strong><br>' % (
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2930
diff changeset
1129 _('This page redirects to page "%(page)s"') % {'page': wikiutil.escape(pi['redirect'])}), "info")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1130
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1131 # Page trail
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1132 trail = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1133 if not print_mode:
1956
477760dd8487 speedup addTrail by passing existing page object
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
1134 request.user.addTrail(self)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1135 trail = request.user.getTrail()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1136
1776
fc75423e26a8 remove unneeded request param from page.split_title()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1756
diff changeset
1137 title = self.split_title()
1354
26949e36ca0b move code for title_link to theme, better escape warning
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
1138
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1139 html_head = ''
3394
396d3434ab92 move some code under openid_server_enabled where it belongs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3300
diff changeset
1140 if request.cfg.openid_server_enabled:
396d3434ab92 move some code under openid_server_enabled where it belongs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3300
diff changeset
1141 openid_username = self.page_name
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1142 userid = user.getUserId(request, openid_username)
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1143
3394
396d3434ab92 move some code under openid_server_enabled where it belongs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3300
diff changeset
1144 if userid is None and 'openid.user' in self.pi:
396d3434ab92 move some code under openid_server_enabled where it belongs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3300
diff changeset
1145 openid_username = self.pi['openid.user']
396d3434ab92 move some code under openid_server_enabled where it belongs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3300
diff changeset
1146 userid = user.getUserId(request, openid_username)
396d3434ab92 move some code under openid_server_enabled where it belongs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3300
diff changeset
1147
4815
d761238f67f9 Groups2009: OpenID related code was refactored to use groups instead of dicts.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4602
diff changeset
1148 openid_group_name = request.cfg.openid_server_restricted_users_group
d761238f67f9 Groups2009: OpenID related code was refactored to use groups instead of dicts.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4602
diff changeset
1149 if userid is not None and not openid_group_name or \
d761238f67f9 Groups2009: OpenID related code was refactored to use groups instead of dicts.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4602
diff changeset
1150 (openid_group_name in request.groups and openid_username in request.groups[openid_group_name]):
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1151 html_head = '<link rel="openid2.provider" href="%s">' % \
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1152 wikiutil.escape(request.getQualifiedURL(self.url(request,
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3235
diff changeset
1153 querystr={'action': 'serveopenid'})), True)
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1154 html_head += '<link rel="openid.server" href="%s">' % \
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1155 wikiutil.escape(request.getQualifiedURL(self.url(request,
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3235
diff changeset
1156 querystr={'action': 'serveopenid'})), True)
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1157 html_head += '<meta http-equiv="x-xrds-location" content="%s">' % \
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1158 wikiutil.escape(request.getQualifiedURL(self.url(request,
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3235
diff changeset
1159 querystr={'action': 'serveopenid', 'yadis': 'ep'})), True)
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1160 elif self.page_name == request.cfg.page_front_page:
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1161 html_head = '<meta http-equiv="x-xrds-location" content="%s">' % \
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1162 wikiutil.escape(request.getQualifiedURL(self.url(request,
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3235
diff changeset
1163 querystr={'action': 'serveopenid', 'yadis': 'idp'})), True)
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1164
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2930
diff changeset
1165 request.theme.send_title(title, page=self,
1779
224e2106ab89 call send_title with page kw arg, if available, not with pagename
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1778
diff changeset
1166 print_mode=print_mode,
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1167 media=media, pi_refresh=pi.get('refresh'),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1168 allow_doubleclick=1, trail=trail,
3144
7aba52041f56 add OpenID provider code
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3127
diff changeset
1169 html_head=html_head,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1170 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1171
3296
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1172 # special pages handling, including denying access
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1173 special = None
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1174
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1175 if not send_special:
3620
25431c5a76f9 fix editor preview not working for new pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3610
diff changeset
1176 if not page_exists and not body:
3296
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1177 special = 'missing'
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1178 elif not request.user.may.read(self.page_name):
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1179 special = 'denied'
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1180
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1181 # if we have a special page, output it, unless
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1182 # - we should only output content (this is for say the pagelinks formatter)
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1183 # - we have a non-default formatter
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1184 if special and not content_only and self.default_formatter:
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1185 self._specialPageText(request, special) # this recursively calls send_page
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1186
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1187 # if we didn't short-cut to a special page, output this page
fc5e23d62d56 implement FeatureRequests/AclAccessDeniedMessageIsWikiPage
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3285
diff changeset
1188 if not special:
1906
4c424f7b5d55 fix double content div for MissingPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1885
diff changeset
1189 # start wiki content div
4c424f7b5d55 fix double content div for MissingPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1885
diff changeset
1190 request.write(self.formatter.startContent(content_id))
4c424f7b5d55 fix double content div for MissingPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1885
diff changeset
1191
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1192 # parse the text and send the page content
1908
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1907
diff changeset
1193 self.send_page_content(request, body,
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1907
diff changeset
1194 format=pi['format'],
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1195 format_args=pi['formatargs'],
150
3f6de4cba30b fixed MoinMoinBugs/DiffAnchorOffset
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 138
diff changeset
1196 do_cache=do_cache,
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1197 start_line=pi['lines'])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1198
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1199 # check for pending footnotes
335
e574cc401e89 fixed MoinMoinBugs/IncorrectlyPlacedFootnote. All footnotes are now shown at the very bottom. There is a continuing numbering of all footnotes including the ones on included pages
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 286
diff changeset
1200 if getattr(request, 'footnotes', None) and not omit_footnotes:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1201 from MoinMoin.macro.FootNote import emit_footnotes
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1202 request.write(emit_footnotes(request, self.formatter))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1203
1906
4c424f7b5d55 fix double content div for MissingPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1885
diff changeset
1204 # end wiki content div
4c424f7b5d55 fix double content div for MissingPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1885
diff changeset
1205 request.write(self.formatter.endContent())
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1206
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1207 # end document output
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1208 if not content_only:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1209 # send the page footer
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1210 if self.default_formatter:
616
3b08d9413589 move send_title/footer from wikiutil to theme.__init__
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 609
diff changeset
1211 request.theme.send_footer(self.page_name, print_mode=print_mode)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1212
1675
b8d488de4b69 send_page: use emit_headers=0 to suppress emitting of http headers (merged from docbook branch)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1646
diff changeset
1213 request.write(self.formatter.endDocument())
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1214
1809
03fbdd327f1f saving the pagelinks after closing html saves some ms for the user
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1801
diff changeset
1215 request.clock.stop('send_page')
03fbdd327f1f saving the pagelinks after closing html saves some ms for the user
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1801
diff changeset
1216 if not content_only and self.default_formatter:
03fbdd327f1f saving the pagelinks after closing html saves some ms for the user
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1801
diff changeset
1217 request.theme.send_closing_html()
03fbdd327f1f saving the pagelinks after closing html saves some ms for the user
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1801
diff changeset
1218
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1219 # cache the pagelinks
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1220 if do_cache and self.default_formatter and page_exists:
1639
95efbd8cfa55 caching: use pickle for pagelinks, too
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1636
diff changeset
1221 cache = caching.CacheEntry(request, self, 'pagelinks', scope='item', use_pickle=True)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1222 if cache.needsUpdate(self._text_filename()):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1223 links = self.formatter.pagelinks
1639
95efbd8cfa55 caching: use pickle for pagelinks, too
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1636
diff changeset
1224 cache.update(links)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1225
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1226 # restore old formatter (hopefully we dont throw any exception that is catched again)
1605
c4f2db04084b use 'is' for object identity checking
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1595
diff changeset
1227 if old_formatter is no_formatter:
1531
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1228 del request.formatter
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1229 else:
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1230 request.formatter = old_formatter
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1231
b369a5c3f3e2 Restore the formatter in send_page, fixes 'empty' search results.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1520
diff changeset
1232
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1233 def getFormatterName(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1234 """ Return a formatter name as used in the caching system
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1235
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1236 @rtype: string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1237 @return: formatter name as used in caching
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1238 """
622
8fba6d15a2f5 make request.(html_)formatter available early and use it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 620
diff changeset
1239 if not hasattr(self, 'formatter') or self.formatter is None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1240 return ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1241 module = self.formatter.__module__
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1242 return module[module.rfind('.') + 1:]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1243
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1244 def canUseCache(self, parser=None):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1245 """ Is caching available for this request?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1246
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1247 This make sure we can try to use the caching system for this
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1248 request, but it does not make sure that this will
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1249 succeed. Themes can use this to decide if a Refresh action
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1250 should be displayed.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1251
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1252 @param parser: the parser used to render the page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1253 @rtype: bool
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1254 @return: if this page can use caching
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1255 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1256 if (not self.rev and
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1257 not self.hilite_re and
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1258 not self.__body_modified and
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1259 self.getFormatterName() in self.cfg.caching_formats):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1260 # Everything is fine, now check the parser:
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 33
diff changeset
1261 if parser is None:
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1875
diff changeset
1262 parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", self.pi['format'])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1263 return getattr(parser, 'caching', False)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1264 return False
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1265
1908
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1907
diff changeset
1266 def send_page_content(self, request, body, format='wiki', format_args='', do_cache=1, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1267 """ Output the formatted wiki page, using caching if possible
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1268
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1269 @param request: the request object
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1270 @param body: text of the wiki page
1908
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1907
diff changeset
1271 @param format: format of content, default 'wiki'
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1272 @param format_args: #format arguments, used by some parsers
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1273 @param do_cache: if True, use cached content
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1274 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1275 request.clock.start('send_page_content')
1908
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1907
diff changeset
1276 # Load the parser
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1907
diff changeset
1277 Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser", format)
150
3f6de4cba30b fixed MoinMoinBugs/DiffAnchorOffset
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 138
diff changeset
<