Back to index

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

Classes

class  _Missing
class  _ExtendedMorsel
class  _ExtendedCookie
class  _DictAccessorProperty

Functions

def _proxy_repr
def _log
def _parse_signature
def _patch_wrapper
def _decode_unicode
def _iter_modules
def _dump_date
def _date_to_unix
def _easteregg

Variables

 _logger = None
tuple _empty_stream = StringIO('')
tuple _signature_cache = WeakKeyDictionary()
dictionary HTTP_STATUS_CODES
tuple _missing = _Missing()
 _timegm = None

Function Documentation

Converts a timetuple, integer or datetime object into the seconds from
epoch in utc.

Definition at line 241 of file _internal.py.

00241 
00242 def _date_to_unix(arg):
00243     """Converts a timetuple, integer or datetime object into the seconds from
00244     epoch in utc.
00245     """
00246     global _timegm
00247     if isinstance(arg, datetime):
00248         arg = arg.utctimetuple()
00249     elif isinstance(arg, (int, long, float)):
00250         return int(arg)
00251     if _timegm is None:
00252         from calendar import timegm as _timegm
00253     return _timegm(arg)
00254 

Here is the caller graph for this function:

def MoinMoin.support.werkzeug._internal._decode_unicode (   value,
  charset,
  errors 
) [private]
Like the regular decode function but this one raises an
`HTTPUnicodeError` if errors is `strict`.

Definition at line 186 of file _internal.py.

00186 
00187 def _decode_unicode(value, charset, errors):
00188     """Like the regular decode function but this one raises an
00189     `HTTPUnicodeError` if errors is `strict`."""
00190     fallback = None
00191     if errors.startswith('fallback:'):
00192         fallback = errors[9:]
00193         errors = 'strict'
00194     try:
00195         return value.decode(charset, errors)
00196     except UnicodeError, e:
00197         if fallback is not None:
00198             return value.decode(fallback, 'ignore')
00199         from werkzeug.exceptions import HTTPUnicodeError
00200         raise HTTPUnicodeError(str(e))
00201 

Here is the caller graph for this function:

def MoinMoin.support.werkzeug._internal._dump_date (   d,
  delim 
) [private]
Used for `http_date` and `cookie_date`.

Definition at line 223 of file _internal.py.

00223 
00224 def _dump_date(d, delim):
00225     """Used for `http_date` and `cookie_date`."""
00226     if d is None:
00227         d = gmtime()
00228     elif isinstance(d, datetime):
00229         d = d.utctimetuple()
00230     elif isinstance(d, (int, long, float)):
00231         d = gmtime(d)
00232     return '%s, %02d%s%s%s%s %02d:%02d:%02d GMT' % (
00233         ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')[d.tm_wday],
00234         d.tm_mday, delim,
00235         ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
00236          'Oct', 'Nov', 'Dec')[d.tm_mon - 1],
00237         delim, str(d.tm_year), d.tm_hour, d.tm_min, d.tm_sec
00238     )
00239 

Here is the caller graph for this function:

Like the name says.  But who knows how it works?

Definition at line 334 of file _internal.py.

