paul@0 | 1 | # -*- coding: iso-8859-1 -*- |
paul@0 | 2 | """ |
paul@0 | 3 | MoinMoin - MoinSupport library (derived from EventAggregatorSupport) |
paul@0 | 4 | |
paul@36 | 5 | @copyright: 2008, 2009, 2010, 2011, 2012, 2013 by Paul Boddie <paul@boddie.org.uk> |
paul@0 | 6 | @copyright: 2000-2004 Juergen Hermann <jh@web.de>, |
paul@46 | 7 | 2004 by Florian Festi, |
paul@46 | 8 | 2006 by Mikko Virkkil, |
paul@46 | 9 | 2005-2008 MoinMoin:ThomasWaldmann, |
paul@46 | 10 | 2007 MoinMoin:ReimarBauer. |
paul@0 | 11 | @license: GNU GPL (v2 or later), see COPYING.txt for details. |
paul@0 | 12 | """ |
paul@0 | 13 | |
paul@0 | 14 | from DateSupport import * |
paul@41 | 15 | from ItemSupport import ItemDirectoryStore |
paul@1 | 16 | from MoinMoin.Page import Page |
paul@37 | 17 | from MoinMoin.util import lock |
paul@25 | 18 | from MoinMoin import config, search, wikiutil |
paul@10 | 19 | from StringIO import StringIO |
paul@10 | 20 | from shlex import shlex |
paul@0 | 21 | import re |
paul@0 | 22 | import time |
paul@37 | 23 | import os |
paul@0 | 24 | |
paul@35 | 25 | # Moin 1.9 request parameters. |
paul@35 | 26 | |
paul@35 | 27 | try: |
paul@35 | 28 | from MoinMoin.support.werkzeug.datastructures import MultiDict |
paul@35 | 29 | except ImportError: |
paul@35 | 30 | pass |
paul@35 | 31 | |
paul@46 | 32 | __version__ = "0.3" |
paul@0 | 33 | |
paul@25 | 34 | # Extraction of shared fragments. |
paul@25 | 35 | |
paul@25 | 36 | marker_regexp_str = r"([{]{3,}|[}]{3,})" |
paul@25 | 37 | marker_regexp = re.compile(marker_regexp_str, re.MULTILINE | re.DOTALL) # {{{... or }}}... |
paul@25 | 38 | |
paul@29 | 39 | # Extraction of headings. |
paul@29 | 40 | |
paul@29 | 41 | heading_regexp = re.compile(r"^(?P<level>=+)(?P<heading>.*?)(?P=level)$", re.UNICODE | re.MULTILINE) |
paul@29 | 42 | |
paul@25 | 43 | # Category extraction from pages. |
paul@25 | 44 | |
paul@25 | 45 | category_regexp = None |
paul@25 | 46 | |
paul@25 | 47 | # Simple content parsing. |
paul@25 | 48 | |
paul@25 | 49 | verbatim_regexp = re.compile(ur'(?:' |
paul@25 | 50 | ur'<<Verbatim\((?P<verbatim>.*?)\)>>' |
paul@25 | 51 | ur'|' |
paul@25 | 52 | ur'\[\[Verbatim\((?P<verbatim2>.*?)\)\]\]' |
paul@25 | 53 | ur'|' |
paul@25 | 54 | ur'!(?P<verbatim3>.*?)(\s|$)?' |
paul@25 | 55 | ur'|' |
paul@25 | 56 | ur'`(?P<monospace>.*?)`' |
paul@25 | 57 | ur'|' |
paul@25 | 58 | ur'{{{(?P<preformatted>.*?)}}}' |
paul@25 | 59 | ur')', re.UNICODE) |
paul@25 | 60 | |
paul@25 | 61 | # Category discovery. |
paul@0 | 62 | |
paul@25 | 63 | def getCategoryPattern(request): |
paul@25 | 64 | global category_regexp |
paul@25 | 65 | |
paul@25 | 66 | try: |
paul@25 | 67 | return request.cfg.cache.page_category_regexact |
paul@25 | 68 | except AttributeError: |
paul@25 | 69 | |
paul@25 | 70 | # Use regular expression from MoinMoin 1.7.1 otherwise. |
paul@25 | 71 | |
paul@25 | 72 | if category_regexp is None: |
paul@25 | 73 | category_regexp = re.compile(u'^%s$' % ur'(?P<all>Category(?P<key>(?!Template)\S+))', re.UNICODE) |
paul@25 | 74 | return category_regexp |
paul@25 | 75 | |
paul@25 | 76 | def getCategories(request): |
paul@25 | 77 | |
paul@25 | 78 | """ |
paul@25 | 79 | From the AdvancedSearch macro, return a list of category page names using |
paul@25 | 80 | the given 'request'. |
paul@25 | 81 | """ |
paul@25 | 82 | |
paul@25 | 83 | # This will return all pages with "Category" in the title. |
paul@25 | 84 | |
paul@25 | 85 | cat_filter = getCategoryPattern(request).search |
paul@25 | 86 | return request.rootpage.getPageList(filter=cat_filter) |
paul@25 | 87 | |
paul@25 | 88 | def getCategoryMapping(category_pagenames, request): |
paul@2 | 89 | |
paul@2 | 90 | """ |
paul@25 | 91 | For the given 'category_pagenames' return a list of tuples of the form |
paul@25 | 92 | (category name, category page name) using the given 'request'. |
paul@25 | 93 | """ |
paul@25 | 94 | |
paul@25 | 95 | cat_pattern = getCategoryPattern(request) |
paul@25 | 96 | mapping = [] |
paul@25 | 97 | for pagename in category_pagenames: |
paul@25 | 98 | name = cat_pattern.match(pagename).group("key") |
paul@25 | 99 | if name != "Category": |
paul@25 | 100 | mapping.append((name, pagename)) |
paul@25 | 101 | mapping.sort() |
paul@25 | 102 | return mapping |
paul@25 | 103 | |
paul@25 | 104 | def getCategoryPages(pagename, request): |
paul@25 | 105 | |
paul@25 | 106 | """ |
paul@25 | 107 | Return the pages associated with the given category 'pagename' using the |
paul@25 | 108 | 'request'. |
paul@25 | 109 | """ |
paul@25 | 110 | |
paul@25 | 111 | query = search.QueryParser().parse_query('category:%s' % pagename) |
paul@25 | 112 | results = search.searchPages(request, query, "page_name") |
paul@27 | 113 | return filterCategoryPages(results, request) |
paul@27 | 114 | |
paul@27 | 115 | def filterCategoryPages(results, request): |
paul@27 | 116 | |
paul@27 | 117 | "Filter category pages from the given 'results' using the 'request'." |
paul@25 | 118 | |
paul@25 | 119 | cat_pattern = getCategoryPattern(request) |
paul@25 | 120 | pages = [] |
paul@25 | 121 | for page in results.hits: |
paul@25 | 122 | if not cat_pattern.match(page.page_name): |
paul@25 | 123 | pages.append(page) |
paul@25 | 124 | return pages |
paul@25 | 125 | |
paul@25 | 126 | def getAllCategoryPages(category_names, request): |
paul@25 | 127 | |
paul@25 | 128 | """ |
paul@25 | 129 | Return all pages belonging to the categories having the given |
paul@25 | 130 | 'category_names', using the given 'request'. |
paul@25 | 131 | """ |
paul@25 | 132 | |
paul@25 | 133 | pages = [] |
paul@25 | 134 | pagenames = set() |
paul@25 | 135 | |
paul@25 | 136 | for category_name in category_names: |
paul@25 | 137 | |
paul@25 | 138 | # Get the pages and page names in the category. |
paul@25 | 139 | |
paul@25 | 140 | pages_in_category = getCategoryPages(category_name, request) |
paul@25 | 141 | |
paul@25 | 142 | # Visit each page in the category. |
paul@25 | 143 | |
paul@25 | 144 | for page_in_category in pages_in_category: |
paul@25 | 145 | pagename = page_in_category.page_name |
paul@25 | 146 | |
paul@25 | 147 | # Only process each page once. |
paul@25 | 148 | |
paul@25 | 149 | if pagename in pagenames: |
paul@25 | 150 | continue |
paul@25 | 151 | else: |
paul@25 | 152 | pagenames.add(pagename) |
paul@25 | 153 | |
paul@25 | 154 | pages.append(page_in_category) |
paul@25 | 155 | |
paul@25 | 156 | return pages |
paul@25 | 157 | |
paul@28 | 158 | def getPagesForSearch(search_pattern, request): |
paul@27 | 159 | |
paul@27 | 160 | """ |
paul@27 | 161 | Return result pages for a search employing the given 'search_pattern' and |
paul@28 | 162 | using the given 'request'. |
paul@27 | 163 | """ |
paul@27 | 164 | |
paul@27 | 165 | query = search.QueryParser().parse_query(search_pattern) |
paul@27 | 166 | results = search.searchPages(request, query, "page_name") |
paul@27 | 167 | return filterCategoryPages(results, request) |
paul@27 | 168 | |
paul@25 | 169 | # WikiDict functions. |
paul@25 | 170 | |
paul@25 | 171 | def getWikiDict(pagename, request): |
paul@25 | 172 | |
paul@25 | 173 | """ |
paul@25 | 174 | Return the WikiDict provided by the given 'pagename' using the given |
paul@25 | 175 | 'request'. |
paul@2 | 176 | """ |
paul@2 | 177 | |
paul@25 | 178 | if pagename and Page(request, pagename).exists() and request.user.may.read(pagename): |
paul@25 | 179 | if hasattr(request.dicts, "dict"): |
paul@25 | 180 | return request.dicts.dict(pagename) |
paul@25 | 181 | else: |
paul@25 | 182 | return request.dicts[pagename] |
paul@0 | 183 | else: |
paul@25 | 184 | return None |
paul@25 | 185 | |
paul@25 | 186 | # Searching-related functions. |
paul@25 | 187 | |
paul@25 | 188 | def getPagesFromResults(result_pages, request): |
paul@25 | 189 | |
paul@25 | 190 | "Return genuine pages for the given 'result_pages' using the 'request'." |
paul@25 | 191 | |
paul@25 | 192 | return [Page(request, page.page_name) for page in result_pages] |
paul@25 | 193 | |
paul@25 | 194 | # Region/section parsing. |
paul@25 | 195 | |
paul@25 | 196 | def getRegions(s, include_non_regions=False): |
paul@25 | 197 | |
paul@25 | 198 | """ |
paul@25 | 199 | Parse the string 's', returning a list of explicitly declared regions. |
paul@25 | 200 | |
paul@25 | 201 | If 'include_non_regions' is specified as a true value, fragments will be |
paul@25 | 202 | included for text between explicitly declared regions. |
paul@25 | 203 | """ |
paul@25 | 204 | |
paul@25 | 205 | regions = [] |
paul@25 | 206 | marker = None |
paul@25 | 207 | is_block = True |
paul@25 | 208 | |
paul@25 | 209 | # Start a region for exposed text, if appropriate. |
paul@25 | 210 | |
paul@25 | 211 | if include_non_regions: |
paul@25 | 212 | regions.append("") |
paul@25 | 213 | |
paul@25 | 214 | for match_text in marker_regexp.split(s): |
paul@25 | 215 | |
paul@25 | 216 | # Capture section text. |
paul@25 | 217 | |
paul@25 | 218 | if is_block: |
paul@25 | 219 | if marker or include_non_regions: |
paul@25 | 220 | regions[-1] += match_text |
paul@25 | 221 | |
paul@25 | 222 | # Handle section markers. |
paul@25 | 223 | |
paul@31 | 224 | else: |
paul@25 | 225 | |
paul@25 | 226 | # Close any open sections, returning to exposed text regions. |
paul@25 | 227 | |
paul@25 | 228 | if marker: |
paul@31 | 229 | |
paul@31 | 230 | # Add any marker to the current region, regardless of whether it |
paul@31 | 231 | # successfully closes a section. |
paul@31 | 232 | |
paul@31 | 233 | regions[-1] += match_text |
paul@31 | 234 | |
paul@25 | 235 | if match_text.startswith("}") and len(marker) == len(match_text): |
paul@25 | 236 | marker = None |
paul@25 | 237 | |
paul@25 | 238 | # Start a region for exposed text, if appropriate. |
paul@25 | 239 | |
paul@25 | 240 | if include_non_regions: |
paul@25 | 241 | regions.append("") |
paul@25 | 242 | |
paul@31 | 243 | # Without a current marker, start a new section. |
paul@25 | 244 | |
paul@31 | 245 | else: |
paul@25 | 246 | marker = match_text |
paul@25 | 247 | regions.append("") |
paul@25 | 248 | |
paul@31 | 249 | # Add the marker to the new region. |
paul@25 | 250 | |
paul@31 | 251 | regions[-1] += match_text |
paul@0 | 252 | |
paul@25 | 253 | # The match text alternates between text between markers and the markers |
paul@25 | 254 | # themselves. |
paul@25 | 255 | |
paul@25 | 256 | is_block = not is_block |
paul@25 | 257 | |
paul@25 | 258 | return regions |
paul@25 | 259 | |
paul@25 | 260 | def getFragmentsFromRegions(regions): |
paul@25 | 261 | |
paul@25 | 262 | """ |
paul@25 | 263 | Return fragments from the given 'regions', each having the form |
paul@32 | 264 | (format, attributes, body text). |
paul@25 | 265 | """ |
paul@25 | 266 | |
paul@25 | 267 | fragments = [] |
paul@25 | 268 | |
paul@25 | 269 | for region in regions: |
paul@32 | 270 | format, attributes, body, header, close = getFragmentFromRegion(region) |
paul@32 | 271 | fragments.append((format, attributes, body)) |
paul@25 | 272 | |
paul@32 | 273 | return fragments |
paul@25 | 274 | |
paul@32 | 275 | def getFragmentFromRegion(region): |
paul@25 | 276 | |
paul@32 | 277 | """ |
paul@32 | 278 | Return a fragment for the given 'region' having the form (format, |
paul@32 | 279 | attributes, body text, header, close), where the 'header' is the original |
paul@32 | 280 | declaration of the 'region' or None if no explicit region is defined, and |
paul@32 | 281 | 'close' is the closing marker of the 'region' or None if no explicit region |
paul@32 | 282 | is defined. |
paul@32 | 283 | """ |
paul@25 | 284 | |
paul@32 | 285 | if region.startswith("{{{"): |
paul@25 | 286 | |
paul@32 | 287 | body = region.lstrip("{") |
paul@32 | 288 | level = len(region) - len(body) |
paul@32 | 289 | body = body.rstrip("}").lstrip() |
paul@32 | 290 | |
paul@32 | 291 | # Remove any prelude and process metadata. |
paul@32 | 292 | |
paul@32 | 293 | if body.startswith("#!"): |
paul@25 | 294 | |
paul@32 | 295 | try: |
paul@32 | 296 | declaration, body = body.split("\n", 1) |
paul@32 | 297 | except ValueError: |
paul@32 | 298 | declaration = body |
paul@32 | 299 | body = "" |
paul@25 | 300 | |
paul@32 | 301 | arguments = declaration[2:] |
paul@32 | 302 | |
paul@32 | 303 | # Get any parser/format declaration. |
paul@25 | 304 | |
paul@32 | 305 | if arguments and not arguments[0].isspace(): |
paul@32 | 306 | details = arguments.split(None, 1) |
paul@32 | 307 | if len(details) == 2: |
paul@32 | 308 | format, arguments = details |
paul@32 | 309 | else: |
paul@32 | 310 | format = details[0] |
paul@32 | 311 | arguments = "" |
paul@32 | 312 | else: |
paul@32 | 313 | format = None |
paul@25 | 314 | |
paul@32 | 315 | # Get the attributes/arguments for the region. |
paul@32 | 316 | |
paul@32 | 317 | attributes = parseAttributes(arguments, False) |
paul@25 | 318 | |
paul@32 | 319 | # Add an entry for the format in the attribute dictionary. |
paul@25 | 320 | |
paul@32 | 321 | if format and not attributes.has_key(format): |
paul@32 | 322 | attributes[format] = True |
paul@32 | 323 | |
paul@32 | 324 | return format, attributes, body, level * "{" + declaration + "\n", level * "}" |
paul@25 | 325 | |
paul@25 | 326 | else: |
paul@32 | 327 | return None, {}, body, level * "{" + "\n", level * "}" |
paul@25 | 328 | |
paul@32 | 329 | else: |
paul@32 | 330 | return None, {}, region, None, None |
paul@25 | 331 | |
paul@25 | 332 | def getFragments(s, include_non_regions=False): |
paul@25 | 333 | |
paul@25 | 334 | """ |
paul@25 | 335 | Return fragments for the given string 's', each having the form |
paul@25 | 336 | (format, arguments, body text). |
paul@25 | 337 | |
paul@25 | 338 | If 'include_non_regions' is specified as a true value, fragments will be |
paul@25 | 339 | included for text between explicitly declared regions. |
paul@25 | 340 | """ |
paul@25 | 341 | |
paul@25 | 342 | return getFragmentsFromRegions(getRegions(s, include_non_regions)) |
paul@25 | 343 | |
paul@29 | 344 | # Heading extraction. |
paul@29 | 345 | |
paul@29 | 346 | def getHeadings(s): |
paul@29 | 347 | |
paul@29 | 348 | """ |
paul@29 | 349 | Return tuples of the form (level, title, span) for headings found within the |
paul@29 | 350 | given string 's'. The span is itself a (start, end) tuple indicating the |
paul@29 | 351 | matching region of 's' for a heading declaration. |
paul@29 | 352 | """ |
paul@29 | 353 | |
paul@29 | 354 | headings = [] |
paul@29 | 355 | |
paul@29 | 356 | for match in heading_regexp.finditer(s): |
paul@29 | 357 | headings.append( |
paul@29 | 358 | (len(match.group("level")), match.group("heading"), match.span()) |
paul@29 | 359 | ) |
paul@29 | 360 | |
paul@29 | 361 | return headings |
paul@29 | 362 | |
paul@25 | 363 | # Region/section attribute parsing. |
paul@0 | 364 | |
paul@10 | 365 | def parseAttributes(s, escape=True): |
paul@10 | 366 | |
paul@10 | 367 | """ |
paul@10 | 368 | Parse the section attributes string 's', returning a mapping of names to |
paul@10 | 369 | values. If 'escape' is set to a true value, the attributes will be suitable |
paul@10 | 370 | for use with the formatter API. If 'escape' is set to a false value, the |
paul@10 | 371 | attributes will have any quoting removed. |
paul@10 | 372 | """ |
paul@10 | 373 | |
paul@10 | 374 | attrs = {} |
paul@10 | 375 | f = StringIO(s) |
paul@10 | 376 | name = None |
paul@10 | 377 | need_value = False |
paul@34 | 378 | lex = shlex(f) |
paul@34 | 379 | lex.wordchars += "-" |
paul@10 | 380 | |
paul@34 | 381 | for token in lex: |
paul@10 | 382 | |
paul@10 | 383 | # Capture the name if needed. |
paul@10 | 384 | |
paul@10 | 385 | if name is None: |
paul@10 | 386 | name = escape and wikiutil.escape(token) or strip_token(token) |
paul@10 | 387 | |
paul@10 | 388 | # Detect either an equals sign or another name. |
paul@10 | 389 | |
paul@10 | 390 | elif not need_value: |
paul@10 | 391 | if token == "=": |
paul@10 | 392 | need_value = True |
paul@10 | 393 | else: |
paul@10 | 394 | attrs[name.lower()] = escape and "true" or True |
paul@10 | 395 | name = wikiutil.escape(token) |
paul@10 | 396 | |
paul@10 | 397 | # Otherwise, capture a value. |
paul@10 | 398 | |
paul@10 | 399 | else: |
paul@10 | 400 | # Quoting of attributes done similarly to wikiutil.parseAttributes. |
paul@10 | 401 | |
paul@10 | 402 | if token: |
paul@10 | 403 | if escape: |
paul@10 | 404 | if token[0] in ("'", '"'): |
paul@10 | 405 | token = wikiutil.escape(token) |
paul@10 | 406 | else: |
paul@10 | 407 | token = '"%s"' % wikiutil.escape(token, 1) |
paul@10 | 408 | else: |
paul@10 | 409 | token = strip_token(token) |
paul@10 | 410 | |
paul@10 | 411 | attrs[name.lower()] = token |
paul@10 | 412 | name = None |
paul@10 | 413 | need_value = False |
paul@10 | 414 | |
paul@13 | 415 | # Handle any name-only attributes at the end of the collection. |
paul@13 | 416 | |
paul@13 | 417 | if name and not need_value: |
paul@13 | 418 | attrs[name.lower()] = escape and "true" or True |
paul@13 | 419 | |
paul@10 | 420 | return attrs |
paul@10 | 421 | |
paul@10 | 422 | def strip_token(token): |
paul@10 | 423 | |
paul@10 | 424 | "Return the given 'token' stripped of quoting." |
paul@10 | 425 | |
paul@10 | 426 | if token[0] in ("'", '"') and token[-1] == token[0]: |
paul@10 | 427 | return token[1:-1] |
paul@10 | 428 | else: |
paul@10 | 429 | return token |
paul@10 | 430 | |
paul@46 | 431 | # Macro argument parsing. |
paul@46 | 432 | |
paul@46 | 433 | def parseMacroArguments(args): |
paul@46 | 434 | |
paul@46 | 435 | """ |
paul@46 | 436 | Interpret the arguments. To support commas in labels, the label argument |
paul@46 | 437 | should be quoted. For example: |
paul@46 | 438 | |
paul@46 | 439 | "label=No, thanks!" |
paul@46 | 440 | """ |
paul@46 | 441 | |
paul@46 | 442 | try: |
paul@46 | 443 | parsed_args = args and wikiutil.parse_quoted_separated(args, name_value=False) or [] |
paul@46 | 444 | except AttributeError: |
paul@46 | 445 | parsed_args = args.split(",") |
paul@46 | 446 | |
paul@46 | 447 | pairs = [] |
paul@46 | 448 | for arg in parsed_args: |
paul@46 | 449 | if arg: |
paul@46 | 450 | pair = arg.split("=", 1) |
paul@46 | 451 | if len(pair) < 2: |
paul@46 | 452 | pairs.append((None, arg)) |
paul@46 | 453 | else: |
paul@46 | 454 | pairs.append(tuple(pair)) |
paul@46 | 455 | |
paul@46 | 456 | return pairs |
paul@46 | 457 | |
paul@25 | 458 | # Request-related classes and associated functions. |
paul@0 | 459 | |
paul@0 | 460 | class Form: |
paul@0 | 461 | |
paul@0 | 462 | """ |
paul@0 | 463 | A wrapper preserving MoinMoin 1.8.x (and earlier) behaviour in a 1.9.x |
paul@0 | 464 | environment. |
paul@0 | 465 | """ |
paul@0 | 466 | |
paul@35 | 467 | def __init__(self, request): |
paul@35 | 468 | self.request = request |
paul@35 | 469 | self.form = request.values |
paul@0 | 470 | |
paul@0 | 471 | def has_key(self, name): |
paul@0 | 472 | return not not self.form.getlist(name) |
paul@0 | 473 | |
paul@0 | 474 | def get(self, name, default=None): |
paul@0 | 475 | values = self.form.getlist(name) |
paul@0 | 476 | if not values: |
paul@0 | 477 | return default |
paul@0 | 478 | else: |
paul@0 | 479 | return values |
paul@0 | 480 | |
paul@0 | 481 | def __getitem__(self, name): |
paul@0 | 482 | return self.form.getlist(name) |
paul@0 | 483 | |
paul@35 | 484 | def __setitem__(self, name, value): |
paul@35 | 485 | try: |
paul@35 | 486 | self.form.setlist(name, value) |
paul@35 | 487 | except TypeError: |
paul@35 | 488 | self._write_enable() |
paul@35 | 489 | self.form.setlist(name, value) |
paul@35 | 490 | |
paul@33 | 491 | def __delitem__(self, name): |
paul@35 | 492 | try: |
paul@35 | 493 | del self.form[name] |
paul@35 | 494 | except TypeError: |
paul@35 | 495 | self._write_enable() |
paul@35 | 496 | del self.form[name] |
paul@35 | 497 | |
paul@35 | 498 | def _write_enable(self): |
paul@35 | 499 | self.form = self.request.values = MultiDict(self.form) |
paul@33 | 500 | |
paul@33 | 501 | def keys(self): |
paul@33 | 502 | return self.form.keys() |
paul@33 | 503 | |
paul@32 | 504 | def items(self): |
paul@35 | 505 | return self.form.lists() |
paul@32 | 506 | |
paul@0 | 507 | class ActionSupport: |
paul@0 | 508 | |
paul@0 | 509 | """ |
paul@0 | 510 | Work around disruptive MoinMoin changes in 1.9, and also provide useful |
paul@0 | 511 | convenience methods. |
paul@0 | 512 | """ |
paul@0 | 513 | |
paul@0 | 514 | def get_form(self): |
paul@0 | 515 | return get_form(self.request) |
paul@0 | 516 | |
paul@0 | 517 | def _get_selected(self, value, input_value): |
paul@0 | 518 | |
paul@0 | 519 | """ |
paul@0 | 520 | Return the HTML attribute text indicating selection of an option (or |
paul@0 | 521 | otherwise) if 'value' matches 'input_value'. |
paul@0 | 522 | """ |
paul@0 | 523 | |
paul@0 | 524 | return input_value is not None and value == input_value and 'selected="selected"' or '' |
paul@0 | 525 | |
paul@0 | 526 | def _get_selected_for_list(self, value, input_values): |
paul@0 | 527 | |
paul@0 | 528 | """ |
paul@0 | 529 | Return the HTML attribute text indicating selection of an option (or |
paul@0 | 530 | otherwise) if 'value' matches one of the 'input_values'. |
paul@0 | 531 | """ |
paul@0 | 532 | |
paul@0 | 533 | return value in input_values and 'selected="selected"' or '' |
paul@0 | 534 | |
paul@26 | 535 | def get_option_list(self, value, values): |
paul@26 | 536 | |
paul@26 | 537 | """ |
paul@26 | 538 | Return a list of HTML element definitions for options describing the |
paul@26 | 539 | given 'values', selecting the option with the specified 'value' if |
paul@26 | 540 | present. |
paul@26 | 541 | """ |
paul@26 | 542 | |
paul@26 | 543 | options = [] |
paul@26 | 544 | for available_value in values: |
paul@26 | 545 | selected = self._get_selected(available_value, value) |
paul@26 | 546 | options.append('<option value="%s" %s>%s</option>' % ( |
paul@26 | 547 | escattr(available_value), selected, wikiutil.escape(available_value))) |
paul@26 | 548 | return options |
paul@26 | 549 | |
paul@0 | 550 | def _get_input(self, form, name, default=None): |
paul@0 | 551 | |
paul@0 | 552 | """ |
paul@0 | 553 | Return the input from 'form' having the given 'name', returning either |
paul@0 | 554 | the input converted to an integer or the given 'default' (optional, None |
paul@0 | 555 | if not specified). |
paul@0 | 556 | """ |
paul@0 | 557 | |
paul@0 | 558 | value = form.get(name, [None])[0] |
paul@0 | 559 | if not value: # true if 0 obtained |
paul@0 | 560 | return default |
paul@0 | 561 | else: |
paul@0 | 562 | return int(value) |
paul@0 | 563 | |
paul@0 | 564 | def get_form(request): |
paul@0 | 565 | |
paul@0 | 566 | "Work around disruptive MoinMoin changes in 1.9." |
paul@0 | 567 | |
paul@0 | 568 | if hasattr(request, "values"): |
paul@35 | 569 | return Form(request) |
paul@0 | 570 | else: |
paul@0 | 571 | return request.form |
paul@0 | 572 | |
paul@0 | 573 | class send_headers_cls: |
paul@0 | 574 | |
paul@0 | 575 | """ |
paul@0 | 576 | A wrapper to preserve MoinMoin 1.8.x (and earlier) request behaviour in a |
paul@0 | 577 | 1.9.x environment. |
paul@0 | 578 | """ |
paul@0 | 579 | |
paul@0 | 580 | def __init__(self, request): |
paul@0 | 581 | self.request = request |
paul@0 | 582 | |
paul@0 | 583 | def __call__(self, headers): |
paul@0 | 584 | for header in headers: |
paul@0 | 585 | parts = header.split(":") |
paul@0 | 586 | self.request.headers.add(parts[0], ":".join(parts[1:])) |
paul@0 | 587 | |
paul@0 | 588 | def get_send_headers(request): |
paul@0 | 589 | |
paul@0 | 590 | "Return a function that can send response headers." |
paul@0 | 591 | |
paul@0 | 592 | if hasattr(request, "http_headers"): |
paul@0 | 593 | return request.http_headers |
paul@0 | 594 | elif hasattr(request, "emit_http_headers"): |
paul@0 | 595 | return request.emit_http_headers |
paul@0 | 596 | else: |
paul@0 | 597 | return send_headers_cls(request) |
paul@0 | 598 | |
paul@0 | 599 | def escattr(s): |
paul@0 | 600 | return wikiutil.escape(s, 1) |
paul@0 | 601 | |
paul@0 | 602 | def getPathInfo(request): |
paul@0 | 603 | if hasattr(request, "getPathinfo"): |
paul@0 | 604 | return request.getPathinfo() |
paul@0 | 605 | else: |
paul@0 | 606 | return request.path |
paul@0 | 607 | |
paul@14 | 608 | def getHeader(request, header_name, prefix=None): |
paul@17 | 609 | |
paul@17 | 610 | """ |
paul@17 | 611 | Using the 'request', return the value of the header with the given |
paul@17 | 612 | 'header_name', using the optional 'prefix' to obtain protocol-specific |
paul@17 | 613 | headers if necessary. |
paul@17 | 614 | |
paul@17 | 615 | If no value is found for the given 'header_name', None is returned. |
paul@17 | 616 | """ |
paul@17 | 617 | |
paul@14 | 618 | if hasattr(request, "getHeader"): |
paul@14 | 619 | return request.getHeader(header_name) |
paul@14 | 620 | elif hasattr(request, "headers"): |
paul@17 | 621 | return request.headers.get(header_name) |
paul@14 | 622 | else: |
paul@17 | 623 | return request.env.get((prefix and prefix + "_" or "") + header_name.upper()) |
paul@14 | 624 | |
paul@23 | 625 | def writeHeaders(request, mimetype, metadata, status=None): |
paul@23 | 626 | |
paul@23 | 627 | """ |
paul@23 | 628 | Using the 'request', write resource headers using the given 'mimetype', |
paul@23 | 629 | based on the given 'metadata'. If the optional 'status' is specified, set |
paul@23 | 630 | the status header to the given value. |
paul@23 | 631 | """ |
paul@23 | 632 | |
paul@23 | 633 | send_headers = get_send_headers(request) |
paul@23 | 634 | |
paul@23 | 635 | # Define headers. |
paul@23 | 636 | |
paul@23 | 637 | headers = ["Content-Type: %s; charset=%s" % (mimetype, config.charset)] |
paul@23 | 638 | |
paul@23 | 639 | # Define the last modified time. |
paul@23 | 640 | # NOTE: Consider using request.httpDate. |
paul@23 | 641 | |
paul@23 | 642 | latest_timestamp = metadata.get("last-modified") |
paul@23 | 643 | if latest_timestamp: |
paul@23 | 644 | headers.append("Last-Modified: %s" % latest_timestamp.as_HTTP_datetime_string()) |
paul@23 | 645 | |
paul@23 | 646 | if status: |
paul@23 | 647 | headers.append("Status: %s" % status) |
paul@23 | 648 | |
paul@23 | 649 | send_headers(headers) |
paul@23 | 650 | |
paul@1 | 651 | # Page access functions. |
paul@1 | 652 | |
paul@1 | 653 | def getPageURL(page): |
paul@1 | 654 | |
paul@1 | 655 | "Return the URL of the given 'page'." |
paul@1 | 656 | |
paul@1 | 657 | request = page.request |
paul@1 | 658 | return request.getQualifiedURL(page.url(request, relative=0)) |
paul@1 | 659 | |
paul@1 | 660 | def getFormat(page): |
paul@1 | 661 | |
paul@1 | 662 | "Get the format used on the given 'page'." |
paul@1 | 663 | |
paul@1 | 664 | return page.pi["format"] |
paul@1 | 665 | |
paul@1 | 666 | def getMetadata(page): |
paul@1 | 667 | |
paul@1 | 668 | """ |
paul@1 | 669 | Return a dictionary containing items describing for the given 'page' the |
paul@1 | 670 | page's "created" time, "last-modified" time, "sequence" (or revision number) |
paul@1 | 671 | and the "last-comment" made about the last edit. |
paul@1 | 672 | """ |
paul@1 | 673 | |
paul@1 | 674 | request = page.request |
paul@1 | 675 | |
paul@1 | 676 | # Get the initial revision of the page. |
paul@1 | 677 | |
paul@1 | 678 | revisions = page.getRevList() |
paul@26 | 679 | |
paul@26 | 680 | if not revisions: |
paul@26 | 681 | return {} |
paul@26 | 682 | |
paul@1 | 683 | event_page_initial = Page(request, page.page_name, rev=revisions[-1]) |
paul@1 | 684 | |
paul@1 | 685 | # Get the created and last modified times. |
paul@1 | 686 | |
paul@1 | 687 | initial_revision = getPageRevision(event_page_initial) |
paul@1 | 688 | |
paul@1 | 689 | metadata = {} |
paul@1 | 690 | metadata["created"] = initial_revision["timestamp"] |
paul@1 | 691 | latest_revision = getPageRevision(page) |
paul@1 | 692 | metadata["last-modified"] = latest_revision["timestamp"] |
paul@1 | 693 | metadata["sequence"] = len(revisions) - 1 |
paul@1 | 694 | metadata["last-comment"] = latest_revision["comment"] |
paul@1 | 695 | |
paul@1 | 696 | return metadata |
paul@0 | 697 | |
paul@0 | 698 | def getPageRevision(page): |
paul@0 | 699 | |
paul@0 | 700 | "Return the revision details dictionary for the given 'page'." |
paul@0 | 701 | |
paul@0 | 702 | # From Page.edit_info... |
paul@0 | 703 | |
paul@0 | 704 | if hasattr(page, "editlog_entry"): |
paul@0 | 705 | line = page.editlog_entry() |
paul@0 | 706 | else: |
paul@0 | 707 | line = page._last_edited(page.request) # MoinMoin 1.5.x and 1.6.x |
paul@0 | 708 | |
paul@0 | 709 | # Similar to Page.mtime_usecs behaviour... |
paul@0 | 710 | |
paul@0 | 711 | if line: |
paul@0 | 712 | timestamp = line.ed_time_usecs |
paul@0 | 713 | mtime = wikiutil.version2timestamp(long(timestamp)) # must be long for py 2.2.x |
paul@0 | 714 | comment = line.comment |
paul@0 | 715 | else: |
paul@0 | 716 | mtime = 0 |
paul@0 | 717 | comment = "" |
paul@0 | 718 | |
paul@0 | 719 | # Leave the time zone empty. |
paul@0 | 720 | |
paul@0 | 721 | return {"timestamp" : DateTime(time.gmtime(mtime)[:6] + (None,)), "comment" : comment} |
paul@0 | 722 | |
paul@11 | 723 | # Page parsing and formatting of embedded content. |
paul@11 | 724 | |
paul@15 | 725 | def getPageParserClass(request): |
paul@15 | 726 | |
paul@15 | 727 | "Using 'request', return a parser class for the current page's format." |
paul@15 | 728 | |
paul@16 | 729 | return getParserClass(request, getFormat(request.page)) |
paul@15 | 730 | |
paul@11 | 731 | def getParserClass(request, format): |
paul@11 | 732 | |
paul@11 | 733 | """ |
paul@11 | 734 | Return a parser class using the 'request' for the given 'format', returning |
paul@11 | 735 | a plain text parser if no parser can be found for the specified 'format'. |
paul@11 | 736 | """ |
paul@11 | 737 | |
paul@11 | 738 | try: |
paul@11 | 739 | return wikiutil.searchAndImportPlugin(request.cfg, "parser", format or "plain") |
paul@11 | 740 | except wikiutil.PluginMissingError: |
paul@11 | 741 | return wikiutil.searchAndImportPlugin(request.cfg, "parser", "plain") |
paul@11 | 742 | |
paul@15 | 743 | def getFormatterClass(request, format): |
paul@15 | 744 | |
paul@15 | 745 | """ |
paul@15 | 746 | Return a formatter class using the 'request' for the given output 'format', |
paul@15 | 747 | returning a plain text formatter if no formatter can be found for the |
paul@15 | 748 | specified 'format'. |
paul@15 | 749 | """ |
paul@15 | 750 | |
paul@15 | 751 | try: |
paul@15 | 752 | return wikiutil.searchAndImportPlugin(request.cfg, "formatter", format or "plain") |
paul@15 | 753 | except wikiutil.PluginMissingError: |
paul@15 | 754 | return wikiutil.searchAndImportPlugin(request.cfg, "formatter", "plain") |
paul@15 | 755 | |
paul@33 | 756 | def formatText(text, request, fmt, inhibit_p=True, parser_cls=None): |
paul@15 | 757 | |
paul@15 | 758 | """ |
paul@15 | 759 | Format the given 'text' using the specified 'request' and formatter 'fmt'. |
paul@15 | 760 | Suppress line anchors in the output, and fix lists by indicating that a |
paul@15 | 761 | paragraph has already been started. |
paul@15 | 762 | """ |
paul@15 | 763 | |
paul@15 | 764 | if not parser_cls: |
paul@15 | 765 | parser_cls = getPageParserClass(request) |
paul@15 | 766 | parser = parser_cls(text, request, line_anchors=False) |
paul@15 | 767 | |
paul@15 | 768 | old_fmt = request.formatter |
paul@15 | 769 | request.formatter = fmt |
paul@15 | 770 | try: |
paul@33 | 771 | return redirectedOutput(request, parser, fmt, inhibit_p=inhibit_p) |
paul@15 | 772 | finally: |
paul@15 | 773 | request.formatter = old_fmt |
paul@15 | 774 | |
paul@11 | 775 | def redirectedOutput(request, parser, fmt, **kw): |
paul@11 | 776 | |
paul@11 | 777 | "A fixed version of the request method of the same name." |
paul@11 | 778 | |
paul@11 | 779 | buf = StringIO() |
paul@11 | 780 | request.redirect(buf) |
paul@11 | 781 | try: |
paul@11 | 782 | parser.format(fmt, **kw) |
paul@11 | 783 | if hasattr(fmt, "flush"): |
paul@11 | 784 | buf.write(fmt.flush(True)) |
paul@11 | 785 | finally: |
paul@11 | 786 | request.redirect() |
paul@11 | 787 | text = buf.getvalue() |
paul@11 | 788 | buf.close() |
paul@11 | 789 | return text |
paul@11 | 790 | |
paul@46 | 791 | # Finding components for content types. |
paul@46 | 792 | |
paul@46 | 793 | def getParsersForContentType(cfg, mimetype): |
paul@46 | 794 | |
paul@46 | 795 | """ |
paul@46 | 796 | Find parsers that support the given 'mimetype', constructing a dictionary |
paul@46 | 797 | mapping content types to lists of parsers that is then cached in the 'cfg' |
paul@46 | 798 | object. A list of suitable parsers is returned for 'mimetype'. |
paul@46 | 799 | """ |
paul@46 | 800 | |
paul@46 | 801 | if not hasattr(cfg.cache, "MIMETYPE_TO_PARSER"): |
paul@46 | 802 | available = {} |
paul@46 | 803 | |
paul@46 | 804 | for name in wikiutil.getPlugins("parser", cfg): |
paul@46 | 805 | |
paul@46 | 806 | # Import each parser in order to inspect supported content types. |
paul@46 | 807 | |
paul@46 | 808 | try: |
paul@46 | 809 | parser_cls = wikiutil.importPlugin(cfg, "parser", name, "Parser") |
paul@46 | 810 | except wikiutil.PluginMissingError: |
paul@46 | 811 | continue |
paul@46 | 812 | |
paul@46 | 813 | # Attempt to determine supported content types. |
paul@46 | 814 | # NOTE: Extensions and /etc/mime.types (or equivalent) could also be |
paul@46 | 815 | # NOTE: used. |
paul@46 | 816 | |
paul@46 | 817 | if hasattr(parser_cls, "input_mimetypes"): |
paul@46 | 818 | for input_mimetype in parser_cls.input_mimetypes: |
paul@46 | 819 | if not available.has_key(input_mimetype): |
paul@46 | 820 | available[input_mimetype] = [] |
paul@46 | 821 | available[input_mimetype].append(parser_cls) |
paul@46 | 822 | |
paul@46 | 823 | # Support some basic parsers. |
paul@46 | 824 | |
paul@46 | 825 | elif name == "text_moin_wiki": |
paul@46 | 826 | available["text/moin-wiki"] = [parser_cls] |
paul@46 | 827 | available["text/moin"] = [parser_cls] |
paul@46 | 828 | |
paul@46 | 829 | cfg.cache.MIMETYPE_TO_PARSER = available |
paul@46 | 830 | |
paul@46 | 831 | return cfg.cache.MIMETYPE_TO_PARSER.get(mimetype, []) |
paul@46 | 832 | |
paul@25 | 833 | # Textual representations. |
paul@25 | 834 | |
paul@25 | 835 | def getSimpleWikiText(text): |
paul@25 | 836 | |
paul@25 | 837 | """ |
paul@25 | 838 | Return the plain text representation of the given 'text' which may employ |
paul@25 | 839 | certain Wiki syntax features, such as those providing verbatim or monospaced |
paul@25 | 840 | text. |
paul@25 | 841 | """ |
paul@25 | 842 | |
paul@25 | 843 | # NOTE: Re-implementing support for verbatim text and linking avoidance. |
paul@25 | 844 | |
paul@25 | 845 | return "".join([s for s in verbatim_regexp.split(text) if s is not None]) |
paul@25 | 846 | |
paul@25 | 847 | def getEncodedWikiText(text): |
paul@25 | 848 | |
paul@25 | 849 | "Encode the given 'text' in a verbatim representation." |
paul@25 | 850 | |
paul@25 | 851 | return "<<Verbatim(%s)>>" % text |
paul@25 | 852 | |
paul@25 | 853 | def getPrettyTitle(title): |
paul@25 | 854 | |
paul@25 | 855 | "Return a nicely formatted version of the given 'title'." |
paul@25 | 856 | |
paul@25 | 857 | return title.replace("_", " ").replace("/", u" ? ") |
paul@25 | 858 | |
paul@0 | 859 | # User interface functions. |
paul@0 | 860 | |
paul@0 | 861 | def getParameter(request, name, default=None): |
paul@0 | 862 | |
paul@0 | 863 | """ |
paul@0 | 864 | Using the given 'request', return the value of the parameter with the given |
paul@0 | 865 | 'name', returning the optional 'default' (or None) if no value was supplied |
paul@0 | 866 | in the 'request'. |
paul@0 | 867 | """ |
paul@0 | 868 | |
paul@0 | 869 | return get_form(request).get(name, [default])[0] |
paul@0 | 870 | |
paul@0 | 871 | def getQualifiedParameter(request, prefix, argname, default=None): |
paul@0 | 872 | |
paul@0 | 873 | """ |
paul@0 | 874 | Using the given 'request', 'prefix' and 'argname', retrieve the value of the |
paul@0 | 875 | qualified parameter, returning the optional 'default' (or None) if no value |
paul@0 | 876 | was supplied in the 'request'. |
paul@0 | 877 | """ |
paul@0 | 878 | |
paul@0 | 879 | argname = getQualifiedParameterName(prefix, argname) |
paul@0 | 880 | return getParameter(request, argname, default) |
paul@0 | 881 | |
paul@0 | 882 | def getQualifiedParameterName(prefix, argname): |
paul@0 | 883 | |
paul@0 | 884 | """ |
paul@0 | 885 | Return the qualified parameter name using the given 'prefix' and 'argname'. |
paul@0 | 886 | """ |
paul@0 | 887 | |
paul@27 | 888 | if not prefix: |
paul@0 | 889 | return argname |
paul@0 | 890 | else: |
paul@0 | 891 | return "%s-%s" % (prefix, argname) |
paul@0 | 892 | |
paul@0 | 893 | # Page-related functions. |
paul@0 | 894 | |
paul@0 | 895 | def getPrettyPageName(page): |
paul@0 | 896 | |
paul@0 | 897 | "Return a nicely formatted title/name for the given 'page'." |
paul@0 | 898 | |
paul@0 | 899 | title = page.split_title(force=1) |
paul@0 | 900 | return getPrettyTitle(title) |
paul@0 | 901 | |
paul@25 | 902 | def linkToPage(request, page, text, query_string=None, anchor=None, **kw): |
paul@0 | 903 | |
paul@0 | 904 | """ |
paul@0 | 905 | Using 'request', return a link to 'page' with the given link 'text' and |
paul@25 | 906 | optional 'query_string' and 'anchor'. |
paul@0 | 907 | """ |
paul@0 | 908 | |
paul@0 | 909 | text = wikiutil.escape(text) |
paul@25 | 910 | return page.link_to_raw(request, text, query_string, anchor, **kw) |
paul@0 | 911 | |
paul@25 | 912 | def linkToResource(url, request, text, query_string=None, anchor=None): |
paul@0 | 913 | |
paul@0 | 914 | """ |
paul@0 | 915 | Using 'request', return a link to 'url' with the given link 'text' and |
paul@25 | 916 | optional 'query_string' and 'anchor'. |
paul@0 | 917 | """ |
paul@0 | 918 | |
paul@25 | 919 | if anchor: |
paul@25 | 920 | url += "#%s" % anchor |
paul@25 | 921 | |
paul@0 | 922 | if query_string: |
paul@0 | 923 | query_string = wikiutil.makeQueryString(query_string) |
paul@25 | 924 | url += "?%s" % query_string |
paul@0 | 925 | |
paul@0 | 926 | formatter = request.page and getattr(request.page, "formatter", None) or request.html_formatter |
paul@0 | 927 | |
paul@0 | 928 | output = [] |
paul@0 | 929 | output.append(formatter.url(1, url)) |
paul@0 | 930 | output.append(formatter.text(text)) |
paul@0 | 931 | output.append(formatter.url(0)) |
paul@0 | 932 | return "".join(output) |
paul@0 | 933 | |
paul@0 | 934 | def getFullPageName(parent, title): |
paul@0 | 935 | |
paul@0 | 936 | """ |
paul@0 | 937 | Return a full page name from the given 'parent' page (can be empty or None) |
paul@0 | 938 | and 'title' (a simple page name). |
paul@0 | 939 | """ |
paul@0 | 940 | |
paul@0 | 941 | if parent: |
paul@0 | 942 | return "%s/%s" % (parent.rstrip("/"), title) |
paul@0 | 943 | else: |
paul@0 | 944 | return title |
paul@0 | 945 | |
paul@37 | 946 | # Content storage support. |
paul@37 | 947 | |
paul@41 | 948 | class ItemStore(ItemDirectoryStore): |
paul@37 | 949 | |
paul@37 | 950 | "A page-specific item store." |
paul@37 | 951 | |
paul@45 | 952 | def __init__(self, page, item_dir=("items",), lock_dir=("item_locks",)): |
paul@37 | 953 | |
paul@37 | 954 | "Initialise an item store for the given 'page'." |
paul@37 | 955 | |
paul@45 | 956 | ItemDirectoryStore.__init__(self, page.getPagePath(*item_dir), page.getPagePath(*lock_dir)) |
paul@40 | 957 | self.page = page |
paul@37 | 958 | |
paul@40 | 959 | def can_write(self): |
paul@40 | 960 | |
paul@40 | 961 | """ |
paul@40 | 962 | Return whether the user associated with the request can write to the |
paul@40 | 963 | page owning this store. |
paul@40 | 964 | """ |
paul@40 | 965 | |
paul@40 | 966 | user = self.page.request.user |
paul@40 | 967 | return user and user.may.write(self.page.page_name) |
paul@40 | 968 | |
paul@42 | 969 | def can_read(self): |
paul@42 | 970 | |
paul@42 | 971 | """ |
paul@42 | 972 | Return whether the user associated with the request can read from the |
paul@42 | 973 | page owning this store. |
paul@42 | 974 | """ |
paul@42 | 975 | |
paul@42 | 976 | user = self.page.request.user |
paul@42 | 977 | return user and user.may.read(self.page.page_name) |
paul@42 | 978 | |
paul@41 | 979 | # High-level methods. |
paul@41 | 980 | |
paul@41 | 981 | def append(self, item): |
paul@41 | 982 | |
paul@41 | 983 | "Append the given 'item' to the store." |
paul@41 | 984 | |
paul@41 | 985 | if not self.can_write(): |
paul@41 | 986 | return |
paul@41 | 987 | |
paul@41 | 988 | ItemDirectoryStore.append(self, item) |
paul@41 | 989 | |
paul@42 | 990 | def __len__(self): |
paul@42 | 991 | |
paul@42 | 992 | """ |
paul@42 | 993 | Return the number of the next item (which should also be the number of |
paul@42 | 994 | items). |
paul@42 | 995 | """ |
paul@42 | 996 | |
paul@42 | 997 | if not self.can_read(): |
paul@42 | 998 | return 0 |
paul@42 | 999 | |
paul@42 | 1000 | return ItemDirectoryStore.__len__(self) |
paul@42 | 1001 | |
paul@42 | 1002 | def __getitem__(self, number): |
paul@42 | 1003 | |
paul@42 | 1004 | "Return the item with the given 'number'." |
paul@42 | 1005 | |
paul@42 | 1006 | if not self.can_read(): |
paul@42 | 1007 | raise IndexError, number |
paul@42 | 1008 | |
paul@42 | 1009 | return ItemDirectoryStore.__getitem__(self, number) |
paul@42 | 1010 | |
paul@0 | 1011 | # vim: tabstop=4 expandtab shiftwidth=4 |