Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
MoinMoin.wikiutil Namespace Reference

Classes

class  InvalidFileNameError
class  MetaDict
class  MimeType
class  PluginError
class  PluginMissingError
class  PluginAttributeError
class  BracketError
 Parameter parsing. More...
class  BracketUnexpectedCloseError
class  BracketMissingCloseError
class  ParserPrefix
class  IEFArgument
class  UnitArgument
class  required_arg
class  ParameterParser
class  Version

Functions

def decodeUnknownInput
 Getting data from user/Sending data to user.
def decodeUserInput
def url_quote
def url_quote_plus
def url_unquote
def parseQueryString
def makeQueryString
def quoteWikinameURL
def clean_input
def make_breakable
def quoteWikinameFS
def unquoteWikiname
def timestamp2version
def version2timestamp
def generate_file_list
def get_max_mtime
def load_wikimap
def split_wiki
def split_interwiki
def resolve_wiki
def resolve_interwiki
def join_wiki
def isSystemPage
 Page types (based on page names)
def isTemplatePage
def isGroupPage
def filterCategoryPages
def getLocalizedPage
def getFrontPage
def getHomePage
def getInterwikiHomePage
def AbsPageName
def RelPageName
def pagelinkmarkup
def importPlugin
def importWikiPlugin
def importBuiltinPlugin
def importNameFromPlugin
def builtinPlugins
def wikiPlugins
def getPlugins
def searchAndImportPlugin
def getParserForExtension
 Parsers.
def parse_quoted_separated_ext
def parse_quoted_separated
def get_bool
def get_int
def get_float
def get_complex
def get_unicode
def get_choice
def invoke_extension_function
def parseAttributes
def normalize_pagename
def taintfilename
def drawing2fname
def mapURL
def getUnicodeIndexGroup
def isStrictWikiname
def is_URL
def isPicture
def link_tag
def containsConflictMarker
def pagediff
def anchor_name_from_text
def split_anchor
def createTicket
 Tickets - used by RenamePage and DeletePage.
def checkTicket
def renderText
def get_processing_instructions

Variables

tuple logging = log.getLogger(__name__)
string PARENT_PREFIX = "../"
tuple PARENT_PREFIX_LEN = len(PARENT_PREFIX)
string CHILD_PREFIX = "/"
tuple CHILD_PREFIX_LEN = len(CHILD_PREFIX)
 escape = werkzeug.escape
tuple UNSAFE = re.compile(r'[^a-zA-Z0-9_]+')
 Storage.
tuple QUOTED = re.compile(r'\(([a-fA-F0-9]+)\)')
list INTEGER_METAS
string QUOTE_CHARS = u'"'
string INTERWIKI_PAGE = "InterWikiMap"
 InterWiki.
dictionary MIMETYPES_MORE
dictionary MIMETYPES_sanitize_mapping
dictionary MIMETYPES_spoil_mapping = {}

Class Documentation

class MoinMoin::wikiutil::InvalidFileNameError
Called when we find an invalid file name 

Definition at line 32 of file wikiutil.py.


Function Documentation

def MoinMoin.wikiutil.AbsPageName (   context,
  pagename 
)
Return the absolute pagename for a (possibly) relative pagename.

@param context: name of the page where "pagename" appears on
@param pagename: the (possibly relative) page name
@rtype: string
@return: the absolute page name

Definition at line 771 of file wikiutil.py.

00771 
00772 def AbsPageName(context, pagename):
00773     """
00774     Return the absolute pagename for a (possibly) relative pagename.
00775 
00776     @param context: name of the page where "pagename" appears on
00777     @param pagename: the (possibly relative) page name
00778     @rtype: string
00779     @return: the absolute page name
00780     """
00781     if pagename.startswith(PARENT_PREFIX):
00782         while context and pagename.startswith(PARENT_PREFIX):
00783             context = '/'.join(context.split('/')[:-1])
00784             pagename = pagename[PARENT_PREFIX_LEN:]
00785         pagename = '/'.join(filter(None, [context, pagename, ]))
00786     elif pagename.startswith(CHILD_PREFIX):
00787         if context:
00788             pagename = context + '/' + pagename[CHILD_PREFIX_LEN:]
00789         else:
00790             pagename = pagename[CHILD_PREFIX_LEN:]
00791     return pagename

Generate an anchor name from the given text.
This function generates valid HTML IDs matching: [A-Za-z][A-Za-z0-9:_.-]*
Note: this transformation has a special feature: when you feed it with a
      valid ID/name, it will return it without modification (identity
      transformation).

Definition at line 2404 of file wikiutil.py.

02404 
02405 def anchor_name_from_text(text):
02406     '''
02407     Generate an anchor name from the given text.
02408     This function generates valid HTML IDs matching: [A-Za-z][A-Za-z0-9:_.-]*
02409     Note: this transformation has a special feature: when you feed it with a
02410           valid ID/name, it will return it without modification (identity
02411           transformation).
02412     '''
02413     quoted = urllib.quote_plus(text.encode('utf-7'), safe=':')
02414     res = quoted.replace('%', '.').replace('+', '_')
02415     if not res[:1].isalpha():
02416         return 'A%s' % res
02417     return res

Gets a list of modules in MoinMoin.'kind'

@param kind: what kind of modules we look for
@rtype: list
@return: module names

Definition at line 1094 of file wikiutil.py.

01094 
01095 def builtinPlugins(kind):
01096     """ Gets a list of modules in MoinMoin.'kind'
01097 
01098     @param kind: what kind of modules we look for
01099     @rtype: list
01100     @return: module names
01101     """
01102     modulename = "MoinMoin." + kind
01103     return pysupport.importName(modulename, "modules")
01104 

Here is the caller graph for this function:

def MoinMoin.wikiutil.checkTicket (   request,
  ticket 
)
Check validity of a previously created ticket

Definition at line 2483 of file wikiutil.py.

02483 
02484 def checkTicket(request, ticket):
02485     """Check validity of a previously created ticket"""
02486     try:
02487         timestamp_str = ticket.split('.')[0]
02488         timestamp = int(timestamp_str, 16)
02489     except ValueError:
02490         # invalid or empty ticket
02491         logging.debug("checkTicket: invalid or empty ticket %r" % ticket)
02492         return False
02493     now = time.time()
02494     if timestamp < now - 10 * 3600:
02495         # we don't accept tickets older than 10h
02496         logging.debug("checkTicket: too old ticket, timestamp %r" % timestamp)
02497         return False
02498     ourticket = createTicket(request, timestamp_str)
02499     logging.debug("checkTicket: returning %r, got %r, expected %r" % (ticket == ourticket, ticket, ourticket))
02500     return ticket == ourticket
02501 

Here is the call graph for this function:

def MoinMoin.wikiutil.clean_input (   text,
  max_len = 201 
)
Clean input:
    replace CR, LF, TAB by whitespace
    delete control chars

    @param text: unicode text to clean
    @rtype: unicode
    @return: cleaned text

Definition at line 182 of file wikiutil.py.

00182 
00183 def clean_input(text, max_len=201):
00184     """ Clean input:
00185         replace CR, LF, TAB by whitespace
00186         delete control chars
00187 
00188         @param text: unicode text to clean
00189         @rtype: unicode
00190         @return: cleaned text
00191     """
00192     # we only have input fields with max 200 chars, but spammers send us more
00193     length = len(text)
00194     if length == 0 or length > max_len:
00195         return u''
00196     else:
00197         return text.translate(config.clean_input_translation_map)
00198 

Returns true if there is a conflict marker in the text. 

Definition at line 2380 of file wikiutil.py.

02380 
02381 def containsConflictMarker(text):
02382     """ Returns true if there is a conflict marker in the text. """
02383     return "/!\\ '''Edit conflict" in text

def MoinMoin.wikiutil.createTicket (   request,
  tm = None,
  action = None 
)

Tickets - used by RenamePage and DeletePage.

Create a ticket using a configured secret

    @param tm: unix timestamp (optional, uses current time if not given)
    @param action: action name (optional, uses current action if not given)
                   Note: if you create a ticket for a form that calls another
                         action than the current one, you MUST specify the
                         action you call when posting the form.

Definition at line 2448 of file wikiutil.py.

02448 
02449 def createTicket(request, tm=None, action=None):
02450     """ Create a ticket using a configured secret
02451 
02452         @param tm: unix timestamp (optional, uses current time if not given)
02453         @param action: action name (optional, uses current action if not given)
02454                        Note: if you create a ticket for a form that calls another
02455                              action than the current one, you MUST specify the
02456                              action you call when posting the form.
02457     """
02458 
02459     from MoinMoin.support.python_compatibility import hash_new
02460     if tm is None:
02461         tm = "%010x" % time.time()
02462 
02463     # make the ticket specific to the page and action:
02464     try:
02465         pagename = quoteWikinameURL(request.page.page_name)
02466     except:
02467         pagename = 'None'
02468 
02469     if action is None:
02470         try:
02471             action = request.action
02472         except:
02473             action = 'None'
02474 
02475     secret = request.cfg.secrets['wikiutil/tickets']
02476     digest = hash_new('sha1', secret)
02477 
02478     ticket = "%s.%s.%s" % (tm, pagename, action)
02479     digest.update(ticket)
02480 
02481     return "%s.%s" % (ticket, digest.hexdigest())
02482 

Here is the call graph for this function:

Here is the caller graph for this function:

Getting data from user/Sending data to user.

Decode unknown input, like text attachments

First we try utf-8 because it has special format, and it will decode
only utf-8 files. Then we try config.charset, then iso-8859-1 using
'replace'. We will never raise an exception, but may return junk
data.

WARNING: Use this function only for data that you view, not for data
that you save in the wiki.

@param text: the text to decode, string
@rtype: unicode
@return: decoded text (maybe wrong)

Definition at line 46 of file wikiutil.py.

00046 
00047 def decodeUnknownInput(text):
00048     """ Decode unknown input, like text attachments
00049 
00050     First we try utf-8 because it has special format, and it will decode
00051     only utf-8 files. Then we try config.charset, then iso-8859-1 using
00052     'replace'. We will never raise an exception, but may return junk
00053     data.
00054 
00055     WARNING: Use this function only for data that you view, not for data
00056     that you save in the wiki.
00057 
00058     @param text: the text to decode, string
00059     @rtype: unicode
00060     @return: decoded text (maybe wrong)
00061     """
00062     # Shortcut for unicode input
00063     if isinstance(text, unicode):
00064         return text
00065 
00066     try:
00067         return unicode(text, 'utf-8')
00068     except UnicodeError:
00069         if config.charset not in ['utf-8', 'iso-8859-1']:
00070             try:
00071                 return unicode(text, config.charset)
00072             except UnicodeError:
00073                 pass
00074         return unicode(text, 'iso-8859-1', 'replace')
00075 

def MoinMoin.wikiutil.decodeUserInput (   s,
  charsets = [config.charset] 
)
Decodes input from the user.

@param s: the string to unquote
@param charsets: list of charsets to assume the string is in
@rtype: unicode
@return: the unquoted string as unicode

Definition at line 76 of file wikiutil.py.

00076 
00077 def decodeUserInput(s, charsets=[config.charset]):
00078     """
00079     Decodes input from the user.
00080 
00081     @param s: the string to unquote
00082     @param charsets: list of charsets to assume the string is in
00083     @rtype: unicode
00084     @return: the unquoted string as unicode
00085     """
00086     for charset in charsets:
00087         try:
00088             return s.decode(charset)
00089         except UnicodeError:
00090             pass
00091     raise UnicodeError('The string %r cannot be decoded.' % s)
00092 

Here is the caller graph for this function:

Definition at line 2239 of file wikiutil.py.

02239 
02240 def drawing2fname(drawing):
02241     config.drawing_extensions = ['.tdraw', '.adraw',
02242                                  '.svg',
02243                                  '.png', '.jpg', '.jpeg', '.gif',
02244                                 ]
02245     fname, ext = os.path.splitext(drawing)
02246     # note: do not just check for empty extension or stuff like drawing:foo.bar
02247     # will fail, instead of being expanded to foo.bar.tdraw
02248     if ext not in config.drawing_extensions:
02249         # for backwards compatibility, twikidraw is the default:
02250         drawing += '.tdraw'
02251     return drawing
02252 

def MoinMoin.wikiutil.filterCategoryPages (   request,
  pagelist 
)
Return category pages in pagelist

WARNING: DO NOT USE THIS TO FILTER THE FULL PAGE LIST! Use
getPageList with a filter function.

If you pass a list with a single pagename, either that is returned
or an empty list, thus you can use this function like a `isCategoryPage`
one.

@param pagelist: a list of pages
@rtype: list
@return: only the category pages of pagelist

