Attachment 'overlay-1.6-7b80735ede14.diff'
Download 1 diff --width=126 -u -r ../../../1-6-7b80735ede14/MoinMoin/Page.py MoinMoin/Page.py
2 --- ../../../1-6-7b80735ede14/MoinMoin/Page.py 2006-11-28 12:00:33.000000000 -0700
3 +++ MoinMoin/Page.py 2006-11-28 12:10:40.000000000 -0700
4 @@ -155,28 +155,33 @@
5
6 def reset(self):
7 """ Reset page state """
8 - page_name = self.page_name
9 # page_name quoted for file system usage, needs to be reset to
10 # None when pagename changes
11
12 - qpagename = wikiutil.quoteWikinameFS(page_name)
13 - self.page_name_fs = qpagename
14 + self.page_name_fs = wikiutil.quoteWikinameFS(self.page_name)
15
16 # the normal and the underlay path used for this page
17 - normalpath = os.path.join(self.cfg.data_dir, "pages", qpagename)
18 + self.underlaypath = None
19 if not self.cfg.data_underlay_dir is None:
20 - underlaypath = os.path.join(self.cfg.data_underlay_dir, "pages", qpagename)
21 - else:
22 - underlaypath = None
23 + self.underlaypath = os.path.join(self.cfg.data_underlay_dir, "pages", self.page_name_fs)
24
25 - # TUNING - remember some essential values
26 + self.default_base_path = os.path.join(self.cfg.data_dir, "pages", self.page_name_fs)
27
28 - # does the page come from normal page storage (0) or from
29 - # underlay dir (1) (can be used as index into following list)
30 - self._underlay = None
31 + pos = self.page_name.rfind('/')
32 + if pos > 0:
33 + parent = Page(self.request, self.page_name[:pos])
34 + parent_base = os.path.dirname(parent.getPageBasePath())
35 + self.default_base_path = os.path.join(parent_base, self.page_name_fs)
36 +
37 + if hasattr(self, 'is_rootpage') and self.is_rootpage:
38 + self.default_base_path = os.path.dirname( os.path.dirname( self.default_base_path ) )
39 +
40 + # reset the page path
41 + self.pagepath = None
42 + self.getPageBasePath()
43 +
44 + # TUNING - remember some essential values
45
46 - # path to normal / underlay page dir
47 - self._pagepath = [normalpath, underlaypath]
48
49 def get_current_from_pagedir(self, pagedir):
50 """ get the current revision number from an arbitrary pagedir.
51 @@ -274,10 +279,13 @@
52 return cache_data
53
54 # Figure out if we should use underlay or not, if needed.
55 - if use_underlay == -1:
56 - underlay, pagedir = self.getPageStatus(check_create=0)
57 + if use_underlay == 1:
58 + pagedir = self.underlaypath
59 else:
60 - underlay, pagedir = use_underlay, self._pagepath[use_underlay]
61 + pagedir = self.getPageBasePath( )
62 + if pagedir == self.underlaypath :
63 + if use_underlay == 0:
64 + pagedir = self.default_base_path
65
66 # Find current revision, if automatic selection is requested.
67 if rev == 0:
68 @@ -294,13 +302,20 @@
69
70 def current_rev(self):
71 """Return number of current revision.
72 -
73 +
74 This is the same as get_rev()[1].
75 -
76 +
77 @return: int revision
78 """
79 - pagefile, rev, exists = self.get_rev()
80 - return rev
81 + if self.rev:
82 + return self.rev
83 +
84 + page_path = self.getPageBasePath( )
85 + pagefile, realrev, exists = self.get_rev_dir(page_path)
86 + #if realrev != 99999999:
87 + # self.rev = realrev
88 +
89 + return realrev
90
91 def get_real_rev(self):
92 """Returns the real revision number of this page. A rev=0 is
93 @@ -313,41 +328,56 @@
94 return self.current_rev()
95 return self.rev
96
97 - def getPageBasePath(self, use_underlay):
98 + def _find_page(self, use_underlay=-1):
99 """
100 - Get full path to a page-specific storage area. `args` can
101 - contain additional path components that are added to the base path.
102 + Find the full path to a page-specific storage area.
103 +
104 + @param use_underlay: 0 == no underlay, 1 == only underlay, other values default to look everywhere
105
106 - @param use_underlay: force using a specific pagedir, default '-1'
107 - '-1' = automatically choose page dir
108 - '1' = use underlay page dir
109 - '0' = use standard page dir
110 @rtype: string
111 - @return: int underlay,
112 - str the full path to the storage area
113 + @return: str the full path to the storage area, '' if no page not found
114 """
115 - standardpath, underlaypath = self._pagepath
116 - if underlaypath is None:
117 - use_underlay = 0
118 -
119 - if use_underlay == -1: # automatic
120 - if self._underlay is None:
121 - underlay, path = 0, standardpath
122 - pagefile, rev, exists = self.get_rev(use_underlay=0)
123 - if not exists:
124 - pagefile, rev, exists = self.get_rev(use_underlay=1)
125 - if exists:
126 - underlay, path = 1, underlaypath
127 - self._underlay = underlay
128 +
129 + search_path = self.cfg.page_data_dirs
130 +
131 + if self.request.cfg.data_underlay_dir:
132 + if use_underlay == 1: # only look in the underlay dir
133 + search_path = [ self.request.cfg.data_underlay_dir ]
134 + elif use_underlay == 0: #dont look in underlay dir
135 + search_path = []
136 + for dir in self.cfg.page_data_dirs:
137 + if not dir == self.request.cfg.data_underlay_dir:
138 + search_path.append( dir )
139 +
140 + for dir in search_path:
141 + if self.page_name_fs:
142 + fullpath = os.path.join( dir, "pages", self.page_name_fs)
143 + if os.path.exists(fullpath) :
144 + return fullpath
145 else:
146 - underlay = self._underlay
147 - path = self._pagepath[underlay]
148 - else: # normal or underlay
149 - underlay, path = use_underlay, self._pagepath[use_underlay]
150 + return dir
151 +
152 + return ''
153 +
154 + def getPageBasePath(self):
155 + """
156 + Get full path to a page-specific storage area.
157 +
158 + @rtype: string
159 + @return: str the full path to the storage area
160 + """
161 +
162 + if hasattr(self, 'pagepath') and self.pagepath:
163 + return self.pagepath
164 +
165 + self.pagepath = self._find_current_page(rev=self.rev)
166 + if not self.pagepath:
167 + self.pagepath = self.default_base_path
168
169 - return underlay, path
170 + return self.pagepath
171
172 - def getPageStatus(self, *args, **kw):
173 +
174 + def getPagePath(self, *args, **kw):
175 """
176 Get full path to a page-specific storage area. `args` can
177 contain additional path components that are added to the base path.
178 @@ -362,27 +392,55 @@
179 (default true)
180 @keyword isfile: is the last component in args a filename? (default is false)
181 @rtype: string
182 - @return: (int underlay (1 if using underlay, 0 otherwise),
183 - str the full path to the storage area )
184 + @return: str the full path to the storage area
185 """
186 +
187 check_create = kw.get('check_create', 1)
188 - isfile = kw.get('isfile', 0)
189 use_underlay = kw.get('use_underlay', -1)
190 - underlay, path = self.getPageBasePath(use_underlay)
191 - fullpath = os.path.join(*((path,) + args))
192 +
193 + if use_underlay == 1:
194 + page_path = self.underlaypath
195 + else:
196 + page_path = self.getPageBasePath( )
197 + if use_underlay == 0 and page_path == self.underlaypath:
198 + page_path = self.default_base_path
199 +
200 + fullpath = os.path.join(*((page_path,) + args))
201 +
202 if check_create:
203 + isfile = kw.get('isfile', 0)
204 if isfile:
205 dirname, filename = os.path.split(fullpath)
206 else:
207 dirname = fullpath
208 if not os.path.exists(dirname):
209 os.makedirs(dirname)
210 - return underlay, fullpath
211 + return fullpath
212
213 - def getPagePath(self, *args, **kw):
214 - """Return path to the page storage area."""
215 + def _find_current_page(self, rev=0, use_underlay=-1):
216 + """
217 + Find the current full path to a page-specific storage area.
218 +
219 + @param use_underlay: -1 == auto, 0 == normal, 1 == underlay
220 + @param rev: int revision to get (default is 0 and means the current
221 + revision )
222 +
223 + @rtype: string
224 + @return: str the full path to the storage area, '' if no page not found
225 + """
226 +
227 + if not rev and self.rev:
228 + rev = self.rev
229 +
230 + fullpath = self._find_page(use_underlay)
231 + if fullpath :
232 + pagefile, realrev, exists = self.get_rev_dir(fullpath, rev)
233 + if exists:
234 + return fullpath
235 + return ''
236 +
237 + return ''
238
239 - return self.getPageStatus(*args, **kw)[1]
240
241 def split_title(self, request, force=0):
242 """
243 @@ -419,17 +477,6 @@
244 fname, rev, exists = self.get_rev(-1, rev)
245 return fname
246
247 - def _tmp_filename(self):
248 - """
249 - The name of the temporary file used while saving.
250 -
251 - @rtype: string
252 - @return: temporary filename (complete path + filename)
253 - """
254 - rnd = random.randint(0, 1000000000)
255 - tmpname = os.path.join(self.cfg.data_dir, '#%s.%d#' % (self.page_name_fs, rnd))
256 - return tmpname
257 -
258 # XXX TODO clean up the mess, rewrite _last_edited, last_edit, lastEditInfo for new logs,
259 # XXX TODO do not use mtime() calls any more
260 def _last_edited(self, request):
261 @@ -532,7 +579,23 @@
262 @rtype: bool
263 @return: true if page lives in the underlay dir
264 """
265 - return self.exists(domain='underlay', includeDeleted=includeDeleted)
266 + # page cant be an underlay page
267 + if not self.request.cfg.data_underlay_dir:
268 + return False
269 +
270 + if includeDeleted:
271 + page_dir = self._find_page(use_underlay=1)
272 + else:
273 + page_dir = self._find_current_page(use_underlay=1)
274 +
275 + if page_dir:
276 + underlay_dir = self.request.cfg.data_underlay_dir
277 +
278 + # we found the page in a dir that is the underlay dir
279 + if underlay_dir == os.path.commonprefix( [ underlay_dir, page_dir ] ):
280 + return True
281 +
282 + return False
283
284 def isStandardPage(self, includeDeleted=True):
285 """ Does this page live in the data dir?
286 @@ -544,9 +607,25 @@
287 @rtype: bool
288 @return: true if page lives in the data dir
289 """
290 - return self.exists(domain='standard', includeDeleted=includeDeleted)
291 + # page cant be an underlay page
292 + if not self.request.cfg.data_underlay_dir:
293 + return True
294 +
295 + if includeDeleted:
296 + page_dir = self._find_page()
297 + else:
298 + page_dir = self._find_current_page()
299 +
300 + if page_dir:
301 + underlay_dir = self.request.cfg.data_underlay_dir
302 +
303 + # we found the page in a dir that is not the underlay dir
304 + if not underlay_dir == os.path.commonprefix( [ underlay_dir, page_dir ] ):
305 + return True
306 +
307 + return False
308
309 - def exists(self, rev=0, domain=None, includeDeleted=False):
310 + def exists(self, rev=0, includeDeleted=False):
311 """ Does this page exist?
312
313 This is the lower level method for checking page existence. Use
314 @@ -554,38 +633,19 @@
315 cleaner code.
316
317 @param rev: revision to look for. Default check current
318 - @param domain: where to look for the page. Default look in all,
319 - available values: 'underlay', 'standard'
320 @param includeDeleted: ignore page state, just check its pagedir
321 @rtype: bool
322 @return: true, if page exists
323 """
324 - # Edge cases
325 - if domain == 'underlay' and not self.request.cfg.data_underlay_dir:
326 - return False
327
328 if includeDeleted:
329 - # Look for page directory, ignore page state
330 - if domain is None:
331 - checklist = [0, 1]
332 - else:
333 - checklist = [domain == 'underlay']
334 - for use_underlay in checklist:
335 - pagedir = self.getPagePath(use_underlay=use_underlay, check_create=0)
336 - if os.path.exists(pagedir):
337 - return True
338 - return False
339 + page_dir = self._find_page()
340 else:
341 - # Look for non-deleted pages only, using get_rev
342 - if not rev and self.rev:
343 - rev = self.rev
344 + page_dir = self._find_current_page(rev)
345
346 - if domain is None:
347 - use_underlay = -1
348 - else:
349 - use_underlay = domain == 'underlay'
350 - d, d, exists = self.get_rev(use_underlay, rev)
351 - return exists
352 + if page_dir:
353 + return True
354 + return False
355
356 def size(self, rev=0):
357 """ Get Page size.
358 @@ -1070,7 +1130,7 @@
359
360 # send the page header
361 if self.default_formatter:
362 - if self.rev:
363 + if self.rev and self.rev != 99999999:
364 msg = "<strong>%s</strong><br>%s" % (
365 _('Revision %(rev)d as of %(date)s') % {
366 'rev': self.rev,
367 @@ -1273,7 +1333,7 @@
368 def loadCache(self, request):
369 """ Return page content cache or raises 'CacheNeedsUpdate' """
370 cache = caching.CacheEntry(request, self, self.getFormatterName(), scope='item')
371 - attachmentsPath = self.getPagePath('attachments', check_create=0)
372 + attachmentsPath = os.path.join( self.getPageBasePath(), 'attachments')
373 if cache.needsUpdate(self._text_filename(), attachmentsPath):
374 raise Exception('CacheNeedsUpdate')
375
376 @@ -1337,7 +1397,7 @@
377 import dircache
378 revisions = []
379 if self.page_name:
380 - rev_dir = self.getPagePath('revisions', check_create=0)
381 + rev_dir = os.path.join( self.getPageBasePath(), 'revisions')
382 if os.path.isdir(rev_dir):
383 for rev in dircache.listdir(rev_dir):
384 try:
385 @@ -1608,34 +1668,10 @@
386 def __init__(self, request):
387 page_name = u''
388 Page.__init__(self, request, page_name)
389 + self.is_rootpage = 1
390
391 - def getPageBasePath(self, use_underlay):
392 - """
393 - Get full path to a page-specific storage area. `args` can
394 - contain additional path components that are added to the base path.
395
396 - @param use_underlay: force using a specific pagedir, default '-1'
397 - '-1' = automatically choose page dir
398 - '1' = use underlay page dir
399 - '0' = use standard page dir
400 - @rtype: string
401 - @return: int underlay,
402 - str the full path to the storage area
403 - """
404 - if self.cfg.data_underlay_dir is None:
405 - use_underlay = 0
406 -
407 - # 'auto' doesn't make sense here. maybe not even 'underlay':
408 - if use_underlay == 1:
409 - underlay, path = 1, self.cfg.data_underlay_dir
410 - # no need to check 'standard' case, we just use path in that case!
411 - else:
412 - # this is the location of the virtual root page
413 - underlay, path = 0, self.cfg.data_dir
414 -
415 - return underlay, path
416 -
417 - def getPageList(self, user=None, exists=1, filter=None, include_underlay=True, return_objects=False):
418 + def getPageList(self, user=None, exists=1, filter=None, return_objects=False):
419 """ List user readable pages under current page
420
421 Currently only request.rootpage is used to list pages, but if we
422 @@ -1659,7 +1695,6 @@
423 @param user: the user requesting the pages (MoinMoin.user.User)
424 @param filter: filter function
425 @param exists: filter existing pages
426 - @param include_underlay: determines if underlay pages are returned as well
427 @param return_objects: lets it return a list of Page objects instead of
428 names
429 @rtype: list of unicode strings
430 @@ -1688,7 +1723,7 @@
431 cachedlist[pagename] = None
432 request.cfg.cache.pagelists.putItem(request, 'all', None, cachedlist)
433
434 - if user or exists or filter or not include_underlay or return_objects:
435 + if user or exists or filter or return_objects:
436 # Filter names
437 pages = []
438 for name in cachedlist:
439 @@ -1699,10 +1734,6 @@
440
441 page = Page(request, name)
442
443 - # Filter underlay pages
444 - if not include_underlay and page.getPageStatus()[0]: # is an underlay page
445 - continue
446 -
447 # Filter deleted pages
448 if exists and not page.exists():
449 continue
450 @@ -1749,16 +1780,12 @@
451 @rtype: dict
452 @return: dict of page names using file system encoding
453 """
454 - # Get pages in standard dir
455 - path = self.getPagePath('pages')
456 - pages = self._listPageInPath(path)
457 -
458 - if self.cfg.data_underlay_dir is not None:
459 - # Merge with pages from underlay
460 - path = self.getPagePath('pages', use_underlay=1)
461 - underlay = self._listPageInPath(path)
462 - pages.update(underlay)
463
464 + pages = {}
465 + for dir in self.cfg.page_data_dirs:
466 + path = os.path.join( dir, 'pages' )
467 + more_pages = self._listPageInPath(path)
468 + pages.update(more_pages)
469 return pages
470
471 def _listPageInPath(self, path):
472 diff --width=126 -u -r ../../../1-6-7b80735ede14/MoinMoin/PageEditor.py MoinMoin/PageEditor.py
473 --- ../../../1-6-7b80735ede14/MoinMoin/PageEditor.py 2006-11-28 12:00:33.000000000 -0700
474 +++ MoinMoin/PageEditor.py 2006-11-28 12:10:45.000000000 -0700
475 @@ -909,7 +909,10 @@
476 llog = editlog.EditLog(self.request, filename=pagelog,
477 uid_override=self.uid_override)
478 # Open the global log
479 - glog = editlog.EditLog(self.request, uid_override=self.uid_override)
480 + root_dir = os.path.dirname( os.path.dirname( pagedir ) )
481 + gpagelog = os.path.join( root_dir, 'edit-log')
482 + glog = editlog.EditLog(self.request, filename=gpagelog,
483 + uid_override=self.uid_override)
484
485 if not os.path.exists(pagedir): # new page, create and init pagedir
486 os.mkdir(pagedir)
487 @@ -961,9 +964,6 @@
488 # set in-memory content
489 self.set_raw_body(text)
490
491 - # reset page object
492 - self.reset()
493 -
494 # write the editlog entry
495 # for now simply make 2 logs, better would be some multilog stuff maybe
496 if self.do_revision_backup:
497 @@ -977,6 +977,9 @@
498 if got_lock:
499 filesys.rename(clfn, cfn)
500
501 + # reset page object
502 + self.reset()
503 +
504 # add event log entry
505 elog = eventlog.EventLog(self.request)
506 elog.add(self.request, 'SAVEPAGE', {'pagename': self.page_name}, 1, mtime_usecs)
507 @@ -1022,7 +1025,7 @@
508 other = False
509 pagelog = self.getPagePath('edit-log', use_underlay=0, isfile=1)
510 next_line = None
511 - for line in editlog.EditLog(self.request, pagelog).reverse():
512 + for line in editlog.EditLog(self.request, filename=pagelog).reverse():
513 if int(line.rev) == int(rev):
514 break
515 if not line.is_from_current_user(self.request):
516 Only in ../../../1-6-7b80735ede14/MoinMoin/_tests: broken
517 diff --width=126 -u -r ../../../1-6-7b80735ede14/MoinMoin/action/info.py MoinMoin/action/info.py
518 --- ../../../1-6-7b80735ede14/MoinMoin/action/info.py 2006-11-28 12:00:33.000000000 -0700
519 +++ MoinMoin/action/info.py 2006-11-28 12:10:18.000000000 -0700
520 @@ -33,6 +33,15 @@
521 f.text(_("Page size: %d") % page.size()),
522 f.paragraph(0))
523
524 + page_location = 'Overlay'
525 + page_path = page.getPageBasePath()
526 + if request.cfg.data_underlay_dir and \
527 + request.cfg.data_underlay_dir == os.path.commonprefix( [ request.cfg.data_underlay_dir, page_path ] ):
528 + page_location = 'Underlay'
529 + elif request.cfg.data_dir == os.path.commonprefix( [ request.cfg.data_dir, page_path ] ):
530 + page_location = 'Standard'
531 + request.write(("<p>%s</p>" % _("Page Location: %s")) % page_location)
532 +
533 import sha
534 digest = sha.new(page.get_raw_body().encode(config.charset)).hexdigest().upper()
535 request.write(f.paragraph(1),
536 diff --width=126 -u -r ../../../1-6-7b80735ede14/MoinMoin/config/multiconfig.py MoinMoin/config/multiconfig.py
537 --- ../../../1-6-7b80735ede14/MoinMoin/config/multiconfig.py 2006-11-28 12:00:33.000000000 -0700
538 +++ MoinMoin/config/multiconfig.py 2006-11-28 12:11:43.000000000 -0700
539 @@ -736,17 +736,28 @@
540 Both data and underlay should exists and allow read, write and
541 execute.
542 """
543 - mode = os.F_OK | os.R_OK | os.W_OK | os.X_OK
544 - for attr in ('data_dir', 'data_underlay_dir'):
545 - path = getattr(self, attr)
546 + if not hasattr(self, 'page_data_dirs'):
547 + data_dir = getattr(self, 'data_dir')
548 + underlay_dir = getattr(self, 'underlay_dir')
549 + self.page_data_dirs = [ data_dir, ]
550 + if underlay_dir:
551 + self.page_data_dirs = [ data_dir, underlay_dir, ]
552
553 + mode = os.F_OK | os.R_OK | os.W_OK | os.X_OK
554 + for attr in ('data_dir', 'data_underlay_dir', 'page_data_dirs'):
555 + if attr == 'data_dir' or attr == 'data_underlay_dir':
556 + paths_to_check = ( getattr(self, attr), )
557 + else:
558 + paths_to_check = getattr(self, attr)
559 +
560 # allow an empty underlay path or None
561 - if attr == 'data_underlay_dir' and not path:
562 + if attr == 'data_underlay_dir' and not paths_to_check:
563 continue
564
565 - path_pages = os.path.join(path, "pages")
566 - if not (os.path.isdir(path_pages) and os.access(path_pages, mode)):
567 - msg = '''
568 + for path in paths_to_check:
569 + path_pages = os.path.join(path, "pages")
570 + if not (os.path.isdir(path_pages) and os.access(path_pages, mode)):
571 + msg = '''
572 %(attr)s "%(path)s" does not exists, or has incorrect ownership or
573 permissions.
574
575 @@ -756,8 +767,8 @@
576
577 It is recommended to use absolute paths and not relative paths. Check
578 also the spelling of the directory name.
579 -''' % {'attr': attr, 'path': path, }
580 - raise error.ConfigurationError(msg)
581 +''' % {'attr': attr, 'path': path,}
582 + raise error.ConfigurationError(msg)
583
584 def _loadPluginModule(self):
585 """ import plugin module under configname.plugin
586 diff --width=126 -u -r ../../../1-6-7b80735ede14/MoinMoin/script/maint/mkpagepacks.py MoinMoin/script/maint/mkpagepacks.py
587 --- ../../../1-6-7b80735ede14/MoinMoin/script/maint/mkpagepacks.py 2006-11-28 12:00:33.000000000 -0700
588 +++ MoinMoin/script/maint/mkpagepacks.py 2006-11-28 12:08:14.000000000 -0700
589 @@ -110,7 +110,7 @@
590 pagename = pagename.strip()
591 page = Page(request, pagename)
592 try:
593 - underlay, path = page.getPageBasePath(-1)
594 + path = page.getPageBasePath()
595 shutil.rmtree(path)
596 except:
597 pass
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.