00334 
00335 def _easteregg(app):
00336     """Like the name says.  But who knows how it works?"""
00337     gyver = '\n'.join([x + (77 - len(x)) * ' ' for x in '''
00338 eJyFlzuOJDkMRP06xRjymKgDJCDQStBYT8BCgK4gTwfQ2fcFs2a2FzvZk+hvlcRvRJD148efHt9m
00339 9Xz94dRY5hGt1nrYcXx7us9qlcP9HHNh28rz8dZj+q4rynVFFPdlY4zH873NKCexrDM6zxxRymzz
00340 4QIxzK4bth1PV7+uHn6WXZ5C4ka/+prFzx3zWLMHAVZb8RRUxtFXI5DTQ2n3Hi2sNI+HK43AOWSY
00341 jmEzE4naFp58PdzhPMdslLVWHTGUVpSxImw+pS/D+JhzLfdS1j7PzUMxij+mc2U0I9zcbZ/HcZxc
00342 q1QjvvcThMYFnp93agEx392ZdLJWXbi/Ca4Oivl4h/Y1ErEqP+lrg7Xa4qnUKu5UE9UUA4xeqLJ5
00343 jWlPKJvR2yhRI7xFPdzPuc6adXu6ovwXwRPXXnZHxlPtkSkqWHilsOrGrvcVWXgGP3daXomCj317
00344 8P2UOw/NnA0OOikZyFf3zZ76eN9QXNwYdD8f8/LdBRFg0BO3bB+Pe/+G8er8tDJv83XTkj7WeMBJ
00345 v/rnAfdO51d6sFglfi8U7zbnr0u9tyJHhFZNXYfH8Iafv2Oa+DT6l8u9UYlajV/hcEgk1x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ZqSB2Qm0SGtjAw7RDwaM1roESC8HWiPxkoOy0lLTRFG39kvbLZbU9gFKFRvixDZBJmpi
00360 Xyq3RE5lW00EJjaqwp/v3EByMSpVZYsEIJ4APaHmVtpGSieV5CALOtNUAzTBiw81GLgC0quyzf6c
00361 NlWknzJeCsJ5fup2R4d8CYGN77mu5vnO1UqbfElZ9E6cR6zbHjgsr9ly18fXjZoPeDjPuzlWbFwS
00362 pdvPkhntFvkc13qb9094LL5NrA3NIq3r9eNnop9DizWOqCEbyRBFJTHn6Tt3CG1o8a4HevYh0XiJ
00363 sR0AVVHuGuMOIfbuQ/OKBkGRC6NJ4u7sbPX8bG/n5sNIOQ6/Y/BX3IwRlTSabtZpYLB85lYtkkgm
00364 p1qXK3Du2mnr5INXmT/78KI12n11EFBkJHHp0wJyLe9MvPNUGYsf+170maayRoy2lURGHAIapSpQ
00365 krEDuNoJCHNlZYhKpvw4mspVWxqo415n8cD62N9+EfHrAvqQnINStetek7RY2Urv8nxsnGaZfRr/
00366 nhXbJ6m/yl1LzYqscDZA9QHLNbdaSTTr+kFg3bC0iYbX/eQy0Bv3h4B50/SGYzKAXkCeOLI3bcAt
00367 mj2Z/FM1vQWgDynsRwNvrWnJHlespkrp8+vO1jNaibm+PhqXPPv30YwDZ6jApe3wUjFQobghvW9p
00368 7f2zLkGNv8b191cD/3vs9Q833z8t'''.decode('base64').decode('zlib').splitlines()])
00369     def easteregged(environ, start_response):
00370         def injecting_start_response(status, headers, exc_info=None):
00371             headers.append(('X-Powered-By', 'Werkzeug'))
00372             return start_response(status, headers, exc_info)
00373         if environ.get('QUERY_STRING') != 'macgybarchakku':
00374             return app(environ, injecting_start_response)
00375         injecting_start_response('200 OK', [('Content-Type', 'text/html')])
00376         return ['''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
00377 <title>About Werkzeug</>
00378 <style type="text/css">
00379   body { font: 15px Georgia, serif; text-align: center; }
00380   a { color: #333; text-decoration: none; }
00381   h1 { font-size: 30px; margin: 20px 0 10px 0; }
00382   p { margin: 0 0 30px 0; }
00383   pre { font: 11px 'Consolas', 'Monaco', monospace; line-height: 0.95; }
00384 </style>
00385 <h1><a href="http://werkzeug.pocoo.org/">Werkzeug</a></h1>
00386 <p>the Swiss Army knife of Python web development.
00387 <pre>%s\n\n\n</>''' % gyver]
00388     return easteregged
Iterate over all modules in a package.

Definition at line 202 of file _internal.py.

00202 
00203 def _iter_modules(path):
00204     """Iterate over all modules in a package."""
00205     import os
00206     import pkgutil
00207     if hasattr(pkgutil, 'iter_modules'):
00208         for importer, modname, ispkg in pkgutil.iter_modules(path):
00209             yield modname, ispkg
00210         return
00211     from inspect import getmodulename
00212     from pydoc import ispackage
00213     found = set()
00214     for path in path:
00215         for filename in os.listdir(path):
00216             p = os.path.join(path, filename)
00217             modname = getmodulename(filename)
00218             if modname and modname != '__init__':
00219                 if modname not in found:
00220                     found.add(modname)
00221                     yield modname, ispackage(modname)
00222 