Definition at line 649 of file wikiutil.py.

00649 
00650 def filterCategoryPages(request, pagelist):
00651     """ Return category pages in pagelist
00652 
00653     WARNING: DO NOT USE THIS TO FILTER THE FULL PAGE LIST! Use
00654     getPageList with a filter function.
00655 
00656     If you pass a list with a single pagename, either that is returned
00657     or an empty list, thus you can use this function like a `isCategoryPage`
00658     one.
00659 
00660     @param pagelist: a list of pages
00661     @rtype: list
00662     @return: only the category pages of pagelist
00663     """
00664     func = request.cfg.cache.page_category_regexact.search
00665     return [pn for pn in pagelist if func(pn)]
00666 

generates a list of all files. for internal use. 

Definition at line 432 of file wikiutil.py.

00432 
00433 def generate_file_list(request):
00434     """ generates a list of all files. for internal use. """
00435 
00436     # order is important here, the local intermap file takes
00437     # precedence over the shared one, and is thus read AFTER
00438     # the shared one
00439     intermap_files = request.cfg.shared_intermap
00440     if not isinstance(intermap_files, list):
00441         intermap_files = [intermap_files]
00442     else:
00443         intermap_files = intermap_files[:]
00444     intermap_files.append(os.path.join(request.cfg.data_dir, "intermap.txt"))
00445     request.cfg.shared_intermap_files = [filename for filename in intermap_files
00446                                          if filename and os.path.isfile(filename)]
00447 

Here is the caller graph for this function:

def MoinMoin.wikiutil.get_bool (   request,
  arg,
  name = None,
  default = None 
)
For use with values returned from parse_quoted_separated or given
as macro parameters, return a boolean from a unicode string.
Valid input is 'true'/'false', 'yes'/'no' and '1'/'0' or None for
the default value.

@param request: A request instance
@param arg: The argument, may be None or a unicode string
@param name: Name of the argument, for error messages
@param default: default value if arg is None
@rtype: boolean or None
@returns: the boolean value of the string according to above rules
          (or default value)

Definition at line 1481 of file wikiutil.py.

01481 
01482 def get_bool(request, arg, name=None, default=None):
01483     """
01484     For use with values returned from parse_quoted_separated or given
01485     as macro parameters, return a boolean from a unicode string.
01486     Valid input is 'true'/'false', 'yes'/'no' and '1'/'0' or None for
01487     the default value.
01488 
01489     @param request: A request instance
01490     @param arg: The argument, may be None or a unicode string
01491     @param name: Name of the argument, for error messages
01492     @param default: default value if arg is None
01493     @rtype: boolean or None
01494     @returns: the boolean value of the string according to above rules
01495               (or default value)
01496     """
01497     _ = request.getText
01498     assert default is None or isinstance(default, bool)
01499     if arg is None:
01500         return default
01501     elif not isinstance(arg, unicode):
01502         raise TypeError('Argument must be None or unicode')
01503     arg = arg.lower()
01504     if arg in [u'0', u'false', u'no']:
01505         return False
01506     elif arg in [u'1', u'true', u'yes']:
01507         return True
01508     else:
01509         if name:
01510             raise ValueError(
01511                 _('Argument "%s" must be a boolean value, not "%s"') % (
01512                     name, arg))
01513         else:
01514             raise ValueError(
01515                 _('Argument must be a boolean value, not "%s"') % arg)
01516 

Here is the caller graph for this function:

def MoinMoin.wikiutil.get_choice (   request,
  arg,
  name = None,
  choices = [None] 
)
For use with values returned from parse_quoted_separated or given
as macro parameters, return a unicode string that must be in the
choices given. None is a valid input and yields first of the valid
choices.

@param request: A request instance
@param arg: The argument, may be None or a unicode string
@param name: Name of the argument, for error messages
@param choices: the possible choices
@rtype: unicode or None
@returns: the unicode string (or default value)

Definition at line 1635 of file wikiutil.py.

01635 
01636 def get_choice(request, arg, name=None, choices=[None]):
01637     """
01638     For use with values returned from parse_quoted_separated or given
01639     as macro parameters, return a unicode string that must be in the
01640     choices given. None is a valid input and yields first of the valid
01641     choices.
01642 
01643     @param request: A request instance
01644     @param arg: The argument, may be None or a unicode string
01645     @param name: Name of the argument, for error messages
01646     @param choices: the possible choices
01647     @rtype: unicode or None
01648     @returns: the unicode string (or default value)
01649     """
01650     assert isinstance(choices, (tuple, list))
01651     if arg is None:
01652         return choices[0]
01653     elif not isinstance(arg, unicode):
01654         raise TypeError('Argument must be None or unicode')
01655     elif not arg in choices:
01656         _ = request.getText
01657         if name:
01658             raise ValueError(
01659                 _('Argument "%s" must be one of "%s", not "%s"') % (
01660                     name, '", "'.join(choices), arg))
01661         else:
01662             raise ValueError(
01663                 _('Argument must be one of "%s", not "%s"') % (
01664                     '", "'.join(choices), arg))
01665 
01666     return arg
01667 

Here is the caller graph for this function:

def MoinMoin.wikiutil.get_complex (   request,
  arg,
  name = None,
  default = None 
)
For use with values returned from parse_quoted_separated or given
as macro parameters, return a complex from a unicode string.
None is a valid input and yields the default value.

@param request: A request instance
@param arg: The argument, may be None or a unicode string
@param name: Name of the argument, for error messages
@param default: default return value if arg is None
@rtype: complex or None
@returns: the complex value of the string (or default value)

Definition at line 1580 of file wikiutil.py.

01580 
01581 def get_complex(request, arg, name=None, default=None):
01582     """
01583     For use with values returned from parse_quoted_separated or given
01584     as macro parameters, return a complex from a unicode string.
01585     None is a valid input and yields the default value.
01586 
01587     @param request: A request instance
01588     @param arg: The argument, may be None or a unicode string
01589     @param name: Name of the argument, for error messages
01590     @param default: default return value if arg is None
01591     @rtype: complex or None
01592     @returns: the complex value of the string (or default value)
01593     """
01594     _ = request.getText
01595     assert default is None or isinstance(default, (int, long, float, complex))
01596     if arg is None:
01597         return default
01598     elif not isinstance(arg, unicode):
01599         raise TypeError('Argument must be None or unicode')
01600     try:
01601         # allow writing 'i' instead of 'j'
01602         arg = arg.replace('i', 'j').replace('I', 'j')
01603         return complex(arg)
01604     except ValueError:
01605         if name:
01606             raise ValueError(
01607                 _('Argument "%s" must be a complex value, not "%s"') % (
01608                     name, arg))
01609         else:
01610             raise ValueError(
01611                 _('Argument must be a complex value, not "%s"') % arg)
01612 

Here is the caller graph for this function:

def MoinMoin.wikiutil.get_float (   request,
  arg,
  name = None,
  default = None 
)
For use with values returned from parse_quoted_separated or given
as macro parameters, return a float from a unicode string.
None is a valid input and yields the default value.

@param request: A request instance
@param arg: The argument, may be None or a unicode string
@param name: Name of the argument, for error messages
@param default: default return value if arg is None
@rtype: float or None
@returns: the float value of the string (or default value)

Definition at line 1549 of file wikiutil.py.

01549 
01550 def get_float(request, arg, name=None, default=None):
01551     """
01552     For use with values returned from parse_quoted_separated or given
01553     as macro parameters, return a float from a unicode string.
01554     None is a valid input and yields the default value.
01555 
01556     @param request: A request instance
01557     @param arg: The argument, may be None or a unicode string
01558     @param name: Name of the argument, for error messages
01559     @param default: default return value if arg is None
01560     @rtype: float or None
01561     @returns: the float value of the string (or default value)
01562     """
01563     _ = request.getText
01564     assert default is None or isinstance(default, (int, long, float))
01565     if arg is None:
01566         return default
01567     elif not isinstance(arg, unicode):
01568         raise TypeError('Argument must be None or unicode')
01569     try:
01570         return float(arg)
01571     except ValueError:
01572         if name:
01573             raise ValueError(
01574                 _('Argument "%s" must be a floating point value, not "%s"') % (
01575                     name, arg))
01576         else:
01577             raise ValueError(
01578                 _('Argument must be a floating point value, not "%s"') % arg)
01579 

Here is the caller graph for this function:

def MoinMoin.wikiutil.get_int (   request,
  arg,
  name = None,
  default = None 
)
For use with values returned from parse_quoted_separated or given
as macro parameters, return an integer from a unicode string
containing the decimal representation of a number.
None is a valid input and yields the default value.

@param request: A request instance
@param arg: The argument, may be None or a unicode string
@param name: Name of the argument, for error messages
@param default: default value if arg is None
@rtype: int or None
@returns: the integer value of the string (or default value)

Definition at line 1517 of file wikiutil.py.

01517 
01518 def get_int(request, arg, name=None, default=None):
01519     """
01520     For use with values returned from parse_quoted_separated or given
01521     as macro parameters, return an integer from a unicode string
01522     containing the decimal representation of a number.
01523     None is a valid input and yields the default value.
01524 
01525     @param request: A request instance
01526     @param arg: The argument, may be None or a unicode string
01527     @param name: Name of the argument, for error messages
01528     @param default: default value if arg is None
01529     @rtype: int or None
01530     @returns: the integer value of the string (or default value)
01531     """
01532     _ = request.getText
01533     assert default is None or isinstance(default, (int, long))
01534     if arg is None:
01535         return default
01536     elif not isinstance(arg, unicode):
01537         raise TypeError('Argument must be None or unicode')
01538     try:
01539         return int(arg)
01540     except ValueError:
01541         if name:
01542             raise ValueError(
01543                 _('Argument "%s" must be an integer value, not "%s"') % (
01544                     name, arg))
01545         else:
01546             raise ValueError(
01547                 _('Argument must be an integer value, not "%s"') % arg)
01548 

Here is the caller graph for this function:

def MoinMoin.wikiutil.get_max_mtime (   file_list,
  page 
)
Returns the highest modification time of the files in file_list and the
page page. 

Definition at line 448 of file wikiutil.py.

00448 
00449 def get_max_mtime(file_list, page):
00450     """ Returns the highest modification time of the files in file_list and the
00451     page page. """
00452     timestamps = [os.stat(filename).st_mtime for filename in file_list]
00453     if page.exists():
00454         # exists() is cached and thus cheaper than mtime_usecs()
00455         timestamps.append(version2timestamp(page.mtime_usecs()))
00456     if timestamps:
00457         return max(timestamps)
00458     else:
00459         return 0 # no files / pages there

Here is the call graph for this function:

Here is the caller graph for this function:

Extract the processing instructions / acl / etc. at the beginning of a page's body.

    Hint: if you have a Page object p, you already have the result of this function in
          p.meta and (even better) parsed/processed stuff in p.pi.

    Returns a list of (pi, restofline) tuples and a string with the rest of the body.

Definition at line 2514 of file wikiutil.py.

02514 
02515 def get_processing_instructions(body):
02516     """ Extract the processing instructions / acl / etc. at the beginning of a page's body.
02517 
02518         Hint: if you have a Page object p, you already have the result of this function in
02519               p.meta and (even better) parsed/processed stuff in p.pi.
02520 
02521         Returns a list of (pi, restofline) tuples and a string with the rest of the body.
02522     """
02523     pi = []
02524     while body.startswith('#'):
02525         try:
02526             line, body = body.split('\n', 1) # extract first line
02527         except ValueError:
02528             line = body
02529             body = ''
02530 
02531         # end parsing on empty (invalid) PI
02532         if line == "#":
02533             body = line + '\n' + body
02534             break
02535 
02536         if line[1] == '#':# two hash marks are a comment
02537             comment = line[2:]
02538             if not comment.startswith(' '):
02539                 # we don't require a blank after the ##, so we put one there
02540                 comment = ' ' + comment
02541                 line = '##%s' % comment
02542 
02543         verb, args = (line[1:] + ' ').split(' ', 1) # split at the first blank
02544         pi.append((verb.lower(), args.strip()))
02545 
02546     return pi, body
02547 

def MoinMoin.wikiutil.get_unicode (   request,
  arg,
  name = None,
  default = None 
)
For use with values returned from parse_quoted_separated or given
as macro parameters, return a unicode string from a unicode string.
None is a valid input and yields the default value.

@param request: A request instance
@param arg: The argument, may be None or a unicode string
@param name: Name of the argument, for error messages
@param default: default return value if arg is None;
@rtype: unicode or None
@returns: the unicode string (or default value)

Definition at line 1613 of file wikiutil.py.

