Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
MoinMoin.support.werkzeug.routing Namespace Reference

Classes

class  RoutingException
class  RequestRedirect
class  RequestSlash
class  BuildError
class  ValidationError
class  RuleFactory
class  Subdomain
class  Submount
class  EndpointPrefix
class  RuleTemplate
class  RuleTemplateFactory
class  Rule
class  BaseConverter
class  UnicodeConverter
class  AnyConverter
class  PathConverter
class  NumberConverter
class  IntegerConverter
class  FloatConverter
class  Map
class  MapAdapter

Functions

def parse_rule
def get_converter

Variables

tuple _rule_re
tuple _simple_rule_re = re.compile(r'<([^>]+)>')
dictionary DEFAULT_CONVERTERS

Class Documentation

class MoinMoin::support::werkzeug::routing::ValidationError
Validation error.  If a rule converter raises this exception the rule
does not match the current URL and the next URL is tried.

Definition at line 210 of file routing.py.


Function Documentation

def MoinMoin.support.werkzeug.routing.get_converter (   map,
  name,
  args 
)
Create a new converter for the given arguments or raise
exception if the converter does not exist.

:internal:

Definition at line 153 of file routing.py.

00153 
00154 def get_converter(map, name, args):
00155     """Create a new converter for the given arguments or raise
00156     exception if the converter does not exist.
00157 
00158     :internal:
00159     """
00160     if not name in map.converters:
00161         raise LookupError('the converter %r does not exist' % name)
00162     if args:
00163         storage = type('_Storage', (), {'__getitem__': lambda s, x: x})()
00164         args, kwargs = eval(u'(lambda *a, **kw: (a, kw))(%s)' % args, {}, storage)
00165     else:
00166         args = ()
00167         kwargs = {}
00168     return map.converters[name](map, *args, **kwargs)
00169 

Here is the caller graph for this function:

Parse a rule and return it as generator. Each iteration yields tuples
in the form ``(converter, arguments, variable)``. If the converter is
`None` it's a static url part, otherwise it's a dynamic one.

:internal:

Definition at line 121 of file routing.py.

00121 
00122 def parse_rule(rule):
00123     """Parse a rule and return it as generator. Each iteration yields tuples
00124     in the form ``(converter, arguments, variable)``. If the converter is
00125     `None` it's a static url part, otherwise it's a dynamic one.
00126 
00127     :internal:
00128     """
00129     pos = 0
00130     end = len(rule)
00131     do_match = _rule_re.match
00132     used_names = set()
00133     while pos < end:
00134         m = do_match(rule, pos)
00135         if m is None:
00136             break
00137         data = m.groupdict()
00138         if data['static']:
00139             yield None, None, data['static']
00140         variable = data['variable']
00141         converter = data['converter'] or 'default'
00142         if variable in used_names:
00143             raise ValueError('variable name %r used twice.' % variable)
00144         used_names.add(variable)
00145         yield converter, data['args'] or None, variable
00146         pos = m.end()
00147     if pos < end:
00148         remaining = rule[pos:]
00149         if '>' in remaining or '<' in remaining:
00150             raise ValueError('malformed url rule: %r' % rule)
00151         yield None, None, remaining
00152 

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 re.compile(r'''
00002     (?P<static>[^<]*)                           # static rule data
00003     <
00004     (?:
00005         (?P<converter>[a-zA-Z_][a-zA-Z0-9_]*)   # converter name
00006         (?:\((?P<args>.*?)\))?                  # converter arguments
00007         \:                                      # variable delimiter
00008     )?
00009     (?P<variable>[a-zA-Z][a-zA-Z0-9_]*)         # variable name
00010     >
00011 ''', re.VERBOSE)

Definition at line 107 of file routing.py.

tuple MoinMoin.support.werkzeug.routing._simple_rule_re = re.compile(r'<([^>]+)>')

Definition at line 118 of file routing.py.

Initial value:
00001 {
00002     'default':          UnicodeConverter,
00003     'string':           UnicodeConverter,
00004     'any':              AnyConverter,
00005     'path':             PathConverter,
00006     'int':              IntegerConverter,
00007     'float':            FloatConverter
00008 }

Definition at line 1349 of file routing.py.