Here is the caller graph for this function:

def MoinMoin.support.werkzeug._internal._log (   type,
  message,
  args,
  kwargs 
) [private]
Log into the internal werkzeug logger.

Definition at line 96 of file _internal.py.

00096 
00097 def _log(type, message, *args, **kwargs):
00098     """Log into the internal werkzeug logger."""
00099     global _logger
00100     if _logger is None:
00101         import logging
00102         _logger = logging.getLogger('werkzeug')
00103         if _logger.level == logging.NOTSET:
00104             _logger.setLevel(logging.INFO)
00105             handler = logging.StreamHandler()
00106             _logger.addHandler(handler)
00107     getattr(_logger, type)(message.rstrip(), *args, **kwargs)
00108 

Here is the caller graph for this function:

Return a signature object for the function.

Definition at line 109 of file _internal.py.

00109 
00110 def _parse_signature(func):
00111     """Return a signature object for the function."""
00112     if hasattr(func, 'im_func'):
00113         func = func.im_func
00114 
00115     # if we have a cached validator for this function, return it
00116     parse = _signature_cache.get(func)
00117     if parse is not None:
00118         return parse
00119 
00120     # inspect the function signature and collect all the information
00121     positional, vararg_var, kwarg_var, defaults = inspect.getargspec(func)
00122     defaults = defaults or ()
00123     arg_count = len(positional)
00124     arguments = []
00125     for idx, name in enumerate(positional):
00126         if isinstance(name, list):
00127             raise TypeError('cannot parse functions that unpack tuples '
00128                             'in the function signature')
00129         try:
00130             default = defaults[idx - arg_count]
00131         except IndexError:
00132             param = (name, False, None)
00133         else:
00134             param = (name, True, default)
00135         arguments.append(param)
00136     arguments = tuple(arguments)
00137 
00138     def parse(args, kwargs):
00139         new_args = []
00140         missing = []
00141         extra = {}
00142 
00143         # consume as many arguments as positional as possible
00144         for idx, (name, has_default, default) in enumerate(arguments):
00145             try:
00146                 new_args.append(args[idx])
00147             except IndexError:
00148                 try:
00149                     new_args.append(kwargs.pop(name))
00150                 except KeyError:
00151                     if has_default:
00152                         new_args.append(default)
00153                     else:
00154                         missing.append(name)
00155             else:
00156                 if name in kwargs:
00157                     extra[name] = kwargs.pop(name)
00158 
00159         # handle extra arguments
00160         extra_positional = args[arg_count:]
00161         if vararg_var is not None:
00162             new_args.extend(extra_positional)
00163             extra_positional = ()
00164         if kwargs and not kwarg_var is not None:
00165             extra.update(kwargs)
00166             kwargs = {}
00167 
00168         return new_args, kwargs, missing, extra, extra_positional, \
00169                arguments, vararg_var, kwarg_var
00170     _signature_cache[func] = parse
00171     return parse
00172 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.support.werkzeug._internal._patch_wrapper (   old,
  new 
) [private]
Helper function that forwards all the function details to the
decorated function.

Definition at line 173 of file _internal.py.

00173 
00174 def _patch_wrapper(old, new):
00175     """Helper function that forwards all the function details to the
00176     decorated function."""
00177     try:
00178         new.__name__ = old.__name__
00179         new.__module__ = old.__module__
00180         new.__doc__ = old.__doc__
00181         new.__dict__ = old.__dict__
00182     except:
00183         pass
00184     return new
00185 

Here is the caller graph for this function:

Definition at line 90 of file _internal.py.

00090 
00091 def _proxy_repr(cls):
00092     def proxy_repr(self):
00093         return '%s(%s)' % (self.__class__.__name__, cls.__repr__(self))
00094     return proxy_repr
00095 


Variable Documentation

Definition at line 20 of file _internal.py.

Definition at line 19 of file _internal.py.

Definition at line 87 of file _internal.py.

Definition at line 21 of file _internal.py.

Definition at line 240 of file _internal.py.

Definition at line 24 of file _internal.py.