01613 
01614 def get_unicode(request, arg, name=None, default=None):
01615     """
01616     For use with values returned from parse_quoted_separated or given
01617     as macro parameters, return a unicode string from a unicode string.
01618     None is a valid input and yields the default value.
01619 
01620     @param request: A request instance
01621     @param arg: The argument, may be None or a unicode string
01622     @param name: Name of the argument, for error messages
01623     @param default: default return value if arg is None;
01624     @rtype: unicode or None
01625     @returns: the unicode string (or default value)
01626     """
01627     assert default is None or isinstance(default, unicode)
01628     if arg is None:
01629         return default
01630     elif not isinstance(arg, unicode):
01631         raise TypeError('Argument must be None or unicode')
01632 
01633     return arg
01634 

Here is the caller graph for this function:

def MoinMoin.wikiutil.getFrontPage (   request)
Convenience function to get localized front page

@param request: current request
@rtype: Page object
@return localized page_front_page, if there is a translation

Definition at line 706 of file wikiutil.py.

00706 
00707 def getFrontPage(request):
00708     """ Convenience function to get localized front page
00709 
00710     @param request: current request
00711     @rtype: Page object
00712     @return localized page_front_page, if there is a translation
00713     """
00714     return getLocalizedPage(request, request.cfg.page_front_page)
00715 

Here is the call graph for this function:

def MoinMoin.wikiutil.getHomePage (   request,
  username = None 
)
Get a user's homepage, or return None for anon users and
those who have not created a homepage.

DEPRECATED - try to use getInterwikiHomePage (see below)

@param request: the request object
@param username: the user's name
@rtype: Page
@return: user's homepage object - or None

Definition at line 716 of file wikiutil.py.

00716 
00717 def getHomePage(request, username=None):
00718     """
00719     Get a user's homepage, or return None for anon users and
00720     those who have not created a homepage.
00721 
00722     DEPRECATED - try to use getInterwikiHomePage (see below)
00723 
00724     @param request: the request object
00725     @param username: the user's name
00726     @rtype: Page
00727     @return: user's homepage object - or None
00728     """
00729     from MoinMoin.Page import Page
00730     # default to current user
00731     if username is None and request.user.valid:
00732         username = request.user.name
00733 
00734     # known user?
00735     if username:
00736         # Return home page
00737         page = Page(request, username)
00738         if page.exists():
00739             return page
00740 
00741     return None
00742 

def MoinMoin.wikiutil.getInterwikiHomePage (   request,
  username = None 
)
Get a user's homepage.

cfg.user_homewiki influences behaviour of this:
'Self' does mean we store user homepage in THIS wiki.
When set to our own interwikiname, it behaves like with 'Self'.

'SomeOtherWiki' means we store user homepages in another wiki.

@param request: the request object
@param username: the user's name
@rtype: tuple (or None for anon users)
@return: (wikiname, pagename)

Definition at line 743 of file wikiutil.py.

00743 
00744 def getInterwikiHomePage(request, username=None):
00745     """
00746     Get a user's homepage.
00747 
00748     cfg.user_homewiki influences behaviour of this:
00749     'Self' does mean we store user homepage in THIS wiki.
00750     When set to our own interwikiname, it behaves like with 'Self'.
00751 
00752     'SomeOtherWiki' means we store user homepages in another wiki.
00753 
00754     @param request: the request object
00755     @param username: the user's name
00756     @rtype: tuple (or None for anon users)
00757     @return: (wikiname, pagename)
00758     """
00759     # default to current user
00760     if username is None and request.user.valid:
00761         username = request.user.name
00762     if not username:
00763         return None # anon user
00764 
00765     homewiki = request.cfg.user_homewiki
00766     if homewiki == request.cfg.interwikiname:
00767         homewiki = u'Self'
00768 
00769     return homewiki, username
00770 

def MoinMoin.wikiutil.getLocalizedPage (   request,
  pagename 
)
Get a system page according to user settings and available translations.

We include some special treatment for the case that <pagename> is the
currently rendered page, as this is the case for some pages used very
often, like FrontPage, RecentChanges etc. - in that case we reuse the
already existing page object instead creating a new one.

@param request: the request object
@param pagename: the name of the page
@rtype: Page object
@return: the page object of that system page, using a translated page,
         if it exists

Definition at line 667 of file wikiutil.py.

00667 
00668 def getLocalizedPage(request, pagename): # was: getSysPage
00669     """ Get a system page according to user settings and available translations.
00670 
00671     We include some special treatment for the case that <pagename> is the
00672     currently rendered page, as this is the case for some pages used very
00673     often, like FrontPage, RecentChanges etc. - in that case we reuse the
00674     already existing page object instead creating a new one.
00675 
00676     @param request: the request object
00677     @param pagename: the name of the page
00678     @rtype: Page object
00679     @return: the page object of that system page, using a translated page,
00680              if it exists
00681     """
00682     from MoinMoin.Page import Page
00683     i18n_name = request.getText(pagename)
00684     pageobj = None
00685     if i18n_name != pagename:
00686         if request.page and i18n_name == request.page.page_name:
00687             # do not create new object for current page
00688             i18n_page = request.page
00689             if i18n_page.exists():
00690                 pageobj = i18n_page
00691         else:
00692             i18n_page = Page(request, i18n_name)
00693             if i18n_page.exists():
00694                 pageobj = i18n_page
00695 
00696     # if we failed getting a translated version of <pagename>,
00697     # we fall back to english
00698     if not pageobj:
00699         if request.page and pagename == request.page.page_name:
00700             # do not create new object for current page
00701             pageobj = request.page
00702         else:
00703             pageobj = Page(request, pagename)
00704     return pageobj
00705 

Here is the caller graph for this function:

def MoinMoin.wikiutil.getParserForExtension (   cfg,
  extension 
)

Parsers.

Returns the Parser class of the parser fit to handle a file
with the given extension. The extension should be in the same
format as os.path.splitext returns it (i.e. with the dot).
Returns None if no parser willing to handle is found.
The dict of extensions is cached in the config object.

@param cfg: the Config instance for the wiki in question
@param extension: the filename extension including the dot
@rtype: class, None
@returns: the parser class or None

Definition at line 1176 of file wikiutil.py.

01176 
01177 def getParserForExtension(cfg, extension):
01178     """
01179     Returns the Parser class of the parser fit to handle a file
01180     with the given extension. The extension should be in the same
01181     format as os.path.splitext returns it (i.e. with the dot).
01182     Returns None if no parser willing to handle is found.
01183     The dict of extensions is cached in the config object.
01184 
01185     @param cfg: the Config instance for the wiki in question
01186     @param extension: the filename extension including the dot
01187     @rtype: class, None
01188     @returns: the parser class or None
01189     """
01190     if not hasattr(cfg.cache, 'EXT_TO_PARSER'):
01191         etp, etd = {}, None
01192         for pname in getPlugins('parser', cfg):
01193             try:
01194                 Parser = importPlugin(cfg, 'parser', pname, 'Parser')
01195             except PluginMissingError:
01196                 continue
01197             if hasattr(Parser, 'extensions'):
01198                 exts = Parser.extensions
01199                 if isinstance(exts, list):
01200                     for ext in Parser.extensions:
01201                         etp[ext] = Parser
01202                 elif str(exts) == '*':
01203                     etd = Parser
01204         cfg.cache.EXT_TO_PARSER = etp
01205         cfg.cache.EXT_TO_PARSER_DEFAULT = etd
01206 
01207     return cfg.cache.EXT_TO_PARSER.get(extension, cfg.cache.EXT_TO_PARSER_DEFAULT)
01208 

Here is the call graph for this function:

def MoinMoin.wikiutil.getPlugins (   kind,
  cfg 
)
Gets a list of plugin names of kind

@param kind: what kind of modules we look for
@rtype: list
@return: module names

Definition at line 1135 of file wikiutil.py.

01135 
01136 def getPlugins(kind, cfg):
01137     """ Gets a list of plugin names of kind
01138 
01139     @param kind: what kind of modules we look for
01140     @rtype: list
01141     @return: module names
01142     """
01143     # Copy names from builtin plugins - so we dont destroy the value
01144     all_plugins = builtinPlugins(kind)[:]
01145 
01146     # Add extension plugins without duplicates
01147     for plugin in wikiPlugins(kind, cfg):
01148         if plugin not in all_plugins:
01149             all_plugins.append(plugin)
01150 
01151     return all_plugins
01152 

Here is the call graph for this function:

Here is the caller graph for this function:

Return a group letter for `name`, which must be a unicode string.
Currently supported: Hangul Syllables (U+AC00 - U+D7AF)

@param name: a string
@rtype: string
@return: group letter or None

Definition at line 2273 of file wikiutil.py.

02273 
02274 def getUnicodeIndexGroup(name):
02275     """
02276     Return a group letter for `name`, which must be a unicode string.
02277     Currently supported: Hangul Syllables (U+AC00 - U+D7AF)
02278 
02279     @param name: a string
02280     @rtype: string
02281     @return: group letter or None
02282     """
02283     c = name[0]
02284     if u'\uAC00' <= c <= u'\uD7AF': # Hangul Syllables
02285         return unichr(0xac00 + (int(ord(c) - 0xac00) / 588) * 588)
02286     else:
02287         return c.upper() # we put lower and upper case words into the same index group
02288 

def MoinMoin.wikiutil.importBuiltinPlugin (   kind,
  name,
  function = "execute" 
)
Import builtin plugin from MoinMoin package

See importPlugin docstring.

Definition at line 1058 of file wikiutil.py.

01058 
01059 def importBuiltinPlugin(kind, name, function="execute"):
01060     """ Import builtin plugin from MoinMoin package
01061 
01062     See importPlugin docstring.
01063     """
01064     if not name in builtinPlugins(kind):
01065         raise PluginMissingError()
01066     moduleName = 'MoinMoin.%s.%s' % (kind, name)
01067     return importNameFromPlugin(moduleName, function)
01068 

Here is the call graph for this function:

def MoinMoin.wikiutil.importNameFromPlugin (   moduleName,
  name 
)
Return <name> attr from <moduleName> module,
    raise PluginAttributeError if name does not exist.

    If name is None, return the <moduleName> module object.

Definition at line 1069 of file wikiutil.py.

01069 
01070 def importNameFromPlugin(moduleName, name):
01071     """ Return <name> attr from <moduleName> module,
01072         raise PluginAttributeError if name does not exist.
01073 
01074         If name is None, return the <moduleName> module object.
01075     """
01076     if name is None:
01077         fromlist = []
01078     else:
01079         fromlist = [name]
01080     module = __import__(moduleName, globals(), {}, fromlist)
01081     if fromlist:
01082         # module has the obj for module <moduleName>
01083         try:
01084             return getattr(module, name)
01085         except AttributeError:
01086             raise PluginAttributeError
01087     else:
01088         # module now has the toplevel module of <moduleName> (see __import__ docs!)
01089         components = moduleName.split('.')
01090         for comp in components[1:]:
01091             module = getattr(module, comp)
01092         return module
01093 

Here is the caller graph for this function:

def MoinMoin.wikiutil.importPlugin (   cfg,
  kind,
  name,
  function = "execute" 
)
Import wiki or builtin plugin

Returns <function> attr from a plugin module <name>.
If <function> attr is missing, raise PluginAttributeError.
If <function> is None, return the whole module object.

If <name> plugin can not be imported, raise PluginMissingError.

kind may be one of 'action', 'formatter', 'macro', 'parser' or any other
directory that exist in MoinMoin or data/plugin.

Wiki plugins will always override builtin plugins. If you want
specific plugin, use either importWikiPlugin or importBuiltinPlugin
directly.

@param cfg: wiki config instance
@param kind: what kind of module we want to import
@param name: the name of the module
@param function: the function name
@rtype: any object
@return: "function" of module "name" of kind "kind", or None

Definition at line 1016 of file wikiutil.py.

01016 
01017 def importPlugin(cfg, kind, name, function="execute"):
01018     """ Import wiki or builtin plugin
01019 
01020     Returns <function> attr from a plugin module <name>.
01021     If <function> attr is missing, raise PluginAttributeError.
01022     If <function> is None, return the whole module object.
01023 
01024     If <name> plugin can not be imported, raise PluginMissingError.
01025 
01026     kind may be one of 'action', 'formatter', 'macro', 'parser' or any other
01027     directory that exist in MoinMoin or data/plugin.
01028 
01029     Wiki plugins will always override builtin plugins. If you want
01030     specific plugin, use either importWikiPlugin or importBuiltinPlugin
01031     directly.
01032 
01033     @param cfg: wiki config instance
01034     @param kind: what kind of module we want to import
01035     @param name: the name of the module
01036     @param function: the function name
01037     @rtype: any object
01038     @return: "function" of module "name" of kind "kind", or None
01039     """
01040     try:
01041         return importWikiPlugin(cfg, kind, name, function)
01042     except PluginMissingError:
01043         return importBuiltinPlugin(kind, name, function)
01044 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.wikiutil.importWikiPlugin (   cfg,
  kind,
  name,
  function = "execute" 
)
Import plugin from the wiki data directory

See importPlugin docstring.

Definition at line 1045 of file wikiutil.py.

01045 
01046 def importWikiPlugin(cfg, kind, name, function="execute"):
01047     """ Import plugin from the wiki data directory
01048 
01049     See importPlugin docstring.
01050     """
01051     plugins = wikiPlugins(kind, cfg)
01052     modname = plugins.get(name, None)
01053     if modname is None:
01054         raise PluginMissingError()
01055     moduleName = '%s.%s' % (modname, name)
01056     return importNameFromPlugin(moduleName, function)
01057 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.wikiutil.invoke_extension_function (   request,
  function,
  args,
  fixed_args = [] 
)
Parses arguments for an extension call and calls the extension
function with the arguments.

If the macro function has a default value that is a bool,
int, long, float or unicode object, then the given value
is converted to the type of that default value before passing
it to the macro function. That way, macros need not call the
wikiutil.get_* functions for any arguments that have a default.

@param request: the request object
@param function: the function to invoke
@param args: unicode string with arguments (or evaluating to False)
@param fixed_args: fixed arguments to pass as the first arguments
@returns: the return value from the function called

Definition at line 1755 of file wikiutil.py.

01755 
01756 def invoke_extension_function(request, function, args, fixed_args=[]):
01757     """
01758     Parses arguments for an extension call and calls the extension
01759     function with the arguments.
01760 
01761     If the macro function has a default value that is a bool,
01762     int, long, float or unicode object, then the given value
01763     is converted to the type of that default value before passing
01764     it to the macro function. That way, macros need not call the
01765     wikiutil.get_* functions for any arguments that have a default.
01766 
01767     @param request: the request object
01768     @param function: the function to invoke
01769     @param args: unicode string with arguments (or evaluating to False)
01770     @param fixed_args: fixed arguments to pass as the first arguments
01771     @returns: the return value from the function called
01772     """
01773 
01774     def _convert_arg(request, value, default, name=None):
01775         """
01776         Using the get_* functions, convert argument to the type of the default
01777         if that is any of bool, int, long, float or unicode; if the default
01778         is the type itself then convert to that type (keeps None) or if the
01779         default is a list require one of the list items.
01780 
01781         In other cases return the value itself.
01782         """
01783         # if extending this, extend required_arg as well!
01784         if isinstance(default, bool):
01785             return get_bool(request, value, name, default)
01786         elif isinstance(default, (int, long)):
01787             return get_int(request, value, name, default)
01788         elif isinstance(default, float):
01789             return get_float(request, value, name, default)
01790         elif isinstance(default, complex):
01791             return get_complex(request, value, name, default)
01792         elif isinstance(default, unicode):
01793             return get_unicode(request, value, name, default)
01794         elif isinstance(default, (tuple, list)):
01795             return get_choice(request, value, name, default)
01796         elif default is bool:
01797             return get_bool(request, value, name)
01798         elif default is int or default is long:
01799             return get_int(request, value, name)
01800         elif default is float:
01801             return get_float(request, value, name)
01802         elif default is complex:
01803             return get_complex(request, value, name)
01804         elif isinstance(default, IEFArgument):
01805             # defaults handled later
01806             if value is None:
01807                 return None
01808             return default.parse_argument(value)
01809         elif isinstance(default, required_arg):
01810             if isinstance(default.argtype, (tuple, list)):
01811                 # treat choice specially and return None if no choice
01812                 # is given in the value
01813                 choices = [None] + list(default.argtype)
01814                 return get_choice(request, value, name, choices)
01815             else:
01816                 return _convert_arg(request, value, default.argtype, name)
01817         return value
01818 
01819     assert isinstance(fixed_args, (list, tuple))
01820 
01821     _ = request.getText
01822 
01823     kwargs = {}
01824     kwargs_to_pass = {}
01825     trailing_args = []
01826 
01827     if args:
01828         assert isinstance(args, unicode)
01829 
01830         positional, keyword, trailing = parse_quoted_separated(args)
01831 
01832         for kw in keyword:
01833             try:
01834                 kwargs[str(kw)] = keyword[kw]
01835             except UnicodeEncodeError:
01836                 kwargs_to_pass[kw] = keyword[kw]
01837 
01838         trailing_args.extend(trailing)
01839 
01840     else:
01841         positional = []
01842 
01843     if isfunction(function) or ismethod(function):
01844         argnames, varargs, varkw, defaultlist = getargspec(function)
01845     elif isclass(function):
01846         (argnames, varargs,
01847          varkw, defaultlist) = getargspec(function.__init__.im_func)
01848     else:
01849         raise TypeError('function must be a function, method or class')
01850 
01851     # self is implicit!
01852     if ismethod(function) or isclass(function):
01853         argnames = argnames[1:]
01854 
01855     fixed_argc = len(fixed_args)
01856     argnames = argnames[fixed_argc:]
01857     argc = len(argnames)
01858     if not defaultlist:
01859         defaultlist = []
01860 
01861     # if the fixed parameters have defaults too...
01862     if argc < len(defaultlist):
01863         defaultlist = defaultlist[fixed_argc:]
01864     defstart = argc - len(defaultlist)
01865 
01866     defaults = {}
01867     # reverse to be able to pop() things off
01868     positional.reverse()
01869     allow_kwargs = False
01870     allow_trailing = False
01871     # convert all arguments to keyword arguments,
01872     # fill all arguments that weren't given with None
01873     for idx in range(argc):
01874         argname = argnames[idx]
01875         if argname == '_kwargs':
01876             allow_kwargs = True
01877             continue
01878         if argname == '_trailing_args':
01879             allow_trailing = True
01880             continue
01881         if positional:
01882             kwargs[argname] = positional.pop()
01883         if not argname in kwargs:
01884             kwargs[argname] = None
01885         if idx >= defstart:
01886             defaults[argname] = defaultlist[idx - defstart]
01887 
01888     if positional:
01889         if not allow_trailing:
01890             raise ValueError(_('Too many arguments'))
01891         trailing_args.extend(positional)
01892 
01893     if trailing_args:
01894         if not allow_trailing:
01895             raise ValueError(_('Cannot have arguments without name following'
01896                                ' named arguments'))
01897         kwargs['_trailing_args'] = trailing_args
01898 
01899     # type-convert all keyword arguments to the type
01900     # that the default value indicates
01901     for argname in kwargs.keys()[:]:
01902         if argname in defaults:
01903             # the value of 'argname' from kwargs will be put into the
01904             # macro's 'argname' argument, so convert that giving the
01905             # name to the converter so the user is told which argument
01906             # went wrong (if it does)
01907             kwargs[argname] = _convert_arg(request, kwargs[argname],
01908                                            defaults[argname], argname)
01909             if kwargs[argname] is None:
01910                 if isinstance(defaults[argname], required_arg):
01911                     raise ValueError(_('Argument "%s" is required') % argname)
01912                 if isinstance(defaults[argname], IEFArgument):
01913                     kwargs[argname] = defaults[argname].get_default()
01914 
01915         if not argname in argnames:
01916             # move argname into _kwargs parameter
01917             kwargs_to_pass[argname] = kwargs[argname]
01918             del kwargs[argname]
01919 
01920     if kwargs_to_pass:
01921         kwargs['_kwargs'] = kwargs_to_pass
01922         if not allow_kwargs:
01923             raise ValueError(_(u'No argument named "%s"') % (
01924                 kwargs_to_pass.keys()[0]))
01925 
01926     return function(*fixed_args, **kwargs)
01927 

Here is the call graph for this function:

def MoinMoin.wikiutil.is_URL (   arg,
  schemas = config.url_schemas 
)
Return True if arg is a URL (with a schema given in the schemas list).

    Note: there are not that many requirements for generic URLs, basically
    the only mandatory requirement is the ':' between schema and rest.
    Schema itself could be anything, also the rest (but we only support some
    schemas, as given in config.url_schemas, so it is a bit less ambiguous).

Definition at line 2300 of file wikiutil.py.

02300 
02301 def is_URL(arg, schemas=config.url_schemas):
02302     """ Return True if arg is a URL (with a schema given in the schemas list).
02303 
02304         Note: there are not that many requirements for generic URLs, basically
02305         the only mandatory requirement is the ':' between schema and rest.
02306         Schema itself could be anything, also the rest (but we only support some
02307         schemas, as given in config.url_schemas, so it is a bit less ambiguous).
02308     """
02309     if ':' not in arg:
02310         return False
02311     for schema in schemas:
02312         if arg.startswith(schema + ':'):
02313             return True
02314     return False
02315 

def MoinMoin.wikiutil.isGroupPage (   pagename,
  cfg 
)
Is this a name of group page?

@param pagename: the page name
@rtype: bool
@return: true if page is a form page

Definition at line 639 of file wikiutil.py.

00639 
00640 def isGroupPage(pagename, cfg):
00641     """ Is this a name of group page?
00642 
00643     @param pagename: the page name
00644     @rtype: bool
00645     @return: true if page is a form page
00646     """
00647     return cfg.cache.page_group_regexact.search(pagename) is not None
00648 

Here is the caller graph for this function:

Is this a picture's url?

@param url: the url in question
@rtype: bool
@return: true if url points to a picture

Definition at line 2316 of file wikiutil.py.

02316 
02317 def isPicture(url):
02318     """
02319     Is this a picture's url?
02320 
02321     @param url: the url in question
02322     @rtype: bool
02323     @return: true if url points to a picture
02324     """
02325     extpos = url.rfind(".") + 1
02326     return extpos > 1 and url[extpos:].lower() in config.browser_supported_images
02327 

def MoinMoin.wikiutil.isStrictWikiname (   name,
  word_re = re.compile(ur"^(?:[%(u)s][%(l)s]+){2,}$" % {'u': config.chars_upper,
  l 
)

Definition at line 2289 of file wikiutil.py.

02289 
02290 def isStrictWikiname(name, word_re=re.compile(ur"^(?:[%(u)s][%(l)s]+){2,}$" % {'u': config.chars_upper, 'l': config.chars_lower})):
02291     """
02292     Check whether this is NOT an extended name.
02293 
02294     @param name: the wikiname in question
02295     @rtype: bool
02296     @return: true if name matches the word_re
02297     """
02298     return word_re.match(name)
02299 

def MoinMoin.wikiutil.isSystemPage (   request,
  pagename 
)

Page types (based on page names)

Is this a system page?

@param request: the request object
@param pagename: the page name
@rtype: bool
@return: true if page is a system page

Definition at line 617 of file wikiutil.py.

00617 
00618 def isSystemPage(request, pagename):
00619     """ Is this a system page?
00620 
00621     @param request: the request object
00622     @param pagename: the page name
00623     @rtype: bool
00624     @return: true if page is a system page
00625     """
00626     from MoinMoin import i18n
00627     return pagename in i18n.system_pages or isTemplatePage(request, pagename)
00628 

Here is the call graph for this function:

def MoinMoin.wikiutil.isTemplatePage (   request,
  pagename 
)
Is this a template page?

@param pagename: the page name
@rtype: bool
@return: true if page is a template page

Definition at line 629 of file wikiutil.py.

00629 
00630 def isTemplatePage(request, pagename):
00631     """ Is this a template page?
00632 
00633     @param pagename: the page name
00634     @rtype: bool
00635     @return: true if page is a template page
00636     """
00637     return request.cfg.cache.page_template_regexact.search(pagename) is not None
00638 

Here is the caller graph for this function:

def MoinMoin.wikiutil.join_wiki (   wikiurl,
  wikitail 
)
Add a (url_quoted) page name to an interwiki url.

Note: We can't know what kind of URL quoting a remote wiki expects.
      We just use a utf-8 encoded string with standard URL quoting.

@param wikiurl: wiki url, maybe including a $PAGE placeholder
@param wikitail: page name
@rtype: string
@return: generated URL of the page in the other wiki

Definition at line 594 of file wikiutil.py.

00594 
00595 def join_wiki(wikiurl, wikitail):
00596     """
00597     Add a (url_quoted) page name to an interwiki url.
00598 
00599     Note: We can't know what kind of URL quoting a remote wiki expects.
00600           We just use a utf-8 encoded string with standard URL quoting.
00601 
00602     @param wikiurl: wiki url, maybe including a $PAGE placeholder
00603     @param wikitail: page name
00604     @rtype: string
00605     @return: generated URL of the page in the other wiki
00606     """
00607     wikitail = url_quote(wikitail)
00608     if '$PAGE' in wikiurl:
00609         return wikiurl.replace('$PAGE', wikitail)
00610     else:
00611         return wikiurl + wikitail
00612 

Here is the call graph for this function:

def MoinMoin.wikiutil.link_tag (   request,
  params,
  text = None,
  formatter = None,
  on = None,
  kw 
)
Create a link.

TODO: cleanup css_class

@param request: the request object
@param params: parameter string appended to the URL after the scriptname/
@param text: text / inner part of the <a>...</a> link - does NOT get
             escaped, so you can give HTML here and it will be used verbatim
@param formatter: the formatter object to use
@param on: opening/closing tag only
@keyword attrs: additional attrs (HTMLified string) (removed in 1.5.3)
@rtype: string
@return: formatted link tag

Definition at line 2328 of file wikiutil.py.

02328 
02329 def link_tag(request, params, text=None, formatter=None, on=None, **kw):
02330     """ Create a link.
02331 
02332     TODO: cleanup css_class
02333 
02334     @param request: the request object
02335     @param params: parameter string appended to the URL after the scriptname/
02336     @param text: text / inner part of the <a>...</a> link - does NOT get
02337                  escaped, so you can give HTML here and it will be used verbatim
02338     @param formatter: the formatter object to use
02339     @param on: opening/closing tag only
02340     @keyword attrs: additional attrs (HTMLified string) (removed in 1.5.3)
02341     @rtype: string
02342     @return: formatted link tag
02343     """
02344     if formatter is None:
02345         formatter = request.html_formatter
02346     if 'css_class' in kw:
02347         css_class = kw['css_class']
02348         del kw['css_class'] # one time is enough
02349     else:
02350         css_class = None
02351     id = kw.get('id', None)
02352     name = kw.get('name', None)
02353     if text is None:
02354         text = params # default
02355     if formatter:
02356         url = "%s/%s" % (request.script_root, params)
02357         # formatter.url will escape the url part
02358         if on is not None:
02359             tag = formatter.url(on, url, css_class, **kw)
02360         else:
02361             tag = (formatter.url(1, url, css_class, **kw) +
02362                 formatter.rawHTML(text) +
02363                 formatter.url(0))
02364     else: # this shouldn't be used any more:
02365         if on is not None and not on:
02366             tag = '</a>'
02367         else:
02368             attrs = ''
02369             if css_class:
02370                 attrs += ' class="%s"' % css_class
02371             if id:
02372                 attrs += ' id="%s"' % id
02373             if name:
02374                 attrs += ' name="%s"' % name
02375             tag = '<a%s href="%s/%s">' % (attrs, request.script_root, params)
02376             if not on:
02377                 tag = "%s%s</a>" % (tag, text)
02378         logging.warning("wikiutil.link_tag called without formatter and without request.html_formatter. tag=%r" % (tag, ))
02379     return tag

def MoinMoin.wikiutil.load_wikimap (   request)
load interwiki map (once, and only on demand) 

Definition at line 460 of file wikiutil.py.

00460 
00461 def load_wikimap(request):
00462     """ load interwiki map (once, and only on demand) """
00463     from MoinMoin.Page import Page
00464 
00465     now = int(time.time())
00466     if getattr(request.cfg, "shared_intermap_files", None) is None:
00467         generate_file_list(request)
00468 
00469     try:
00470         _interwiki_list = request.cfg.cache.interwiki_list
00471         old_mtime = request.cfg.cache.interwiki_mtime
00472         if request.cfg.cache.interwiki_ts + (1*60) < now: # 1 minutes caching time
00473             max_mtime = get_max_mtime(request.cfg.shared_intermap_files, Page(request, INTERWIKI_PAGE))
00474             if max_mtime > old_mtime:
00475                 raise AttributeError # refresh cache
00476             else:
00477                 request.cfg.cache.interwiki_ts = now
00478     except AttributeError:
00479         _interwiki_list = {}
00480         lines = []
00481 
00482         for filename in request.cfg.shared_intermap_files:
00483             f = codecs.open(filename, "r", config.charset)
00484             lines.extend(f.readlines())
00485             f.close()
00486 
00487         # add the contents of the InterWikiMap page
00488         lines += Page(request, INTERWIKI_PAGE).get_raw_body().splitlines()
00489 
00490         for line in lines:
00491             if not line or line[0] == '#':
00492                 continue
00493             try:
00494                 line = "%s %s/InterWiki" % (line, request.script_root)
00495                 wikitag, urlprefix, dummy = line.split(None, 2)
00496             except ValueError:
00497                 pass
00498             else:
00499                 _interwiki_list[wikitag] = urlprefix
00500 
00501         del lines
00502 
00503         # add own wiki as "Self" and by its configured name
00504         _interwiki_list['Self'] = request.script_root + '/'
00505         if request.cfg.interwikiname:
00506             _interwiki_list[request.cfg.interwikiname] = request.script_root + '/'
00507 
00508         # save for later
00509         request.cfg.cache.interwiki_list = _interwiki_list
00510         request.cfg.cache.interwiki_ts = now
00511         request.cfg.cache.interwiki_mtime = get_max_mtime(request.cfg.shared_intermap_files, Page(request, INTERWIKI_PAGE))
00512 
00513     return _interwiki_list

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.wikiutil.make_breakable (   text,
  maxlen 
)
make a text breakable by inserting spaces into nonbreakable parts

Definition at line 199 of file wikiutil.py.

00199 
00200 def make_breakable(text, maxlen):
00201     """ make a text breakable by inserting spaces into nonbreakable parts
00202     """
00203     text = text.split(" ")
00204     newtext = []
00205     for part in text:
00206         if len(part) > maxlen:
00207             while part:
00208                 newtext.append(part[:maxlen])
00209                 part = part[maxlen:]
00210         else:
00211             newtext.append(part)
00212     return " ".join(newtext)

def MoinMoin.wikiutil.makeQueryString (   qstr = None,
  want_unicode = None,
  kw 
)
Make a querystring from arguments.

kw arguments overide values in qstr.

If a string is passed in, it's returned verbatim and keyword parameters are ignored.

See also: werkzeug.url_encode

@param qstr: dict to format as query string, using either ascii or unicode
@param kw: same as dict when using keywords, using ascii or unicode
@rtype: string
@return: query string ready to use in a url

Definition at line 133 of file wikiutil.py.

00133 
00134 def makeQueryString(qstr=None, want_unicode=None, **kw):
00135     """ Make a querystring from arguments.
00136 
00137     kw arguments overide values in qstr.
00138 
00139     If a string is passed in, it's returned verbatim and keyword parameters are ignored.
00140 
00141     See also: werkzeug.url_encode
00142 
00143     @param qstr: dict to format as query string, using either ascii or unicode
00144     @param kw: same as dict when using keywords, using ascii or unicode
00145     @rtype: string
00146     @return: query string ready to use in a url
00147     """
00148     try:
00149         assert want_unicode is None
00150     except AssertionError:
00151         log.exception("call with deprecated want_unicode param, please fix caller")
00152     if qstr is None:
00153         qstr = {}
00154     elif isinstance(qstr, (str, unicode)):
00155         return qstr
00156     if isinstance(qstr, dict):
00157         qstr.update(kw)
00158         return werkzeug.url_encode(qstr, charset=config.charset, encode_keys=True)
00159     else:
00160         raise ValueError("Unsupported argument type, should be dict.")
00161 

def MoinMoin.wikiutil.mapURL (   request,
  url 
)
Map URLs according to 'cfg.url_mappings'.

@param url: a URL
@rtype: string
@return: mapped URL

Definition at line 2253 of file wikiutil.py.

02253 
02254 def mapURL(request, url):
02255     """
02256     Map URLs according to 'cfg.url_mappings'.
02257 
02258     @param url: a URL
02259     @rtype: string
02260     @return: mapped URL
02261     """
02262     # check whether we have to map URLs
02263     if request.cfg.url_mappings:
02264         # check URL for the configured prefixes
02265         for prefix in request.cfg.url_mappings:
02266             if url.startswith(prefix):
02267                 # substitute prefix with replacement value
02268                 return request.cfg.url_mappings[prefix] + url[len(prefix):]
02269 
02270     # return unchanged url
02271     return url
02272 

def MoinMoin.wikiutil.normalize_pagename (   name,
  cfg 
)
Normalize page name

Prevent creating page names with invisible characters or funny
whitespace that might confuse the users or abuse the wiki, or
just does not make sense.

Restrict even more group pages, so they can be used inside acl lines.

@param name: page name, unicode
@rtype: unicode
@return: decoded and sanitized page name

Definition at line 2183 of file wikiutil.py.

02183 
02184 def normalize_pagename(name, cfg):
02185     """ Normalize page name
02186 
02187     Prevent creating page names with invisible characters or funny
02188     whitespace that might confuse the users or abuse the wiki, or
02189     just does not make sense.
02190 
02191     Restrict even more group pages, so they can be used inside acl lines.
02192 
02193     @param name: page name, unicode
02194     @rtype: unicode
02195     @return: decoded and sanitized page name
02196     """
02197     # Strip invalid characters
02198     name = config.page_invalid_chars_regex.sub(u'', name)
02199 
02200     # Split to pages and normalize each one
02201     pages = name.split(u'/')
02202     normalized = []
02203     for page in pages:
02204         # Ignore empty or whitespace only pages
02205         if not page or page.isspace():
02206             continue
02207 
02208         # Cleanup group pages.
02209         # Strip non alpha numeric characters, keep white space
02210         if isGroupPage(page, cfg):
02211             page = u''.join([c for c in page
02212                              if c.isalnum() or c.isspace()])
02213 
02214         # Normalize white space. Each name can contain multiple
02215         # words separated with only one space. Split handle all
02216         # 30 unicode spaces (isspace() == True)
02217         page = u' '.join(page.split())
02218 
02219         normalized.append(page)
02220 
02221     # Assemble components into full pagename
02222     name = u'/'.join(normalized)
02223     return name

Here is the call graph for this function:

def MoinMoin.wikiutil.pagediff (   request,
  pagename1,
  rev1,
  pagename2,
  rev2,
  kw 
)
Calculate the "diff" between two page contents.

@param pagename1: name of first page
@param rev1: revision of first page
@param pagename2: name of second page
@param rev2: revision of second page
@keyword ignorews: if 1: ignore pure-whitespace changes.
@rtype: list
@return: lines of diff output

Definition at line 2384 of file wikiutil.py.

02384 
02385 def pagediff(request, pagename1, rev1, pagename2, rev2, **kw):
02386     """
02387     Calculate the "diff" between two page contents.
02388 
02389     @param pagename1: name of first page
02390     @param rev1: revision of first page
02391     @param pagename2: name of second page
02392     @param rev2: revision of second page
02393     @keyword ignorews: if 1: ignore pure-whitespace changes.
02394     @rtype: list
02395     @return: lines of diff output
02396     """
02397     from MoinMoin.Page import Page
02398     from MoinMoin.util import diff_text
02399     lines1 = Page(request, pagename1, rev=rev1).getlines()
02400     lines2 = Page(request, pagename2, rev=rev2).getlines()
02401 
02402     lines = diff_text.diff(lines1, lines2, **kw)
02403     return lines

def MoinMoin.wikiutil.pagelinkmarkup (   pagename,
  text = None 
)
return markup that can be used as link to page <pagename> 

Definition at line 825 of file wikiutil.py.

00825 
00826 def pagelinkmarkup(pagename, text=None):
00827     """ return markup that can be used as link to page <pagename> """
00828     from MoinMoin.parser.text_moin_wiki import Parser
00829     if re.match(Parser.word_rule + "$", pagename, re.U|re.X) and \
00830             (text is None or text == pagename):
00831         return pagename
00832     else:
00833         if text is None or text == pagename:
00834             text = ''
00835         else:
00836             text = '|%s' % text
00837         return u'[[%s%s]]' % (pagename, text)

def MoinMoin.wikiutil.parse_quoted_separated (   args,
  separator = ',
  name_value = True,
  seplimit = 0 
)

Definition at line 1454 of file wikiutil.py.

01454 
01455 def parse_quoted_separated(args, separator=',', name_value=True, seplimit=0):
01456     result = []
01457     positional = result
01458     if name_value:
01459         name_value_separator = '='
01460         trailing = []
01461         keywords = {}
01462     else:
01463         name_value_separator = None
01464 
01465     l = parse_quoted_separated_ext(args, separator=separator,
01466                                    name_value_separator=name_value_separator,
01467                                    seplimit=seplimit)
01468     for item in l:
01469         if isinstance(item, tuple):
01470             key, value = item
01471             if key is None:
01472                 key = u''
01473             keywords[key] = value
01474             positional = trailing
01475         else:
01476             positional.append(item)
01477 
01478     if name_value:
01479         return result, keywords, trailing
01480     return result

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.wikiutil.parse_quoted_separated_ext (   args,
  separator = None,
  name_value_separator = None,
  brackets = None,
  seplimit = 0,
  multikey = False,
  prefixes = None,
  quotes = '"' 
)
Parses the given string according to the other parameters.

Items can be quoted with any character from the quotes parameter
and each quote can be escaped by doubling it, the separator and
name_value_separator can both be quoted, when name_value_separator
is set then the name can also be quoted.

Values that are not given are returned as None, while the
empty string as a value can be achieved by quoting it.

If a name or value does not start with a quote, then the quote
looses its special meaning for that name or value, unless it
starts with one of the given prefixes (the parameter is unicode
containing all allowed prefixes.) The prefixes will be returned
as ParserPrefix() instances in the first element of the tuple
for that particular argument.

If multiple separators follow each other, this is treated as
having None arguments inbetween, that is also true for when
space is used as separators (when separator is None), filter
them out afterwards.

The function can also do bracketing, i.e. parse expressions
that contain things like
    "(a (a b))" to ['(', 'a', ['(', 'a', 'b']],
in this case, as in this example, the returned list will
contain sub-lists and the brackets parameter must be a list
of opening and closing brackets, e.g.
    brackets = ['()', '<>']
Each sub-list's first item is the opening bracket used for
grouping.
Nesting will be observed between the different types of
brackets given. If bracketing doesn't match, a BracketError
instance is raised with a 'bracket' property indicating the
type of missing or unexpected bracket, the instance will be
either of the class BracketMissingCloseError or of the class
BracketUnexpectedCloseError.

If multikey is True (along with setting name_value_separator),
then the returned tuples for (key, value) pairs can also have
multiple keys, e.g.
    "a=b=c" -> ('a', 'b', 'c')

@param args: arguments to parse
@param separator: the argument separator, defaults to None, meaning any
    space separates arguments
@param name_value_separator: separator for name=value, default '=',
    name=value keywords not parsed if evaluates to False
@param brackets: a list of two-character strings giving
    opening and closing brackets
@param seplimit: limits the number of parsed arguments
@param multikey: multiple keys allowed for a single value
@rtype: list
@returns: list of unicode strings and tuples containing
    unicode strings, or lists containing the same for
    bracketing support

Definition at line 1243 of file wikiutil.py.

01243 
01244                                prefixes=None, quotes='"'):
01245     """
01246     Parses the given string according to the other parameters.
01247 
01248     Items can be quoted with any character from the quotes parameter
01249     and each quote can be escaped by doubling it, the separator and
01250     name_value_separator can both be quoted, when name_value_separator
01251     is set then the name can also be quoted.
01252 
01253     Values that are not given are returned as None, while the
01254     empty string as a value can be achieved by quoting it.
01255 
01256     If a name or value does not start with a quote, then the quote
01257     looses its special meaning for that name or value, unless it
01258     starts with one of the given prefixes (the parameter is unicode
01259     containing all allowed prefixes.) The prefixes will be returned
01260     as ParserPrefix() instances in the first element of the tuple
01261     for that particular argument.
01262 
01263     If multiple separators follow each other, this is treated as
01264     having None arguments inbetween, that is also true for when
01265     space is used as separators (when separator is None), filter
01266     them out afterwards.
01267 
01268     The function can also do bracketing, i.e. parse expressions
01269     that contain things like
01270         "(a (a b))" to ['(', 'a', ['(', 'a', 'b']],
01271     in this case, as in this example, the returned list will
01272     contain sub-lists and the brackets parameter must be a list
01273     of opening and closing brackets, e.g.
01274         brackets = ['()', '<>']
01275     Each sub-list's first item is the opening bracket used for
01276     grouping.
01277     Nesting will be observed between the different types of
01278     brackets given. If bracketing doesn't match, a BracketError
01279     instance is raised with a 'bracket' property indicating the
01280     type of missing or unexpected bracket, the instance will be
01281     either of the class BracketMissingCloseError or of the class
01282     BracketUnexpectedCloseError.
01283 
01284     If multikey is True (along with setting name_value_separator),
01285     then the returned tuples for (key, value) pairs can also have
01286     multiple keys, e.g.
01287         "a=b=c" -> ('a', 'b', 'c')
01288 
01289     @param args: arguments to parse
01290     @param separator: the argument separator, defaults to None, meaning any
01291         space separates arguments
01292     @param name_value_separator: separator for name=value, default '=',
01293         name=value keywords not parsed if evaluates to False
01294     @param brackets: a list of two-character strings giving
01295         opening and closing brackets
01296     @param seplimit: limits the number of parsed arguments
01297     @param multikey: multiple keys allowed for a single value
01298     @rtype: list
01299     @returns: list of unicode strings and tuples containing
01300         unicode strings, or lists containing the same for
01301         bracketing support
01302     """
01303     idx = 0
01304     assert name_value_separator is None or name_value_separator != separator
01305     assert name_value_separator is None or len(name_value_separator) == 1
01306     if not isinstance(args, unicode):
01307         raise TypeError('args must be unicode')
01308     max = len(args)
01309     result = []         # result list
01310     cur = [None]        # current item
01311     quoted = None       # we're inside quotes, indicates quote character used
01312     skipquote = 0       # next quote is a quoted quote
01313     noquote = False     # no quotes expected because word didn't start with one
01314     seplimit_reached = False # number of separators exhausted
01315     separator_count = 0 # number of separators encountered
01316     SPACE = [' ', '\t', ]
01317     nextitemsep = [separator]   # used for skipping trailing space
01318     SPACE = [' ', '\t', ]
01319     if separator is None:
01320         nextitemsep = SPACE[:]
01321         separators = SPACE
01322     else:
01323         nextitemsep = [separator]   # used for skipping trailing space
01324         separators = [separator]
01325     if name_value_separator:
01326         nextitemsep.append(name_value_separator)
01327 
01328     # bracketing support
01329     opening = []
01330     closing = []
01331     bracketstack = []
01332     matchingbracket = {}
01333     if brackets:
01334         for o, c in brackets:
01335             assert not o in opening
01336             opening.append(o)
01337             assert not c in closing
01338             closing.append(c)
01339             matchingbracket[o] = c
01340 
01341     def additem(result, cur, separator_count, nextitemsep):
01342         if len(cur) == 1:
01343             result.extend(cur)
01344         elif cur:
01345             result.append(tuple(cur))
01346         cur = [None]
01347         noquote = False
01348         separator_count += 1
01349         seplimit_reached = False
01350         if seplimit and separator_count >= seplimit:
01351             seplimit_reached = True
01352             nextitemsep = [n for n in nextitemsep if n in separators]
01353 
01354         return cur, noquote, separator_count, seplimit_reached, nextitemsep
01355 
01356     while idx < max:
01357         char = args[idx]
01358         next = None
01359         if idx + 1 < max:
01360             next = args[idx+1]
01361         if skipquote:
01362             skipquote -= 1
01363         if not separator is None and not quoted and char in SPACE:
01364             spaces = ''
01365             # accumulate all space
01366             while char in SPACE and idx < max - 1:
01367                 spaces += char
01368                 idx += 1
01369                 char = args[idx]
01370             # remove space if args end with it
01371             if char in SPACE and idx == max - 1:
01372                 break
01373             # remove space at end of argument
01374             if char in nextitemsep:
01375                 continue
01376             idx -= 1
01377             if len(cur) and cur[-1]:
01378                 cur[-1] = cur[-1] + spaces
01379         elif not quoted and char == name_value_separator:
01380             if multikey or len(cur) == 1:
01381                 cur.append(None)
01382             else:
01383                 if not multikey:
01384                     if cur[-1] is None:
01385                         cur[-1] = ''
01386                     cur[-1] += name_value_separator
01387                 else:
01388                     cur.append(None)
01389             noquote = False
01390         elif not quoted and not seplimit_reached and char in separators:
01391             (cur, noquote, separator_count, seplimit_reached,
01392              nextitemsep) = additem(result, cur, separator_count, nextitemsep)
01393         elif not quoted and not noquote and char in quotes:
01394             if len(cur) and cur[-1] is None:
01395                 del cur[-1]
01396             cur.append(u'')
01397             quoted = char
01398         elif char == quoted and not skipquote:
01399             if next == quoted:
01400                 skipquote = 2 # will be decremented right away
01401             else:
01402                 quoted = None
01403         elif not quoted and char in opening:
01404             while len(cur) and cur[-1] is None:
01405                 del cur[-1]
01406             (cur, noquote, separator_count, seplimit_reached,
01407              nextitemsep) = additem(result, cur, separator_count, nextitemsep)
01408             bracketstack.append((matchingbracket[char], result))
01409             result = [char]
01410         elif not quoted and char in closing:
01411             while len(cur) and cur[-1] is None:
01412                 del cur[-1]
01413             (cur, noquote, separator_count, seplimit_reached,
01414              nextitemsep) = additem(result, cur, separator_count, nextitemsep)
01415             cur = []
01416             if not bracketstack:
01417                 raise BracketUnexpectedCloseError(char)
01418             expected, oldresult = bracketstack[-1]
01419             if not expected == char:
01420                 raise BracketUnexpectedCloseError(char)
01421             del bracketstack[-1]
01422             oldresult.append(result)
01423             result = oldresult
01424         elif not quoted and prefixes and char in prefixes and cur == [None]:
01425             cur = [ParserPrefix(char)]
01426             cur.append(None)
01427         else:
01428             if len(cur):
01429                 if cur[-1] is None:
01430                     cur[-1] = char
01431                 else:
01432                     cur[-1] += char
01433             else:
01434                 cur.append(char)
01435             noquote = True
01436 
01437         idx += 1
01438 
01439     if bracketstack:
01440         raise BracketMissingCloseError(bracketstack[-1][0])
01441 
01442     if quoted:
01443         if len(cur):
01444             if cur[-1] is None:
01445                 cur[-1] = quoted
01446             else:
01447                 cur[-1] = quoted + cur[-1]
01448         else:
01449             cur.append(quoted)
01450 
01451     additem(result, cur, separator_count, nextitemsep)
01452 
01453     return result

Here is the caller graph for this function:

def MoinMoin.wikiutil.parseAttributes (   request,
  attrstring,
  endtoken = None,
  extension = None 
)
Parse a list of attributes and return a dict plus a possible
error message.
If extension is passed, it has to be a callable that returns
a tuple (found_flag, msg). found_flag is whether it did find and process
something, msg is '' when all was OK or any other string to return an error
message.

@param request: the request object
@param attrstring: string containing the attributes to be parsed
@param endtoken: token terminating parsing
@param extension: extension function -
                  gets called with the current token, the parser and the dict
@rtype: dict, msg
@return: a dict plus a possible error message

Definition at line 1928 of file wikiutil.py.

01928 
01929 def parseAttributes(request, attrstring, endtoken=None, extension=None):
01930     """
01931     Parse a list of attributes and return a dict plus a possible
01932     error message.
01933     If extension is passed, it has to be a callable that returns
01934     a tuple (found_flag, msg). found_flag is whether it did find and process
01935     something, msg is '' when all was OK or any other string to return an error
01936     message.
01937 
01938     @param request: the request object
01939     @param attrstring: string containing the attributes to be parsed
01940     @param endtoken: token terminating parsing
01941     @param extension: extension function -
01942                       gets called with the current token, the parser and the dict
01943     @rtype: dict, msg
01944     @return: a dict plus a possible error message
01945     """
01946     import shlex, StringIO
01947 
01948     _ = request.getText
01949 
01950     parser = shlex.shlex(StringIO.StringIO(attrstring))
01951     parser.commenters = ''
01952     msg = None
01953     attrs = {}
01954 
01955     while not msg:
01956         try:
01957             key = parser.get_token()
01958         except ValueError, err:
01959             msg = str(err)
01960             break
01961         if not key:
01962             break
01963         if endtoken and key == endtoken:
01964             break
01965 
01966         # call extension function with the current token, the parser, and the dict
01967         if extension:
01968             found_flag, msg = extension(key, parser, attrs)
01969             #logging.debug("%r = extension(%r, parser, %r)" % (msg, key, attrs))
01970             if found_flag:
01971                 continue
01972             elif msg:
01973                 break
01974             #else (we found nothing, but also didn't have an error msg) we just continue below:
01975 
01976         try:
01977             eq = parser.get_token()
01978         except ValueError, err:
01979             msg = str(err)
01980             break
01981         if eq != "=":
01982             msg = _('Expected "=" to follow "%(token)s"') % {'token': key}
01983             break
01984 
01985         try:
01986             val = parser.get_token()
01987         except ValueError, err:
01988             msg = str(err)
01989             break
01990         if not val:
01991             msg = _('Expected a value for key "%(token)s"') % {'token': key}
01992             break
01993 
01994         key = escape(key) # make sure nobody cheats
01995 
01996         # safely escape and quote value
01997         if val[0] in ["'", '"']:
01998             val = escape(val)
01999         else:
02000             val = '"%s"' % escape(val, 1)
02001 
02002         attrs[key.lower()] = val
02003 
02004     return attrs, msg or ''
02005 

def MoinMoin.wikiutil.parseQueryString (   qstr,
  want_unicode = None 
)
see werkzeug.url_decode

    Please note: this returns a MultiDict, you might need to use dict() on
                 the result if your code expects a "normal" dict.

Definition at line 120 of file wikiutil.py.

00120 
00121 def parseQueryString(qstr, want_unicode=None):
00122     """ see werkzeug.url_decode
00123 
00124         Please note: this returns a MultiDict, you might need to use dict() on
00125                      the result if your code expects a "normal" dict.
00126     """
00127     try:
00128         assert want_unicode is None
00129     except AssertionError:
00130         log.exception("call with deprecated want_unicode param, please fix caller")
00131     return werkzeug.url_decode(qstr, charset=config.charset, errors='fallback:iso-8859-1',
00132                                decode_keys=False, include_empty=False)

def MoinMoin.wikiutil.quoteWikinameFS (   wikiname,
  charset = config.charset 
)
Return file system representation of a Unicode WikiName.

Warning: will raise UnicodeError if wikiname can not be encoded using
charset. The default value of config.charset, 'utf-8' can encode any
character.

@param wikiname: Unicode string possibly containing non-ascii characters
@param charset: charset to encode string
@rtype: string
@return: quoted name, safe for any file system

Definition at line 222 of file wikiutil.py.

00222 
00223 def quoteWikinameFS(wikiname, charset=config.charset):
00224     """ Return file system representation of a Unicode WikiName.
00225 
00226     Warning: will raise UnicodeError if wikiname can not be encoded using
00227     charset. The default value of config.charset, 'utf-8' can encode any
00228     character.
00229 
00230     @param wikiname: Unicode string possibly containing non-ascii characters
00231     @param charset: charset to encode string
00232     @rtype: string
00233     @return: quoted name, safe for any file system
00234     """
00235     filename = wikiname.encode(charset)
00236 
00237     quoted = []
00238     location = 0
00239     for needle in UNSAFE.finditer(filename):
00240         # append leading safe stuff
00241         quoted.append(filename[location:needle.start()])
00242         location = needle.end()
00243         # Quote and append unsafe stuff
00244         quoted.append('(')
00245         for character in needle.group():
00246             quoted.append('%02x' % ord(character))
00247         quoted.append(')')
00248 
00249     # append rest of string
00250     quoted.append(filename[location:])
00251     return ''.join(quoted)
00252 

def MoinMoin.wikiutil.quoteWikinameURL (   pagename,
  charset = config.charset 
)
Return a url encoding of filename in plain ascii

Use urllib.quote to quote any character that is not always safe.

@param pagename: the original pagename (unicode)
@param charset: url text encoding, 'utf-8' recommended. Other charset
                might not be able to encode the page name and raise
                UnicodeError. (default config.charset ('utf-8')).
@rtype: string
@return: the quoted filename, all unsafe characters encoded

Definition at line 162 of file wikiutil.py.

00162 
00163 def quoteWikinameURL(pagename, charset=config.charset):
00164     """ Return a url encoding of filename in plain ascii
00165 
00166     Use urllib.quote to quote any character that is not always safe.
00167 
00168     @param pagename: the original pagename (unicode)
00169     @param charset: url text encoding, 'utf-8' recommended. Other charset
00170                     might not be able to encode the page name and raise
00171                     UnicodeError. (default config.charset ('utf-8')).
00172     @rtype: string
00173     @return: the quoted filename, all unsafe characters encoded
00174     """
00175     # XXX please note that urllib.quote and werkzeug.url_quote have
00176     # XXX different defaults for safe=...
00177     return werkzeug.url_quote(pagename, charset=charset, safe='/')
00178 

Here is the caller graph for this function:

def MoinMoin.wikiutil.RelPageName (   context,
  pagename 
)
Return the relative pagename for some context.

@param context: name of the page where "pagename" appears on
@param pagename: the absolute page name
@rtype: string
@return: the relative page name

Definition at line 792 of file wikiutil.py.

00792 
00793 def RelPageName(context, pagename):
00794     """
00795     Return the relative pagename for some context.
00796 
00797     @param context: name of the page where "pagename" appears on
00798     @param pagename: the absolute page name
00799     @rtype: string
00800     @return: the relative page name
00801     """
00802     if context == '':
00803         # special case, context is some "virtual root" page with name == ''
00804         # every page is a subpage of this virtual root
00805         return CHILD_PREFIX + pagename
00806     elif pagename.startswith(context + CHILD_PREFIX):
00807         # simple child
00808         return pagename[len(context):]
00809     else:
00810         # some kind of sister/aunt
00811         context_frags = context.split('/')   # A, B, C, D, E
00812         pagename_frags = pagename.split('/') # A, B, C, F
00813         # first throw away common parents:
00814         common = 0
00815         for cf, pf in zip(context_frags, pagename_frags):
00816             if cf == pf:
00817                 common += 1
00818             else:
00819                 break
00820         context_frags = context_frags[common:] # D, E
00821         pagename_frags = pagename_frags[common:] # F
00822         go_up = len(context_frags)
00823         return PARENT_PREFIX * go_up + '/'.join(pagename_frags)
00824 

def MoinMoin.wikiutil.renderText (   request,
  Parser,
  text 
)
executes raw wiki markup with all page elements

Definition at line 2502 of file wikiutil.py.

02502 
02503 def renderText(request, Parser, text):
02504     """executes raw wiki markup with all page elements"""
02505     import StringIO
02506     out = StringIO.StringIO()
02507     request.redirect(out)
02508     wikiizer = Parser(text, request)
02509     wikiizer.format(request.formatter, inhibit_p=True)
02510     result = out.getvalue()
02511     request.redirect()
02512     del out
02513     return result

def MoinMoin.wikiutil.resolve_interwiki (   request,
  wikiname,
  pagename 
)
Resolve an interwiki reference (wikiname:pagename).

@param request: the request object
@param wikiname: interwiki wiki name
@param pagename: interwiki page name
@rtype: tuple
@return: (wikitag, wikiurl, wikitail, err)

Definition at line 579 of file wikiutil.py.

00579 
00580 def resolve_interwiki(request, wikiname, pagename):
00581     """ Resolve an interwiki reference (wikiname:pagename).
00582 
00583     @param request: the request object
00584     @param wikiname: interwiki wiki name
00585     @param pagename: interwiki page name
00586     @rtype: tuple
00587     @return: (wikitag, wikiurl, wikitail, err)
00588     """
00589     _interwiki_list = load_wikimap(request)
00590     if wikiname in _interwiki_list:
00591         return (wikiname, _interwiki_list[wikiname], pagename, False)
00592     else:
00593         return (wikiname, request.script_root, "/InterWiki", True)

Here is the call graph for this function:

def MoinMoin.wikiutil.resolve_wiki (   request,
  wikiurl 
)
Resolve an interwiki link.

*** DEPRECATED FUNCTION FOR OLD 1.5 SYNTAX - ONLY STILL HERE FOR THE 1.5 -> 1.6 MIGRATION ***
Use resolve_interwiki(), see below.

@param request: the request object
@param wikiurl: the InterWiki:PageName link
@rtype: tuple
@return: (wikitag, wikiurl, wikitail, err)

Definition at line 557 of file wikiutil.py.

00557 
00558 def resolve_wiki(request, wikiurl):
00559     """
00560     Resolve an interwiki link.
00561 
00562     *** DEPRECATED FUNCTION FOR OLD 1.5 SYNTAX - ONLY STILL HERE FOR THE 1.5 -> 1.6 MIGRATION ***
00563     Use resolve_interwiki(), see below.
00564 
00565     @param request: the request object
00566     @param wikiurl: the InterWiki:PageName link
00567     @rtype: tuple
00568     @return: (wikitag, wikiurl, wikitail, err)
00569     """
00570     _interwiki_list = load_wikimap(request)
00571     # split wiki url
00572     wikiname, pagename = split_wiki(wikiurl)
00573 
00574     # return resolved url
00575     if wikiname in _interwiki_list:
00576         return (wikiname, _interwiki_list[wikiname], pagename, False)
00577     else:
00578         return (wikiname, request.script_root, "/InterWiki", True)

Here is the call graph for this function:

def MoinMoin.wikiutil.searchAndImportPlugin (   cfg,
  type,
  name,
  what = None 
)

Definition at line 1153 of file wikiutil.py.

01153 
01154 def searchAndImportPlugin(cfg, type, name, what=None):
01155     type2classname = {"parser": "Parser",
01156                       "formatter": "Formatter",
01157     }
01158     if what is None:
01159         what = type2classname[type]
01160     mt = MimeType(name)
01161     plugin = None
01162     for module_name in mt.module_name():
01163         try:
01164             plugin = importPlugin(cfg, type, module_name, what)
01165             break
01166         except PluginMissingError:
01167             pass
01168     else:
01169         raise PluginMissingError("Plugin not found! (%r %r %r)" % (type, name, what))
01170     return plugin
01171 

Here is the call graph for this function:

def MoinMoin.wikiutil.split_anchor (   pagename)
Split a pagename that (optionally) has an anchor into the real pagename
and the anchor part. If there is no anchor, it returns an empty string
for the anchor.

Note: if pagename contains a # (as part of the pagename, not as anchor),
      you can use a trick to make it work nevertheless: just append a
      # at the end:
      "C##" returns ("C#", "")
      "Problem #1#" returns ("Problem #1", "")

TODO: We shouldn't deal with composite pagename#anchor strings, but keep
      it separate.
      Current approach: [[pagename#anchor|label|attr=val,&qarg=qval]]
      Future approach:  [[pagename|label|attr=val,&qarg=qval,#anchor]]
      The future approach will avoid problems when there is a # in the
      pagename part (and no anchor). Also, we need to append #anchor
      at the END of the generated URL (AFTER the query string).

Definition at line 2418 of file wikiutil.py.

02418 
02419 def split_anchor(pagename):
02420     """
02421     Split a pagename that (optionally) has an anchor into the real pagename
02422     and the anchor part. If there is no anchor, it returns an empty string
02423     for the anchor.
02424 
02425     Note: if pagename contains a # (as part of the pagename, not as anchor),
02426           you can use a trick to make it work nevertheless: just append a
02427           # at the end:
02428           "C##" returns ("C#", "")
02429           "Problem #1#" returns ("Problem #1", "")
02430 
02431     TODO: We shouldn't deal with composite pagename#anchor strings, but keep
02432           it separate.
02433           Current approach: [[pagename#anchor|label|attr=val,&qarg=qval]]
02434           Future approach:  [[pagename|label|attr=val,&qarg=qval,#anchor]]
02435           The future approach will avoid problems when there is a # in the
02436           pagename part (and no anchor). Also, we need to append #anchor
02437           at the END of the generated URL (AFTER the query string).
02438     """
02439     parts = rsplit(pagename, '#', 1)
02440     if len(parts) == 2:
02441         return parts
02442     else:
02443         return pagename, ""

Split a interwiki name, into wikiname and pagename, e.g:

'MoinMoin:FrontPage' -> "MoinMoin", "FrontPage"
'FrontPage' -> "Self", "FrontPage"
'MoinMoin:Page with blanks' -> "MoinMoin", "Page with blanks"
'MoinMoin:' -> "MoinMoin", ""

can also be used for:

'attachment:filename with blanks.txt' -> "attachment", "filename with blanks.txt"

@param wikiurl: the url to split
@rtype: tuple
@return: (wikiname, pagename)

Definition at line 535 of file wikiutil.py.

00535 
00536 def split_interwiki(wikiurl):
00537     """ Split a interwiki name, into wikiname and pagename, e.g:
00538 
00539     'MoinMoin:FrontPage' -> "MoinMoin", "FrontPage"
00540     'FrontPage' -> "Self", "FrontPage"
00541     'MoinMoin:Page with blanks' -> "MoinMoin", "Page with blanks"
00542     'MoinMoin:' -> "MoinMoin", ""
00543 
00544     can also be used for:
00545 
00546     'attachment:filename with blanks.txt' -> "attachment", "filename with blanks.txt"
00547 
00548     @param wikiurl: the url to split
00549     @rtype: tuple
00550     @return: (wikiname, pagename)
00551     """
00552     try:
00553         wikiname, pagename = wikiurl.split(":", 1)
00554     except ValueError:
00555         wikiname, pagename = 'Self', wikiurl
00556     return wikiname, pagename

def MoinMoin.wikiutil.split_wiki (   wikiurl)
Split a wiki url.

*** DEPRECATED FUNCTION FOR OLD 1.5 SYNTAX - ONLY STILL HERE FOR THE 1.5 -> 1.6 MIGRATION ***
Use split_interwiki(), see below.

@param wikiurl: the url to split
@rtype: tuple
@return: (tag, tail)

Definition at line 514 of file wikiutil.py.

00514 
00515 def split_wiki(wikiurl):
00516     """
00517     Split a wiki url.
00518 
00519     *** DEPRECATED FUNCTION FOR OLD 1.5 SYNTAX - ONLY STILL HERE FOR THE 1.5 -> 1.6 MIGRATION ***
00520     Use split_interwiki(), see below.
00521 
00522     @param wikiurl: the url to split
00523     @rtype: tuple
00524     @return: (tag, tail)
00525     """
00526     # !!! use a regex here!
00527     try:
00528         wikitag, tail = wikiurl.split(":", 1)
00529     except ValueError:
00530         try:
00531             wikitag, tail = wikiurl.split("/", 1)
00532         except ValueError:
00533             wikitag, tail = 'Self', wikiurl
00534     return wikitag, tail

Here is the caller graph for this function:

def MoinMoin.wikiutil.taintfilename (   basename)
Make a filename that is supposed to be a plain name secure, i.e.
remove any possible path components that compromise our system.

@param basename: (possibly unsafe) filename
@rtype: string
@return: (safer) filename

Definition at line 2224 of file wikiutil.py.

02224 
02225 def taintfilename(basename):
02226     """
02227     Make a filename that is supposed to be a plain name secure, i.e.
02228     remove any possible path components that compromise our system.
02229 
02230     @param basename: (possibly unsafe) filename
02231     @rtype: string
02232     @return: (safer) filename
02233     """
02234     for x in (os.pardir, ':', '/', '\\', '<', '>'):
02235         basename = basename.replace(x, '_')
02236 
02237     return basename
02238 

Convert UNIX timestamp (may be float or int) to our version
    (long) int.
    We don't want to use floats, so we just scale by 1e6 to get
    an integer in usecs.

Definition at line 315 of file wikiutil.py.

00315 
00316 def timestamp2version(ts):
00317     """ Convert UNIX timestamp (may be float or int) to our version
00318         (long) int.
00319         We don't want to use floats, so we just scale by 1e6 to get
00320         an integer in usecs.
00321     """
00322     return long(ts*1000000L) # has to be long for py 2.2.x

def MoinMoin.wikiutil.unquoteWikiname (   filename,
  charsets = [config.charset] 
)
Return Unicode WikiName from quoted file name.

We raise an InvalidFileNameError if we find an invalid name, so the
wiki could alarm the admin or suggest the user to rename a page.
Invalid file names should never happen in normal use, but are rather
cheap to find.

This function should be used only to unquote file names, not page
names we receive from the user. These are handled in request by
urllib.unquote, decodePagename and normalizePagename.

Todo: search clients of unquoteWikiname and check for exceptions.

@param filename: string using charset and possibly quoted parts
@param charsets: list of charsets used by string
@rtype: Unicode String
@return: WikiName

Definition at line 253 of file wikiutil.py.

00253 
00254 def unquoteWikiname(filename, charsets=[config.charset]):
00255     """ Return Unicode WikiName from quoted file name.
00256 
00257     We raise an InvalidFileNameError if we find an invalid name, so the
00258     wiki could alarm the admin or suggest the user to rename a page.
00259     Invalid file names should never happen in normal use, but are rather
00260     cheap to find.
00261 
00262     This function should be used only to unquote file names, not page
00263     names we receive from the user. These are handled in request by
00264     urllib.unquote, decodePagename and normalizePagename.
00265 
00266     Todo: search clients of unquoteWikiname and check for exceptions.
00267 
00268     @param filename: string using charset and possibly quoted parts
00269     @param charsets: list of charsets used by string
00270     @rtype: Unicode String
00271     @return: WikiName
00272     """
00273     ### Temporary fix start ###
00274     # From some places we get called with Unicode strings
00275     if isinstance(filename, type(u'')):
00276         filename = filename.encode(config.charset)
00277     ### Temporary fix end ###
00278 
00279     parts = []
00280     start = 0
00281     for needle in QUOTED.finditer(filename):
00282         # append leading unquoted stuff
00283         parts.append(filename[start:needle.start()])
00284         start = needle.end()
00285         # Append quoted stuff
00286         group = needle.group(1)
00287         # Filter invalid filenames
00288         if (len(group) % 2 != 0):
00289             raise InvalidFileNameError(filename)
00290         try:
00291             for i in range(0, len(group), 2):
00292                 byte = group[i:i+2]
00293                 character = chr(int(byte, 16))
00294                 parts.append(character)
00295         except ValueError:
00296             # byte not in hex, e.g 'xy'
00297             raise InvalidFileNameError(filename)
00298 
00299     # append rest of string
00300     if start == 0:
00301         wikiname = filename
00302     else:
00303         parts.append(filename[start:len(filename)])
00304         wikiname = ''.join(parts)
00305 
00306     # FIXME: This looks wrong, because at this stage "()" can be both errors
00307     # like open "(" without close ")", or unquoted valid characters in the file name.
00308     # Filter invalid filenames. Any left (xx) must be invalid
00309     #if '(' in wikiname or ')' in wikiname:
00310     #    raise InvalidFileNameError(filename)
00311 
00312     wikiname = decodeUserInput(wikiname, charsets)
00313     return wikiname
00314 
# time scaling

Here is the call graph for this function:

def MoinMoin.wikiutil.url_quote (   s,
  safe = '/',
  want_unicode = None 
)
see werkzeug.url_quote, we use a different safe param default value 

Definition at line 93 of file wikiutil.py.

00093 
00094 def url_quote(s, safe='/', want_unicode=None):
00095     """ see werkzeug.url_quote, we use a different safe param default value """
00096     try:
00097         assert want_unicode is None
00098     except AssertionError:
00099         log.exception("call with deprecated want_unicode param, please fix caller")
00100     return werkzeug.url_quote(s, charset=config.charset, safe=safe)

Here is the caller graph for this function:

def MoinMoin.wikiutil.url_quote_plus (   s,
  safe = '/',
  want_unicode = None 
)
see werkzeug.url_quote_plus, we use a different safe param default value 

Definition at line 101 of file wikiutil.py.

00101 
00102 def url_quote_plus(s, safe='/', want_unicode=None):
00103     """ see werkzeug.url_quote_plus, we use a different safe param default value """
00104     try:
00105         assert want_unicode is None
00106     except AssertionError:
00107         log.exception("call with deprecated want_unicode param, please fix caller")
00108     return werkzeug.url_quote_plus(s, charset=config.charset, safe=safe)

def MoinMoin.wikiutil.url_unquote (   s,
  want_unicode = None 
)
see werkzeug.url_unquote 

Definition at line 109 of file wikiutil.py.

00109 
00110 def url_unquote(s, want_unicode=None):
00111     """ see werkzeug.url_unquote """
00112     try:
00113         assert want_unicode is None
00114     except AssertionError:
00115         log.exception("call with deprecated want_unicode param, please fix caller")
00116     if isinstance(s, unicode):
00117         s = s.encode(config.charset)
00118     return werkzeug.url_unquote(s, charset=config.charset, errors='fallback:iso-8859-1')
00119 

Convert version number to UNIX timestamp (float).
    This must ONLY be used for display purposes.

Definition at line 323 of file wikiutil.py.

00323 
00324 def version2timestamp(v):
00325     """ Convert version number to UNIX timestamp (float).
00326         This must ONLY be used for display purposes.
00327     """
00328     return v / 1000000.0
00329 
00330 
00331 # This is the list of meta attribute names to be treated as integers.
00332 # IMPORTANT: do not use any meta attribute names with "-" (or any other chars
# invalid in python attribute names), use e.g. _ instead.

Here is the caller graph for this function:

def MoinMoin.wikiutil.wikiPlugins (   kind,
  cfg 
)
Gets a dict containing the names of all plugins of @kind
as the key and the containing module name as the value.

@param kind: what kind of modules we look for
@rtype: dict
@return: plugin name to containing module name mapping

Definition at line 1105 of file wikiutil.py.

01105 
01106 def wikiPlugins(kind, cfg):
01107     """
01108     Gets a dict containing the names of all plugins of @kind
01109     as the key and the containing module name as the value.
01110 
01111     @param kind: what kind of modules we look for
01112     @rtype: dict
01113     @return: plugin name to containing module name mapping
01114     """
01115     # short-cut if we've loaded the dict already
01116     # (or already failed to load it)
01117     cache = cfg._site_plugin_lists
01118     if kind in cache:
01119         result = cache[kind]
01120     else:
01121         result = {}
01122         for modname in cfg._plugin_modules:
01123             try:
01124                 module = pysupport.importName(modname, kind)
01125                 packagepath = os.path.dirname(module.__file__)
01126                 plugins = pysupport.getPluginModules(packagepath)
01127                 for p in plugins:
01128                     if not p in result:
01129                         result[p] = '%s.%s' % (modname, kind)
01130             except AttributeError:
01131                 pass
01132         cache[kind] = result
01133     return result
01134 

Here is the caller graph for this function:


Variable Documentation

Definition at line 39 of file wikiutil.py.

Definition at line 40 of file wikiutil.py.

MoinMoin.wikiutil.escape = werkzeug.escape

Definition at line 179 of file wikiutil.py.

Initial value:
00001 ['current', 'revision', # for page storage (moin 2.0)
00002                  'data_format_revision', # for data_dir format spec (use by mig scripts)
00003                 ]

Definition at line 333 of file wikiutil.py.

string MoinMoin.wikiutil.INTERWIKI_PAGE = "InterWikiMap"

InterWiki.

Definition at line 430 of file wikiutil.py.

Definition at line 21 of file wikiutil.py.

Initial value:
00001 {
00002  # OpenOffice 2.x & other open document stuff
00003  '.odt': 'application/vnd.oasis.opendocument.text',
00004  '.ods': 'application/vnd.oasis.opendocument.spreadsheet',
00005  '.odp': 'application/vnd.oasis.opendocument.presentation',
00006  '.odg': 'application/vnd.oasis.opendocument.graphics',
00007  '.odc': 'application/vnd.oasis.opendocument.chart',
00008  '.odf': 'application/vnd.oasis.opendocument.formula',
00009  '.odb': 'application/vnd.oasis.opendocument.database',
00010  '.odi': 'application/vnd.oasis.opendocument.image',
00011  '.odm': 'application/vnd.oasis.opendocument.text-master',
00012  '.ott': 'application/vnd.oasis.opendocument.text-template',
00013  '.ots': 'application/vnd.oasis.opendocument.spreadsheet-template',
00014  '.otp': 'application/vnd.oasis.opendocument.presentation-template',
00015  '.otg': 'application/vnd.oasis.opendocument.graphics-template',
00016  # some systems (like Mac OS X) don't have some of these:
00017  '.patch': 'text/x-diff',
00018  '.diff': 'text/x-diff',
00019  '.py': 'text/x-python',
00020  '.cfg': 'text/plain',
00021  '.conf': 'text/plain',
00022  '.irc': 'text/plain',
00023  '.md5': 'text/plain',
00024  '.csv': 'text/csv',
00025  '.flv': 'video/x-flv',
00026  '.wmv': 'video/x-ms-wmv',
00027  '.swf': 'application/x-shockwave-flash',
00028 }

Definition at line 843 of file wikiutil.py.

Initial value:
00001 {
00002     # this stuff is text, but got application/* for unknown reasons
00003     ('application', 'docbook+xml'): ('text', 'docbook'),
00004     ('application', 'x-latex'): ('text', 'latex'),
00005     ('application', 'x-tex'): ('text', 'tex'),
00006     ('application', 'javascript'): ('text', 'javascript'),
00007 }

Definition at line 873 of file wikiutil.py.

Definition at line 881 of file wikiutil.py.

Definition at line 37 of file wikiutil.py.

Definition at line 38 of file wikiutil.py.

Definition at line 424 of file wikiutil.py.

tuple MoinMoin.wikiutil.QUOTED = re.compile(r'\(([a-fA-F0-9]+)\)')

Definition at line 219 of file wikiutil.py.

tuple MoinMoin.wikiutil.UNSAFE = re.compile(r'[^a-zA-Z0-9_]+')

Storage.

Definition at line 218 of file wikiutil.py.