PKå‹û4r.‡°>>paste/__init__.pyimport pkg_resources pkg_resources.declare_namespace('paste') PKŒû4Üæ3ØØpaste/__init__.pyc;ò ¯>ÉDc@sdkZeidƒdS(Nspaste(s pkg_resourcessdeclare_namespace(s pkg_resources((s,build/bdist.linux-i686/egg/paste/__init__.pys?s PKå‹û4 ¸__paste/deploy/converters.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php def asbool(obj): if isinstance(obj, (str, unicode)): obj = obj.strip().lower() if obj in ['true', 'yes', 'on', 'y', 't', '1']: return True elif obj in ['false', 'no', 'off', 'n', 'f', '0']: return False else: raise ValueError( "String is not true/false: %r" % obj) return bool(obj) def aslist(obj, sep=None, strip=True): if isinstance(obj, (str, unicode)): lst = obj.split(sep) if strip: lst = [v.strip() for v in lst] return lst elif isinstance(obj, (list, tuple)): return obj elif obj is None: return [] else: return [obj] PKå‹û4>Õ±!W!Wpaste/deploy/loadwsgi.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php import os import re import sys import urllib from ConfigParser import ConfigParser import pkg_resources from paste.deploy.util.fixtypeerror import fix_call __all__ = ['loadapp', 'loadserver', 'loadfilter', 'appconfig'] ############################################################ ## Utility functions ############################################################ def import_string(s): return pkg_resources.EntryPoint.parse("x="+s).load(False) def _aslist(obj): """ Turn object into a list; lists and tuples are left as-is, None becomes [], and everything else turns into a one-element list. """ if obj is None: return [] elif isinstance(obj, (list, tuple)): return obj else: return [obj] def _flatten(lst): """ Flatten a nested list. """ if not isinstance(lst, (list, tuple)): return [lst] result = [] for item in lst: result.extend(_flatten(item)) return result class NicerConfigParser(ConfigParser): def __init__(self, filename, *args, **kw): ConfigParser.__init__(self, *args, **kw) self.filename = filename def _interpolate(self, section, option, rawval, vars): try: return ConfigParser._interpolate( self, section, option, rawval, vars) except Exception, e: args = list(e.args) args[0] = 'Error in file %s, [%s] %s=%r: %s' % ( self.filename, section, option, rawval, e) e.args = tuple(args) raise ############################################################ ## Object types ############################################################ class _ObjectType(object): name = None egg_protocols = None config_prefixes = None def __init__(self): # Normalize these variables: self.egg_protocols = map(_aslist, _aslist(self.egg_protocols)) self.config_prefixes = map(_aslist, _aslist(self.config_prefixes)) def __repr__(self): return '<%s protocols=%r prefixes=%r>' % ( self.name, self.egg_protocols, self.config_prefixes) def invoke(self, context): assert context.protocol in _flatten(self.egg_protocols) return fix_call(context.object, context.global_conf, **context.local_conf) class _App(_ObjectType): name = 'application' egg_protocols = ['paste.app_factory', 'paste.composite_factory', 'paste.composit_factory'] config_prefixes = [['app', 'application'], ['composite', 'composit'], 'pipeline', 'filter-app'] def invoke(self, context): if context.protocol in ('paste.composit_factory', 'paste.composite_factory'): return fix_call(context.object, context.loader, context.global_conf, **context.local_conf) elif context.protocol == 'paste.app_factory': return fix_call(context.object, context.global_conf, **context.local_conf) else: assert 0, "Protocol %r unknown" % context.protocol APP = _App() class _Filter(_ObjectType): name = 'filter' egg_protocols = [['paste.filter_factory', 'paste.filter_app_factory']] config_prefixes = ['filter'] def invoke(self, context): if context.protocol == 'paste.filter_factory': return fix_call(context.object, context.global_conf, **context.local_conf) elif context.protocol == 'paste.filter_app_factory': def filter_wrapper(wsgi_app): # This should be an object, so it has a nicer __repr__ return fix_call(context.object, wsgi_app, context.global_conf, **context.local_conf) return filter_wrapper else: assert 0, "Protocol %r unknown" % context.protocol FILTER = _Filter() class _Server(_ObjectType): name = 'server' egg_protocols = [['paste.server_factory', 'paste.server_runner']] config_prefixes = ['server'] def invoke(self, context): if context.protocol == 'paste.server_factory': return fix_call(context.object, context.global_conf, **context.local_conf) elif context.protocol == 'paste.server_runner': def server_wrapper(wsgi_app): # This should be an object, so it has a nicer __repr__ return fix_call(context.object, wsgi_app, context.global_conf, **context.local_conf) return server_wrapper else: assert 0, "Protocol %r unknown" % context.protocol SERVER = _Server() # Virtual type: (@@: There's clearly something crufty here; # this probably could be more elegant) class _PipeLine(_ObjectType): name = 'pipeline' def invoke(self, context): app = context.app_context.create() filters = [c.create() for c in context.filter_contexts] filters.reverse() for filter in filters: app = filter(app) return app PIPELINE = _PipeLine() class _FilterApp(_ObjectType): name = 'filter_app' def invoke(self, context): next_app = context.next_context.create() filter = context.filter_context.create() return filter(next_app) FILTER_APP = _FilterApp() class _FilterWith(_App): name = 'filtered_with' def invoke(self, context): filter = context.filter_context.create() filtered = context.next_context.create() if context.next_context.object_type is APP: return filter(filtered) else: # filtering a filter def composed(app): return filter(filtered(app)) return composed FILTER_WITH = _FilterWith() ############################################################ ## Loaders ############################################################ def loadapp(uri, name=None, **kw): return loadobj(APP, uri, name=name, **kw) def loadfilter(uri, name=None, **kw): return loadobj(FILTER, uri, name=name, **kw) def loadserver(uri, name=None, **kw): return loadobj(SERVER, uri, name=name, **kw) def appconfig(uri, name=None, relative_to=None, global_conf=None): context = loadcontext(APP, uri, name=name, relative_to=relative_to, global_conf=global_conf) return context.config() _loaders = {} def loadobj(object_type, uri, name=None, relative_to=None, global_conf=None): context = loadcontext( object_type, uri, name=name, relative_to=relative_to, global_conf=global_conf) return context.create() def loadcontext(object_type, uri, name=None, relative_to=None, global_conf=None): if '#' in uri: if name is None: uri, name = uri.split('#', 1) else: # @@: Ignore fragment or error? uri = uri.split('#', 1)[0] if name is None: name = 'main' scheme, path = uri.split(':', 1) scheme = scheme.lower() if scheme not in _loaders: raise LookupError( "URI scheme not known: %r (from %s)" % (scheme, ', '.join(_loaders.keys()))) return _loaders[scheme]( object_type, uri, path, name=name, relative_to=relative_to, global_conf=global_conf) def _loadconfig(object_type, uri, path, name, relative_to, global_conf): # De-Windowsify the paths: path = path.replace('\\', '/') absolute_path = True if sys.platform == 'win32': _absolute_re = re.compile(r'^[a-zA-Z]:') if not _absolute_re.search(path): absolute_path = False else: if not path.startswith('/'): absolute_path = False if not absolute_path: if not relative_to: raise ValueError( "Cannot resolve relative uri %r; no context keyword " "argument given" % uri) relative_to = relative_to.replace('\\', '/') if relative_to.endswith('/'): path = relative_to + path else: path = relative_to + '/' + path if path.startswith('///'): path = path[2:] path = urllib.unquote(path) loader = ConfigLoader(path) return loader.get_context(object_type, name, global_conf) _loaders['config'] = _loadconfig def _loadegg(object_type, uri, spec, name, relative_to, global_conf): loader = EggLoader(spec) return loader.get_context(object_type, name, global_conf) _loaders['egg'] = _loadegg ############################################################ ## Loaders ############################################################ class _Loader(object): def get_app(self, name=None, global_conf=None): return self.app_context( name=name, global_conf=global_conf).create() def get_filter(self, name=None, global_conf=None): return self.filter_context( name=name, global_conf=global_conf).create() def get_server(self, name=None, global_conf=None): return self.server_context( name=name, global_conf=global_conf).create() def app_context(self, name=None, global_conf=None): return self.get_context( APP, name=name, global_conf=global_conf) def filter_context(self, name=None, global_conf=None): return self.get_context( FILTER, name=name, global_conf=global_conf) def server_context(self, name=None, global_conf=None): return self.get_context( SERVER, name=name, global_conf=global_conf) _absolute_re = re.compile(r'^[a-zA-Z]+:') def absolute_name(self, name): """ Returns true if the name includes a scheme """ if name is None: return False return self._absolute_re.search(name) class ConfigLoader(_Loader): def __init__(self, filename): self.filename = filename self.parser = NicerConfigParser(self.filename) # Don't lower-case keys: self.parser.optionxform = str # Stupid ConfigParser ignores files that aren't found, so # we have to add an extra check: if not os.path.exists(filename): raise OSError( "File %s not found" % filename) self.parser.read(filename) self.parser._defaults.setdefault( 'here', os.path.dirname(os.path.abspath(filename))) self.parser._defaults.setdefault( '__file__', os.path.abspath(filename)) def get_context(self, object_type, name=None, global_conf=None): if self.absolute_name(name): return loadcontext(object_type, name, relative_to=os.path.dirname(self.filename), global_conf=global_conf) section = self.find_config_section( object_type, name=name) if global_conf is None: global_conf = {} else: global_conf = global_conf.copy() defaults = self.parser.defaults() global_conf.update(defaults) local_conf = {} global_additions = {} get_from_globals = {} for option in self.parser.options(section): if option.startswith('set '): name = option[4:].strip() global_additions[name] = global_conf[name] = ( self.parser.get(section, option)) elif option.startswith('get '): name = option[4:].strip() get_from_globals[name] = self.parser.get(section, option) else: if option in defaults: # @@: It's a global option (?), so skip it continue local_conf[option] = self.parser.get(section, option) for local_var, glob_var in get_from_globals.items(): local_conf[local_var] = global_conf[glob_var] if object_type in (APP, FILTER) and 'filter-with' in local_conf: filter_with = local_conf.pop('filter-with') else: filter_with = None if 'require' in local_conf: for spec in local_conf['require'].split(): pkg_resources.require(spec) del local_conf['require'] if section.startswith('filter-app:'): context = self._filter_app_context( object_type, section, name=name, global_conf=global_conf, local_conf=local_conf, global_additions=global_additions) elif section.startswith('pipeline:'): context = self._pipeline_app_context( object_type, section, name=name, global_conf=global_conf, local_conf=local_conf, global_additions=global_additions) elif 'use' in local_conf: context = self._context_from_use( object_type, local_conf, global_conf, global_additions, section) else: context = self._context_from_explicit( object_type, local_conf, global_conf, global_additions, section) if filter_with is not None: filter_with_context = LoaderContext( obj=None, object_type=FILTER_WITH, protocol=None, global_conf=None, local_conf=None, loader=self) filter_with_context.filter_context = self.filter_context( name=filter_with, global_conf=global_conf) filter_with_context.next_context = context return filter_with_context return context def _context_from_use(self, object_type, local_conf, global_conf, global_additions, section): use = local_conf.pop('use') context = self.get_context( object_type, name=use, global_conf=global_conf) context.global_conf.update(global_additions) context.local_conf.update(local_conf) # @@: Should loader be overwritten? context.loader = self return context def _context_from_explicit(self, object_type, local_conf, global_conf, global_addition, section): possible = [] for protocol_options in object_type.egg_protocols: for protocol in protocol_options: if protocol in local_conf: possible.append((protocol, local_conf[protocol])) break if len(possible) > 1: raise LookupError( "Multiple protocols given in section %r: %s" % (section, possible)) if not possible: raise LookupError( "No loader given in section %r" % section) found_protocol, found_expr = possible[0] del local_conf[found_protocol] value = import_string(found_expr) context = LoaderContext( value, object_type, found_protocol, global_conf, local_conf, self) return context def _filter_app_context(self, object_type, section, name, global_conf, local_conf, global_additions): if 'next' not in local_conf: raise LookupError( "The [%s] section in %s is missing a 'next' setting" % (section, self.filename)) next_name = local_conf.pop('next') context = LoaderContext(None, FILTER_APP, None, global_conf, local_conf, self) context.next_context = self.get_context( APP, next_name, global_conf) if 'use' in local_conf: context.filter_context = self._context_from_use( FILTER, local_conf, global_conf, global_additions, section) else: context.filter_context = self._context_from_explicit( FILTER, local_conf, global_conf, global_additions, section) return context def _pipeline_app_context(self, object_type, section, name, global_conf, local_conf, global_additions): if 'pipeline' not in local_conf: raise LookupError( "The [%s] section in %s is missing a 'pipeline' setting" % (section, self.filename)) pipeline = local_conf.pop('pipeline').split() if local_conf: raise LookupError( "The [%s] pipeline section in %s has extra " "(disallowed) settings: %s" % (', '.join(local_conf.keys()))) context = LoaderContext(None, PIPELINE, None, global_conf, local_conf, self) context.app_context = self.get_context( APP, pipeline[-1], global_conf) context.filter_contexts = [ self.get_context(FILTER, name, global_conf) for name in pipeline[:-1]] return context def find_config_section(self, object_type, name=None): """ Return the section name with the given name prefix (following the same pattern as ``protocol_desc`` in ``config``. It must have the given name, or for ``'main'`` an empty name is allowed. The prefix must be followed by a ``:``. Case is *not* ignored. """ possible = [] for name_options in object_type.config_prefixes: for name_prefix in name_options: found = self._find_sections( self.parser.sections(), name_prefix, name) if found: possible.extend(found) break if not possible: raise LookupError( "No section %r (prefixed by %s) found in config %s" % (name, ' or '.join(map(repr, _flatten(object_type.config_prefixes))), self.filename)) if len(possible) > 1: raise LookupError( "Ambiguous section names %r for section %r (prefixed by %s) " "found in config %s" % (possible, name, ' or '.join(map(repr, _flatten(object_type.config_prefixes))), self.filename)) return possible[0] def _find_sections(self, sections, name_prefix, name): found = [] if name is None: if name_prefix in sections: found.append(name_prefix) name = 'main' for section in sections: if section.startswith(name_prefix+':'): if section[len(name_prefix)+1:].strip() == name: found.append(section) return found class EggLoader(_Loader): def __init__(self, spec): self.spec = spec def get_context(self, object_type, name=None, global_conf=None): if self.absolute_name(name): return loadcontext(object_type, name, global_conf=global_conf) entry_point, protocol, ep_name = self.find_egg_entry_point( object_type, name=name) return LoaderContext( entry_point, object_type, protocol, global_conf or {}, {}, self, distribution=pkg_resources.get_distribution(self.spec), entry_point_name=ep_name) def find_egg_entry_point(self, object_type, name=None): """ Returns the (entry_point, protocol) for the with the given ``name``. """ if name is None: name = 'main' possible = [] for protocol_options in object_type.egg_protocols: for protocol in protocol_options: pkg_resources.require(self.spec) entry = pkg_resources.get_entry_info( self.spec, protocol, name) if entry is not None: possible.append((entry.load(), protocol, entry.name)) break if not possible: # Better exception dist = pkg_resources.get_distribution(self.spec) raise LookupError( "Entry point %r not found in egg %r (dir: %s; protocols: %s; " "entry_points: %s)" % (name, self.spec, dist.location, ', '.join(_flatten(object_type.egg_protocols)), ', '.join(_flatten([ (pkg_resources.get_entry_info(self.spec, prot, name) or {}).keys() for prot in protocol_options] or '(no entry points)')))) if len(possible) > 1: raise LookupError( "Ambiguous entry points for %r in egg %r (protocols: %s)" % (name, self.spec, ', '.join(_flatten(protocol_options)))) return possible[0] class LoaderContext(object): def __init__(self, obj, object_type, protocol, global_conf, local_conf, loader, distribution=None, entry_point_name=None): self.object = obj self.object_type = object_type self.protocol = protocol #assert protocol in _flatten(object_type.egg_protocols), ( # "Bad protocol %r; should be one of %s" # % (protocol, ', '.join(map(repr, _flatten(object_type.egg_protocols))))) self.global_conf = global_conf self.local_conf = local_conf self.loader = loader self.distribution = distribution self.entry_point_name = entry_point_name def create(self): return self.object_type.invoke(self) def config(self): conf = AttrDict(self.global_conf) conf.update(self.local_conf) conf.local_conf = self.local_conf conf.global_conf = self.global_conf conf.context = self return conf class AttrDict(dict): """ A dictionary that can be assigned to. """ pass PKå‹û4ëÕ]ÉÉ paste/deploy/paster_templates.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php import os from paste.script.templates import Template class PasteDeploy(Template): _template_dir = 'paster_templates/paste_deploy' summary = "A web application deployed through paste.deploy" egg_plugins = ['PasteDeploy'] required_templates = ['PasteScript#basic_package'] def post(self, command, output_dir, vars): for prereq in ['PasteDeploy']: command.insert_into_file( os.path.join(output_dir, 'setup.py'), 'Extra requirements', '%r,\n' % prereq, indent=True) command.insert_into_file( os.path.join(output_dir, 'setup.py'), 'Entry points', (' [paste.app_factory]\n' ' main = %(package)s.wsgiapp:make_app\n') % vars, indent=False) if command.verbose: print '*'*72 print '* Run "paster serve docs/devel_config.ini" to run the sample application' print '* on http://localhost:8080' print '*'*72 PKå‹û4³j>Qbbpaste/deploy/__init__.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php from loadwsgi import * try: from config import CONFIG except ImportError: # @@: Or should we require Paste? Or should we put threadlocal # into this package too? pass PKå‹û4Ùt}¬eepaste/deploy/interfaces.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php ############################################################ ## Functions ############################################################ def loadapp(uri, name=None, relative_to=None, global_conf=None): """ Provided by ``paste.deploy.loadapp``. Load the specified URI as a WSGI application (returning IWSGIApp). The ``name`` can be in the URI (typically as ``#name``). If it is and ``name`` is given, the keyword argument overrides the URI. If the URI contains a relative filename, then ``relative_to`` is used (if ``relative_to`` is not provided, then it is an error). ``global_conf`` is used to load the configuration (additions override the values). ``global_conf`` is copied before modifying. """ def loadfilter(uri, name=None, relative_to=None, global_conf=None): """ Provided by ``paste.deploy.loadfilter``. Like ``loadapp()``, except returns in IFilter object. """ def loadserver(uri, name=None, relative_to=None, global_conf=None): """ Provided by ``paste.deploy.loadserver``. Like ``loadapp()``, except returns in IServer object. """ ############################################################ ## Factories ############################################################ class IPasteAppFactory: """ This is the spec for the ``paste.app_factory`` protocol/entry_point. """ def __call__(global_conf, **local_conf): """ Returns a WSGI application (IWSGIAPP) given the global configuration and the local configuration passed in as keyword arguments. All keys are strings, but values in local_conf may not be valid Python identifiers (if you use ``**kw`` you can still capture these values). """ class IPasteCompositFactory: """ This is the spec for the ``paste.composit_factory`` protocol/entry_point. This also produces WSGI applications, like ``paste.app_factory``, but is given more access to the context in which it is loaded. """ def __call__(loader, global_conf, **local_conf): """ Like IPasteAppFactory this returns a WSGI application (IWSGIApp). The ``loader`` value conforms to the ``ILoader`` interface, and can be used to load (contextually) more applications. """ class IPasteFilterFactory: """ This is the spec for the ``paste.filter_factory`` protocol/entry_point. """ def __call__(global_conf, **local_conf): """ Returns a IFilter object. """ class IPasteFilterAppFactory: """ This is the spec for the ``paste.filter_app_factory`` protocol/entry_point. """ def __call__(wsgi_app, global_conf, **local_conf): """ Returns a WSGI application that wraps ``wsgi_app``. Note that paste.deploy creates a wrapper for these objects that implement the IFilter interface. """ class IPasteServerFactory: """ This is the spec for the ``paste.server_factory`` protocol/entry_point. """ def __call__(global_conf, **local_conf): """ Returns a IServer object. """ class IPasteServerRunner: """ This is the spec for the ``paste.server_runner`` protocol/entry_point. """ def __call__(wsgi_app, global_conf, **local_conf): """ Serves the given WSGI application. May serve once, many times, forever; nothing about how the server works is specified here. Note that paste.deploy creates a wrapper for these objects that implement the IServer interface. """ class ILoader: """ This is an object passed into ``IPasteCompositFactory``. It is currently implemented in ``paste.deploy.loadwsgi`` by ``ConfigLoader`` and ``EggLoader``. """ def get_app(name_or_uri, global_conf=None): """ Return an IWSGIApp object. If the loader supports named applications, then you can use a simple name; otherwise you must use a full URI. Any global configuration you pass in will be added; you should generally pass through the global configuration you received. """ def get_filter(name_or_uri, global_conf=None): """ Return an IFilter object, like ``get_app``. """ def get_server(name_or_uri, global_conf=None): """ Return an IServer object, like ``get_app``. """ ############################################################ ## Objects ############################################################ class IWSGIApp: """ This is an application that conforms to `PEP 333 `_: Python Web Server Gateway Interface v1.0 """ def __call__(environ, start_response): """ Calls ``start_response(status_code, header_list)`` and returns an iterator for the body of the response. """ class IFilter: """ A filter is a simple case of middleware, where an object wraps a single WSGI application (IWSGIApp). """ def __call__(wsgi_app): """ Returns an IWSGIApp object, typically one that wraps the ``wsgi_app`` passed in. """ class IServer: """ A simple server interface. """ def __call__(wsgi_app): """ Serves the given WSGI application. May serve once, many times, forever; nothing about how the server works is specified here. """ PKå‹û4‰Hœ@ªªpaste/deploy/config.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php import threading import re # Loaded lazily wsgilib = None local = None __all__ = ['DispatchingConfig', 'CONFIG', 'ConfigMiddleware', 'PrefixMiddleware'] def local_dict(): global config_local, local try: return config_local.wsgi_dict except NameError: from paste.deploy.util.threadinglocal import local config_local = local() config_local.wsgi_dict = result = {} return result except AttributeError: config_local.wsgi_dict = result = {} return result class DispatchingConfig(object): """ This is a configuration object that can be used globally, imported, have references held onto. The configuration may differ by thread (or may not). Specific configurations are registered (and deregistered) either for the process or for threads. """ # @@: What should happen when someone tries to add this # configuration to itself? Probably the conf should become # resolved, and get rid of this delegation wrapper _constructor_lock = threading.Lock() def __init__(self): self._constructor_lock.acquire() try: self.dispatching_id = 0 while 1: self._local_key = 'paste.processconfig_%i' % self.dispatching_id if not local_dict().has_key(self._local_key): break self.dispatching_id += 1 finally: self._constructor_lock.release() self._process_configs = [] def push_thread_config(self, conf): """ Make ``conf`` the active configuration for this thread. Thread-local configuration always overrides process-wide configuration. This should be used like:: conf = make_conf() dispatching_config.push_thread_config(conf) try: ... do stuff ... finally: dispatching_config.pop_thread_config(conf) """ local_dict().setdefault(self._local_key, []).append(conf) def pop_thread_config(self, conf=None): """ Remove a thread-local configuration. If ``conf`` is given, it is checked against the popped configuration and an error is emitted if they don't match. """ self._pop_from(local_dict()[self._local_key], conf) def _pop_from(self, lst, conf): popped = lst.pop() if conf is not None and popped is not conf: raise AssertionError( "The config popped (%s) is not the same as the config " "expected (%s)" % (popped, conf)) def push_process_config(self, conf): """ Like push_thread_config, but applies the configuration to the entire process. """ self._process_configs.append(conf) def pop_process_config(self, conf=None): self._pop_from(self._process_configs, conf) def __getattr__(self, attr): conf = self.current_conf() if conf is None: raise AttributeError( "No configuration has been registered for this process " "or thread") return getattr(conf, attr) def current_conf(self): thread_configs = local_dict().get(self._local_key) if thread_configs: return thread_configs[-1] elif self._process_configs: return self._process_configs[-1] else: return None def __getitem__(self, key): # I thought __getattr__ would catch this, but apparently not conf = self.current_conf() if conf is None: raise TypeError( "No configuration has been registered for this process " "or thread") return conf[key] def __contains__(self, key): # I thought __getattr__ would catch this, but apparently not return self.has_key(key) def __setitem__(self, key, value): # I thought __getattr__ would catch this, but apparently not conf = self.current_conf() conf[key] = value CONFIG = DispatchingConfig() class ConfigMiddleware(object): """ A WSGI middleware that adds a ``paste.config`` key to the request environment, as well as registering the configuration temporarily (for the length of the request) with ``paste.CONFIG``. """ def __init__(self, application, config): """ This delegates all requests to `application`, adding a *copy* of the configuration `config`. """ self.application = application self.config = config def __call__(self, environ, start_response): global wsgilib if wsgilib is None: import pkg_resources pkg_resources.require('Paste') from paste import wsgilib conf = environ['paste.config'] = self.config.copy() app_iter = None CONFIG.push_thread_config(conf) try: app_iter = self.application(environ, start_response) finally: if app_iter is None: # An error occurred... CONFIG.pop_thread_config(conf) if type(app_iter) in (list, tuple): # Because it is a concrete iterator (not a generator) we # know the configuration for this thread is no longer # needed: CONFIG.pop_thread_config(conf) return app_iter else: def close_config(): CONFIG.pop_thread_config(conf) new_app_iter = wsgilib.add_close(app_iter, close_config) return new_app_iter def make_config_filter(app, global_conf, **local_conf): conf = global_conf.copy() conf.update(local_conf) return ConfigMiddleware(app, conf) class PrefixMiddleware(object): """Translate a given prefix into a SCRIPT_NAME for the filtered application.""" def __init__(self, app, global_conf=None, prefix='/'): self.app = app self.prefix = prefix self.regprefix = re.compile("^%s(.*)$" % self.prefix) def __call__(self, environ, start_response): url = environ['PATH_INFO'] url = re.sub(self.regprefix, r'\1', url) if not url: url = '/' environ['PATH_INFO'] = url environ['SCRIPT_NAME'] = self.prefix return self.app(environ, start_response) PKŒû4ý诽ÖÖpaste/deploy/converters.pyc;ò ¯>ÉDc@sd„Zeed„ZdS(cCs˜t|ttfƒot|iƒiƒ}|ddddddgjotSqŠ|ddd d d d gjotSqŠtd |ƒ‚nt |ƒSdS(Nstruesyessonsysts1sfalsesnosoffsnsfs0sString is not true/false: %r( s isinstancesobjsstrsunicodesstripslowersTruesFalses ValueErrorsbool(sobj((s5build/bdist.linux-i686/egg/paste/deploy/converters.pysasboolscCs£t|ttfƒoO|i|ƒ}|o1gi}|D]}||iƒƒq:~}n|Sn;t|t t fƒo|Sn|t jogSn|gSdS(N(s isinstancesobjsstrsunicodessplitssepslstsstripsappends_[1]svsliststuplesNone(sobjssepsstripsvs_[1]slst((s5build/bdist.linux-i686/egg/paste/deploy/converters.pysaslists1 N(sasboolsNonesTruesaslist(saslistsasbool((s5build/bdist.linux-i686/egg/paste/deploy/converters.pys?s PKŒû4 ¾,êYpYppaste/deploy/loadwsgi.pyc;ò ¯>ÉDc@sRdkZdkZdkZdkZdklZdkZdklZddddgZd„Z d„Z d „Z d efd „ƒYZ d e fd „ƒYZdefd„ƒYZeƒZdefd„ƒYZeƒZdefd„ƒYZeƒZdefd„ƒYZeƒZdefd„ƒYZeƒZdefd„ƒYZeƒZed„Zed„Zed„Zeeed„ZhZ eeed„Z!eeed„Z"d „Z#e#e d!|tjogSn&t|ttfƒo|Sn|gSdS(s‹ Turn object into a list; lists and tuples are left as-is, None becomes [], and everything else turns into a one-element list. N(sobjsNones isinstancesliststuple(sobj((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_aslists  cCsTt|ttfƒ o |gSng}x!|D]}|it|ƒƒq/W|SdS(s Flatten a nested list. N(s isinstanceslstsliststuplesresultsitemsextends_flatten(slstsitemsresult((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_flatten s sNicerConfigParsercBstZd„Zd„ZRS(NcOs ti|||Ž||_dS(N(s ConfigParsers__init__sselfsargsskwsfilename(sselfsfilenamesargsskw((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys__init__-scCszyti|||||ƒSWnVtj oJ}t |i ƒ}d|i ||||f|d(sselfsnames egg_protocolssconfig_prefixes(sself((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys__repr__KscCs=|it|iƒjpt‚t|i|i|i SdS(N( scontextsprotocols_flattensselfs egg_protocolssAssertionErrorsfix_callsobjects global_confs local_conf(sselfscontext((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysinvokeOs  ( s__name__s __module__sNonesnames egg_protocolssconfig_prefixess__init__s__repr__sinvoke(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys _ObjectType@s   s_AppcBsDtZdZdddgZddgddgdd gZd „ZRS( Ns applicationspaste.app_factoryspaste.composite_factoryspaste.composit_factorysapps compositescompositspipelines filter-appcCs‚|iddfjo#t|i|i|i|iSnF|idjot|i|i|iSndptd|i‚dS(Nspaste.composit_factoryspaste.composite_factoryspaste.app_factoryisProtocol %r unknown(scontextsprotocolsfix_callsobjectsloaders global_confs local_confsAssertionError(sselfscontext((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysinvoke\s  (s__name__s __module__snames egg_protocolssconfig_prefixessinvoke(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_AppTss_FiltercBs/tZdZddggZdgZd„ZRS(Nsfilterspaste.filter_factoryspaste.filter_app_factorycsmˆidjotˆiˆiˆiSn=ˆidjo‡d†}|Sndptdˆi‚dS(Nspaste.filter_factoryspaste.filter_app_factorycs tˆi|ˆiˆiSdS(N(sfix_callscontextsobjectswsgi_apps global_confs local_conf(swsgi_app(scontext(s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysfilter_wrapperss isProtocol %r unknown(scontextsprotocolsfix_callsobjects global_confs local_confsfilter_wrappersAssertionError(sselfscontextsfilter_wrapper((scontexts3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysinvokens  (s__name__s __module__snames egg_protocolssconfig_prefixessinvoke(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_Filteris s_ServercBs/tZdZddggZdgZd„ZRS(Nsserverspaste.server_factoryspaste.server_runnercsmˆidjotˆiˆiˆiSn=ˆidjo‡d†}|Sndptdˆi‚dS(Nspaste.server_factoryspaste.server_runnercs tˆi|ˆiˆiSdS(N(sfix_callscontextsobjectswsgi_apps global_confs local_conf(swsgi_app(scontext(s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysserver_wrapperˆs isProtocol %r unknown(scontextsprotocolsfix_callsobjects global_confs local_confsserver_wrappersAssertionError(sselfscontextsserver_wrapper((scontexts3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysinvokeƒs  (s__name__s __module__snames egg_protocolssconfig_prefixessinvoke(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_Server~s s _PipeLinecBstZdZd„ZRS(NspipelinecCsn|iiƒ}gi}|iD]}||iƒƒq ~}|i ƒx|D]}||ƒ}qPW|SdS(N( scontexts app_contextscreatesappsappends_[1]sfilter_contextsscsfilterssreversesfilter(sselfscontextsfilterscsfilterss_[1]sapp((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysinvoke˜s0 (s__name__s __module__snamesinvoke(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys _PipeLine•ss _FilterAppcBstZdZd„ZRS(Ns filter_appcCs,|iiƒ}|iiƒ}||ƒSdS(N(scontexts next_contextscreatesnext_appsfilter_contextsfilter(sselfscontextsfiltersnext_app((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysinvoke¥s(s__name__s __module__snamesinvoke(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys _FilterApp¢ss _FilterWithcBstZdZd„ZRS(Ns filtered_withcsV|iiƒ‰|iiƒ‰|iitjoˆˆƒSn‡‡d†}|SdS(Ncsˆˆ|ƒƒSdS(N(sfiltersfilteredsapp(sapp(sfiltersfiltered(s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pyscomposed¶s( scontextsfilter_contextscreatesfilters next_contextsfiltereds object_typesAPPscomposed(sselfscontextscomposedsfiltersfiltered((sfiltersfiltereds3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysinvoke¯s (s__name__s __module__snamesinvoke(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys _FilterWith¬scKstt|d||SdS(Nsname(sloadobjsAPPsurisnameskw(surisnameskw((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysloadappÀscKstt|d||SdS(Nsname(sloadobjsFILTERsurisnameskw(surisnameskw((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys loadfilterÃscKstt|d||SdS(Nsname(sloadobjsSERVERsurisnameskw(surisnameskw((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys loadserverÆsc Cs/tt|d|d|d|ƒ}|iƒSdS(Nsnames relative_tos global_conf(s loadcontextsAPPsurisnames relative_tos global_confscontextsconfig(surisnames relative_tos global_confscontext((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys appconfigÉs c Cs/t||d|d|d|ƒ}|iƒSdS(Nsnames relative_tos global_conf(s loadcontexts object_typesurisnames relative_tos global_confscontextscreate(s object_typesurisnames relative_tos global_confscontext((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysloadobjÑs c Csëd|joC|tjo|iddƒ\}}qP|iddƒd}n|tjo d}n|iddƒ\}}|iƒ}|tjo)td|di ti ƒƒfƒ‚nt||||d|d |d |ƒSdS( Ns#iismains:s"URI scheme not known: %r (from %s)s, snames relative_tos global_conf(surisnamesNonessplitsschemespathslowers_loaderss LookupErrorsjoinskeyss object_types relative_tos global_conf(s object_typesurisnames relative_tos global_confspathsscheme((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys loadcontextØs      ) c Cs'|iddƒ}t}tidjo.tidƒ}|i |ƒ o t }qqn|i dƒ o t }n| o^| ot d|ƒ‚n|iddƒ}|idƒo||}q×|d|}n|i dƒo|d}nti|ƒ}t|ƒ}|i|||ƒSdS(Ns\s/swin32s ^[a-zA-Z]:sACannot resolve relative uri %r; no context keyword argument givens///i(spathsreplacesTrues absolute_pathssyssplatformsrescompiles _absolute_ressearchsFalses startswiths relative_tos ValueErrorsurisendswithsurllibsunquotes ConfigLoadersloaders get_contexts object_typesnames global_conf( s object_typesurispathsnames relative_tos global_confs _absolute_res absolute_pathsloader((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys _loadconfigís(  sconfigcCs#t|ƒ}|i|||ƒSdS(N(s EggLoadersspecsloaders get_contexts object_typesnames global_conf(s object_typesurisspecsnames relative_tos global_confsloader((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_loadegg s seggs_LoadercBsztZeed„Zeed„Zeed„Zeed„Zeed„Zeed„Ze i dƒZ d„Z RS( NcCs |id|d|ƒiƒSdS(Nsnames global_conf(sselfs app_contextsnames global_confscreate(sselfsnames global_conf((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysget_appscCs |id|d|ƒiƒSdS(Nsnames global_conf(sselfsfilter_contextsnames global_confscreate(sselfsnames global_conf((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys get_filterscCs |id|d|ƒiƒSdS(Nsnames global_conf(sselfsserver_contextsnames global_confscreate(sselfsnames global_conf((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys get_server scCs|itd|d|ƒSdS(Nsnames global_conf(sselfs get_contextsAPPsnames global_conf(sselfsnames global_conf((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys app_context$scCs|itd|d|ƒSdS(Nsnames global_conf(sselfs get_contextsFILTERsnames global_conf(sselfsnames global_conf((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysfilter_context(scCs|itd|d|ƒSdS(Nsnames global_conf(sselfs get_contextsSERVERsnames global_conf(sselfsnames global_conf((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysserver_context,ss ^[a-zA-Z]+:cCs)|tjotSn|ii|ƒSdS(s< Returns true if the name includes a scheme N(snamesNonesFalsesselfs _absolute_ressearch(sselfsname((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys absolute_name1s ( s__name__s __module__sNonesget_apps get_filters get_servers app_contextsfilter_contextsserver_contextsrescompiles _absolute_res absolute_name(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_Loaderss ConfigLoadercBsYtZd„Zeed„Zd„Zd„Zd„Zd„Zed„Z d„Z RS( NcCs³||_t|iƒ|_t|i_tii|ƒ ot d|ƒ‚n|ii |ƒ|ii i dtii tii|ƒƒƒ|ii i dtii|ƒƒdS(NsFile %s not foundsheres__file__(sfilenamesselfsNicerConfigParsersparsersstrs optionxformsosspathsexistssOSErrorsreads _defaultss setdefaultsdirnamesabspath(sselfsfilename((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys__init__;s  .c CsC|i|ƒo,t||dtii|iƒd|ƒSn|i |d|ƒ}|t jo h}n |i ƒ}|iiƒ}|i|ƒh} h}h}xÉ|ii|ƒD]µ}|idƒo5|diƒ}|ii||ƒ||<||t d||di ttt|iƒƒƒ|ifƒ‚n|dSdS(s/ Return the section name with the given name prefix (following the same pattern as ``protocol_desc`` in ``config``. It must have the given name, or for ``'main'`` an empty name is allowed. The prefix must be followed by a ``:``. Case is *not* ignored. s1No section %r (prefixed by %s) found in config %ss or isMAmbiguous section names %r for section %r (prefixed by %s) found in config %siN(spossibles object_typesconfig_prefixess name_optionss name_prefixsselfs_find_sectionssparserssectionssnamesfoundsextends LookupErrorsjoinsmapsreprs_flattensfilenameslen(sselfs object_typesnamespossibles name_optionssfounds name_prefix((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysfind_config_sectionÝs   ;>cCsžg}|tjo(||jo|i|ƒnd}nxX|D]P}|i|dƒo6|t|ƒdi ƒ|jo|i|ƒq’qBqBW|SdS(Nsmains:i( sfoundsnamesNones name_prefixssectionssappendssections startswithslensstrip(sselfssectionss name_prefixsnamesfoundssection((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys_find_sectionsýs   !( s__name__s __module__s__init__sNones get_contexts_context_from_uses_context_from_explicits_filter_app_contexts_pipeline_app_contextsfind_config_sections_find_sections(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys ConfigLoader9s F    s EggLoadercBs,tZd„Zeed„Zed„ZRS(NcCs ||_dS(N(sspecsself(sselfsspec((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys__init__ sc Cs|i|ƒot||d|ƒSn|i|d|ƒ\}}}t ||||phh|dt i |i ƒd|ƒSdS(Ns global_confsnames distributionsentry_point_name(sselfs absolute_namesnames loadcontexts object_types global_confsfind_egg_entry_points entry_pointsprotocolsep_names LoaderContexts pkg_resourcessget_distributionsspec(sselfs object_typesnames global_confsprotocolsep_names entry_point((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys get_contexts  c Cs”|tjo d}ng}x{|iD]p}xg|D]_}ti|i ƒti |i ||ƒ}|tj o$|i |iƒ||ifƒPq4q4Wq'W| o£ti|i ƒ} td||i | idit|iƒƒditgi }|D]/}|ti |i ||ƒphiƒƒqö~pdƒƒfƒ‚nt|ƒdjo/td||i dit|ƒƒfƒ‚n|dSdS( s^ Returns the (entry_point, protocol) for the with the given ``name``. smainsMEntry point %r not found in egg %r (dir: %s; protocols: %s; entry_points: %s)s, s(no entry points)is7Ambiguous entry points for %r in egg %r (protocols: %s)iN(snamesNonespossibles object_types egg_protocolssprotocol_optionssprotocols pkg_resourcessrequiresselfsspecsget_entry_infosentrysappendsloadsget_distributionsdists LookupErrorslocationsjoins_flattens_[1]sprotskeysslen( sselfs object_typesnamesprotsprotocolspossibles_[1]sprotocol_optionssentrysdist((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysfind_egg_entry_points*       ‘ /(s__name__s __module__s__init__sNones get_contextsfind_egg_entry_point(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys EggLoader s s LoaderContextcBs)tZeed„Zd„Zd„ZRS(Nc CsL||_||_||_||_||_||_||_||_ dS(N( sobjsselfsobjects object_typesprotocols global_confs local_confsloaders distributionsentry_point_name( sselfsobjs object_typesprotocols global_confs local_confsloaders distributionsentry_point_name((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys__init__Ds       cCs|ii|ƒSdS(N(sselfs object_typesinvoke(sself((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pyscreateSscCsHt|iƒ}|i|iƒ|i|_|i|_||_|SdS(N(sAttrDictsselfs global_confsconfsupdates local_confscontext(sselfsconf((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysconfigVs    (s__name__s __module__sNones__init__screatesconfig(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys LoaderContextBs sAttrDictcBstZdZRS(s/ A dictionary that can be assigned to. (s__name__s __module__s__doc__(((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pysAttrDict^s (+sossressyssurllibs ConfigParsers pkg_resourcesspaste.deploy.util.fixtypeerrorsfix_calls__all__s import_strings_aslists_flattensNicerConfigParsersobjects _ObjectTypes_AppsAPPs_FiltersFILTERs_ServersSERVERs _PipeLinesPIPELINEs _FilterApps FILTER_APPs _FilterWiths FILTER_WITHsNonesloadapps loadfilters loadservers appconfigs_loaderssloadobjs loadcontexts _loadconfigs_loadeggs_Loaders ConfigLoaders EggLoaders LoaderContextsdictsAttrDict('s FILTER_APPs_Filters_Apps_Servers ConfigLoaders loadfiltersFILTERs _FilterApps__all__s_loaderss LoaderContexts_aslistsurllibsres _FilterWiths_LoadersNicerConfigParsers loadservers EggLoadersloadobjs _ObjectTypes FILTER_WITHssyssloadapps _loadconfigs_loadeggs ConfigParsers _PipeLinesPIPELINEsossAPPs pkg_resourcess loadcontextsSERVERs import_strings_flattensAttrDictsfix_calls appconfig((s3build/bdist.linux-i686/egg/paste/deploy/loadwsgi.pys?sP                      #Ñ8PKŒû4™Sá÷÷!paste/deploy/paster_templates.pyc;ò ¯>ÉDc@s0dkZdklZdefd„ƒYZdS(N(sTemplates PasteDeploycBs/tZdZdZdgZdgZd„ZRS(Nspaster_templates/paste_deploys/A web application deployed through paste.deploys PasteDeploysPasteScript#basic_packagecCsšx=dgD]2}|itii|dƒdd|dtƒq W|itii|dƒdd|dt ƒ|i o dd GHd GHd GHdd GHndS( Ns PasteDeployssetup.pysExtra requirementss%r, sindents Entry pointssD [paste.app_factory] main = %(package)s.wsgiapp:make_app s*iHsH* Run "paster serve docs/devel_config.ini" to run the sample applications* on http://localhost:8080( sprereqscommandsinsert_into_filesosspathsjoins output_dirsTruesvarssFalsesverbose(sselfscommands output_dirsvarssprereq((s;build/bdist.linux-i686/egg/paste/deploy/paster_templates.pysposts    (s__name__s __module__s _template_dirssummarys egg_pluginssrequired_templatesspost(((s;build/bdist.linux-i686/egg/paste/deploy/paster_templates.pys PasteDeploys   (sosspaste.script.templatessTemplates PasteDeploy(s PasteDeploysossTemplate((s;build/bdist.linux-i686/egg/paste/deploy/paster_templates.pys?s  PKŒû4þ6Y)paste/deploy/__init__.pyc;ò ¯>ÉDc@s2dkTydklZWnej onXdS((s*(sCONFIGN(sloadwsgisconfigsCONFIGs ImportError(sCONFIG((s3build/bdist.linux-i686/egg/paste/deploy/__init__.pys?sPKŒû4²&ÞÄ&&paste/deploy/interfaces.pyc;ò ¯>ÉDc@søeeed„Zeeed„Zeeed„Zdfd„ƒYZdfd„ƒYZdfd„ƒYZd fd „ƒYZd fd „ƒYZd fd„ƒYZ dfd„ƒYZ dfd„ƒYZ dfd„ƒYZ dfd„ƒYZ dS(cCsdS(s Provided by ``paste.deploy.loadapp``. Load the specified URI as a WSGI application (returning IWSGIApp). The ``name`` can be in the URI (typically as ``#name``). If it is and ``name`` is given, the keyword argument overrides the URI. If the URI contains a relative filename, then ``relative_to`` is used (if ``relative_to`` is not provided, then it is an error). ``global_conf`` is used to load the configuration (additions override the values). ``global_conf`` is copied before modifying. N((surisnames relative_tos global_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysloadapps cCsdS(sm Provided by ``paste.deploy.loadfilter``. Like ``loadapp()``, except returns in IFilter object. N((surisnames relative_tos global_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys loadfilterscCsdS(sm Provided by ``paste.deploy.loadserver``. Like ``loadapp()``, except returns in IServer object. N((surisnames relative_tos global_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys loadserverssIPasteAppFactorycBstZdZd„ZRS(sR This is the spec for the ``paste.app_factory`` protocol/entry_point. cKsdS(sH Returns a WSGI application (IWSGIAPP) given the global configuration and the local configuration passed in as keyword arguments. All keys are strings, but values in local_conf may not be valid Python identifiers (if you use ``**kw`` you can still capture these values). N((s global_confs local_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__/s (s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIPasteAppFactory(s sIPasteCompositFactorycBstZdZd„ZRS(sá This is the spec for the ``paste.composit_factory`` protocol/entry_point. This also produces WSGI applications, like ``paste.app_factory``, but is given more access to the context in which it is loaded. cKsdS(sâ Like IPasteAppFactory this returns a WSGI application (IWSGIApp). The ``loader`` value conforms to the ``ILoader`` interface, and can be used to load (contextually) more applications. N((sloaders global_confs local_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__Ds(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIPasteCompositFactory:s sIPasteFilterFactorycBstZdZd„ZRS(sU This is the spec for the ``paste.filter_factory`` protocol/entry_point. cKsdS(s+ Returns a IFilter object. N((s global_confs local_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__Ss(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIPasteFilterFactoryLs sIPasteFilterAppFactorycBstZdZd„ZRS(sY This is the spec for the ``paste.filter_app_factory`` protocol/entry_point. cKsdS(s· Returns a WSGI application that wraps ``wsgi_app``. Note that paste.deploy creates a wrapper for these objects that implement the IFilter interface. N((swsgi_apps global_confs local_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call___s(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIPasteFilterAppFactoryXs sIPasteServerFactorycBstZdZd„ZRS(sU This is the spec for the ``paste.server_factory`` protocol/entry_point. cKsdS(s+ Returns a IServer object. N((s global_confs local_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__ns(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIPasteServerFactorygs sIPasteServerRunnercBstZdZd„ZRS(sT This is the spec for the ``paste.server_runner`` protocol/entry_point. cKsdS(s Serves the given WSGI application. May serve once, many times, forever; nothing about how the server works is specified here. Note that paste.deploy creates a wrapper for these objects that implement the IServer interface. N((swsgi_apps global_confs local_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__zs(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIPasteServerRunnerss sILoadercBs2tZdZed„Zed„Zed„ZRS(s« This is an object passed into ``IPasteCompositFactory``. It is currently implemented in ``paste.deploy.loadwsgi`` by ``ConfigLoader`` and ``EggLoader``. cCsdS(s9 Return an IWSGIApp object. If the loader supports named applications, then you can use a simple name; otherwise you must use a full URI. Any global configuration you pass in will be added; you should generally pass through the global configuration you received. N((s name_or_uris global_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysget_appŒscCsdS(s= Return an IFilter object, like ``get_app``. N((s name_or_uris global_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys get_filter–scCsdS(s= Return an IServer object, like ``get_app``. N((s name_or_uris global_conf((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys get_server›s(s__name__s __module__s__doc__sNonesget_apps get_filters get_server(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysILoader„s  sIWSGIAppcBstZdZd„ZRS(s™ This is an application that conforms to `PEP 333 `_: Python Web Server Gateway Interface v1.0 cCsdS(s‚ Calls ``start_response(status_code, header_list)`` and returns an iterator for the body of the response. N((senvironsstart_response((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__¬s(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIWSGIApp¤s sIFiltercBstZdZd„ZRS(sr A filter is a simple case of middleware, where an object wraps a single WSGI application (IWSGIApp). cCsdS(sj Returns an IWSGIApp object, typically one that wraps the ``wsgi_app`` passed in. N((swsgi_app((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__¹s(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIFilter²s sIServercBstZdZd„ZRS(s$ A simple server interface. cCsdS(s  Serves the given WSGI application. May serve once, many times, forever; nothing about how the server works is specified here. N((swsgi_app((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys__call__Ås(s__name__s __module__s__doc__s__call__(((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pysIServer¿s N(sNonesloadapps loadfilters loadserversIPasteAppFactorysIPasteCompositFactorysIPasteFilterFactorysIPasteFilterAppFactorysIPasteServerFactorysIPasteServerRunnersILoadersIWSGIAppsIFiltersIServer( s loadfiltersIFiltersIWSGIAppsIServersIPasteFilterFactorysIPasteServerRunnersIPasteServerFactorysIPasteCompositFactorysloadappsILoadersIPasteAppFactorysIPasteFilterAppFactorys loadserver((s5build/bdist.linux-i686/egg/paste/deploy/interfaces.pys?s     PKŒû4%™×ò#ò#paste/deploy/config.pyc;ò ¯>ÉDc@s‘dkZdkZeaeaddddgZd„Zdefd„ƒYZeƒZ defd„ƒYZ d„Z defd „ƒYZ dS( NsDispatchingConfigsCONFIGsConfigMiddlewaresPrefixMiddlewarecCsoy tiSWn]tj o.dklatƒaht_}|Sn%tj oht_}|SnXdS(N(slocal(s config_locals wsgi_dicts NameErrors paste.deploy.util.threadinglocalslocalsresultsAttributeError(sresult((s1build/bdist.linux-i686/egg/paste/deploy/config.pys local_dict s     cBsƒtZdZeiƒZd„Zd„Zed„Z d„Z d„Z ed„Z d„Z d„Zd „Zd „Zd „ZRS( s This is a configuration object that can be used globally, imported, have references held onto. The configuration may differ by thread (or may not). Specific configurations are registered (and deregistered) either for the process or for threads. cCs‚|iiƒzWd|_xGno?d|i|_tƒi|iƒ oPn|id7_q#WWd|iiƒXg|_dS(Niispaste.processconfig_%i( sselfs_constructor_locksacquiresdispatching_ids _local_keys local_dictshas_keysreleases_process_configs(sself((s1build/bdist.linux-i686/egg/paste/deploy/config.pys__init__)s  cCs#tƒi|igƒi|ƒdS(sŸ Make ``conf`` the active configuration for this thread. Thread-local configuration always overrides process-wide configuration. This should be used like:: conf = make_conf() dispatching_config.push_thread_config(conf) try: ... do stuff ... finally: dispatching_config.pop_thread_config(conf) N(s local_dicts setdefaultsselfs _local_keysappendsconf(sselfsconf((s1build/bdist.linux-i686/egg/paste/deploy/config.pyspush_thread_config6scCs|itƒ|i|ƒdS(s¹ Remove a thread-local configuration. If ``conf`` is given, it is checked against the popped configuration and an error is emitted if they don't match. N(sselfs _pop_froms local_dicts _local_keysconf(sselfsconf((s1build/bdist.linux-i686/egg/paste/deploy/config.pyspop_thread_configGscCsD|iƒ}|tj o ||j otd||fƒ‚ndS(NsBThe config popped (%s) is not the same as the config expected (%s)(slstspopspoppedsconfsNonesAssertionError(sselfslstsconfspopped((s1build/bdist.linux-i686/egg/paste/deploy/config.pys _pop_fromOs cCs|ii|ƒdS(sg Like push_thread_config, but applies the configuration to the entire process. N(sselfs_process_configssappendsconf(sselfsconf((s1build/bdist.linux-i686/egg/paste/deploy/config.pyspush_process_configWscCs|i|i|ƒdS(N(sselfs _pop_froms_process_configssconf(sselfsconf((s1build/bdist.linux-i686/egg/paste/deploy/config.pyspop_process_config^scCs:|iƒ}|tjotdƒ‚nt||ƒSdS(Ns?No configuration has been registered for this process or thread(sselfs current_confsconfsNonesAttributeErrorsgetattrsattr(sselfsattrsconf((s1build/bdist.linux-i686/egg/paste/deploy/config.pys __getattr__as  cCsItƒi|iƒ}|o |dSn|io|idSntSdS(Niÿÿÿÿ(s local_dictsgetsselfs _local_keysthread_configss_process_configssNone(sselfsthread_configs((s1build/bdist.linux-i686/egg/paste/deploy/config.pys current_confis   cCs5|iƒ}|tjotdƒ‚n||SdS(Ns?No configuration has been registered for this process or thread(sselfs current_confsconfsNones TypeErrorskey(sselfskeysconf((s1build/bdist.linux-i686/egg/paste/deploy/config.pys __getitem__rs  cCs|i|ƒSdS(N(sselfshas_keyskey(sselfskey((s1build/bdist.linux-i686/egg/paste/deploy/config.pys __contains__{scCs|iƒ}||| 12: v = v[:8]+'...'+v[-4:] return v def fix_call(callable, *args, **kw): """ Call ``callable(*args, **kw)`` fixing any type errors that come out. """ try: val = callable(*args, **kw) except TypeError: exc_info = fix_type_error(None, callable, args, kw) raise exc_info[0], exc_info[1], exc_info[2] return val PKå‹û4©ÞU6««paste/deploy/util/__init__.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # PKå‹û4 4‰YY#paste/deploy/util/threadinglocal.py# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php try: import threading except ImportError: # No threads, so "thread local" means process-global class local(object): pass else: try: local = threading.local except AttributeError: # Added in 2.4, but now we'll have to define it ourselves import thread class local(object): def __init__(self): self.__dict__['__objs'] = {} def __getattr__(self, attr, g=thread.get_ident): try: return self.__dict__['__objs'][g()][attr] except KeyError: raise AttributeError( "No variable %s defined for the thread %s" % (attr, g())) def __setattr__(self, attr, value, g=thread.get_ident): self.__dict__['__objs'].setdefault(g(), {})[attr] = value def __delattr__(self, attr, g=thread.get_ident): try: del self.__dict__['__objs'][g()][attr] except KeyError: raise AttributeError( "No variable %s defined for thread %s" % (attr, g())) PKŒû4ÂéÄX X "paste/deploy/util/fixtypeerror.pyc;ò ¯>ÉDc@s7dZdkZdkZd„Zd„Zd„ZdS(s^ Fixes the vague error message that you get when calling a function with the wrong arguments. Nc Csg|tjotiƒ}n|dtjp4t|dƒidƒdjpt|ddtƒo|Snt|d_ dk }|i |i |ƒŒ}ditt|ƒƒ}|o|o|d7}n|oX|iƒ}|iƒ|digi} |D]\}}| d|ƒq~ ƒ7}nd |} d |d| |f} | f|d_|SdS( sh Given an exception, this will test if the exception was due to a signature error, and annotate the error with better information if so. Usage:: try: val = callable(*args, **kw) except TypeError: exc_info = fix_type_error(None, callable, args, kw) raise exc_info[0], exc_info[1], exc_info[2] iis argumentsiÿÿÿÿs_type_error_fixedNs, s%s=...s(%s)s%s; got %s, wanted %s(sexc_infosNonessyss TypeErrorsstrsfindsgetattrsFalsesTrues_type_error_fixedsinspects formatargspecs getargspecscallablesargspecsjoinsmaps _short_reprsvarargssargsskwargssitemsssortsappends_[1]snsvsgotspecsmsg( sexc_infoscallablesvarargsskwargssinspectsargssvsargspecsnsmsgsgotspecs_[1]((s<build/bdist.linux-i686/egg/paste/deploy/util/fixtypeerror.pysfix_type_error s&  H    B cCsAt|ƒ}t|ƒdjo|d d|d}n|SdS(Ni is...iüÿÿÿ(sreprsvslen(sv((s<build/bdist.linux-i686/egg/paste/deploy/util/fixtypeerror.pys _short_repr-s cOs^y|||Ž}Wn@tj o4tt|||ƒ}|d|d|d‚nX|SdS(sR Call ``callable(*args, **kw)`` fixing any type errors that come out. iiiN(scallablesargsskwsvals TypeErrorsfix_type_errorsNonesexc_info(scallablesargsskwsvalsexc_info((s<build/bdist.linux-i686/egg/paste/deploy/util/fixtypeerror.pysfix_call3s(s__doc__sinspectssyssfix_type_errors _short_reprsfix_call(ssyssfix_type_errorsinspectsfix_calls _short_repr((s<build/bdist.linux-i686/egg/paste/deploy/util/fixtypeerror.pys?s    # PKŒû4Ð2@ªˆˆpaste/deploy/util/__init__.pyc;ò ¯>ÉDc@sdS(N((((s8build/bdist.linux-i686/egg/paste/deploy/util/__init__.pys?sPKŒû4,è?KK$paste/deploy/util/threadinglocal.pyc;ò ¯>ÉDc@sy dkZWn)ej odefd„ƒYZnDXy eiZWn2ej o&dkZdefd„ƒYZnXdS(NslocalcBstZRS(N(s__name__s __module__(((s>build/bdist.linux-i686/egg/paste/deploy/util/threadinglocal.pyslocalscBs>tZd„Zeid„Zeid„Zeid„ZRS(NcCsh|idbuild/bdist.linux-i686/egg/paste/deploy/util/threadinglocal.pys__init__scCsMy|id|ƒ|SWn,tj o td||ƒfƒ‚nXdS(Ns__objss(No variable %s defined for the thread %s(sselfs__dict__sgsattrsKeyErrorsAttributeError(sselfsattrsg((s>build/bdist.linux-i686/egg/paste/deploy/util/threadinglocal.pys __getattr__scCs$||idi|ƒhƒ|build/bdist.linux-i686/egg/paste/deploy/util/threadinglocal.pys __setattr__scCsLy|id|ƒ|=Wn,tj o td||ƒfƒ‚nXdS(Ns__objss$No variable %s defined for thread %s(sselfs__dict__sgsattrsKeyErrorsAttributeError(sselfsattrsg((s>build/bdist.linux-i686/egg/paste/deploy/util/threadinglocal.pys __delattr__ s(s__name__s __module__s__init__sthreads get_idents __getattr__s __setattr__s __delattr__(((s>build/bdist.linux-i686/egg/paste/deploy/util/threadinglocal.pyslocals (s threadings ImportErrorsobjectslocalsAttributeErrorsthread(sthreads threadingslocal((s>build/bdist.linux-i686/egg/paste/deploy/util/threadinglocal.pys?s   PKå‹û4΀jèèEpaste/deploy/paster_templates/paste_deploy/docs/devel_config.ini_tmpl[filter-app:main] # This puts the interactive debugger in place: use = egg:Paste#evalerror next = devel [app:devel] # This application is meant for interactive development use = egg:${project} debug = true # You can add other configuration values: greeting = Aloha! [app:test] # While this version of the configuration is for non-iteractive # tests (unit tests) use = devel [server:main] use = egg:PasteScript#wsgiutils # Change to 0.0.0.0 to make public: host = 127.0.0.1 port = 8080 PKŒû4cèvááEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: PasteDeploy Version: 0.9.6 Summary: Load, configure, and compose WSGI applications and servers Home-page: http://pythonpaste.org/deploy/ Author: Ian Bicking Author-email: ianb@colorstudy.com License: MIT Description: This tool provides code to load WSGI applications and servers from URIs; these URIs can refer to Python Eggs for INI-style configuration files. `Paste Script `_ provides commands to serve applications based on this configuration file. The latest version is available in a `Subversion repository `_. For the latest changes see the `news file `_. Keywords: web wsgi application server Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Python Software Foundation License Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Classifier: Topic :: Software Development :: Libraries :: Python Modules PKŒû4Ðq>>EGG-INFO/SOURCES.txtMANIFEST.in setup.cfg setup.py PasteDeploy.egg-info/PKG-INFO PasteDeploy.egg-info/SOURCES.txt PasteDeploy.egg-info/dependency_links.txt PasteDeploy.egg-info/entry_points.txt PasteDeploy.egg-info/namespace_packages.txt PasteDeploy.egg-info/not-zip-safe PasteDeploy.egg-info/requires.txt PasteDeploy.egg-info/top_level.txt docs/index.txt docs/license.txt docs/news.txt paste/__init__.py paste/deploy/__init__.py paste/deploy/config.py paste/deploy/converters.py paste/deploy/interfaces.py paste/deploy/loadwsgi.py paste/deploy/paster_templates.py paste/deploy/paster_templates/paste_deploy/+package+/sampleapp.py_tmpl paste/deploy/paster_templates/paste_deploy/+package+/wsgiapp.py_tmpl paste/deploy/paster_templates/paste_deploy/docs/devel_config.ini_tmpl paste/deploy/util/__init__.py paste/deploy/util/fixtypeerror.py paste/deploy/util/threadinglocal.py tests/conftest.py tests/fixture.py tests/test_basic_app.py tests/test_config.py tests/test_filter.py tests/test_load_package.py tests/fake_packages/FakeApp.egg/setup.py tests/fake_packages/FakeApp.egg/FakeApp.egg-info/PKG-INFO tests/fake_packages/FakeApp.egg/FakeApp.egg-info/entry_points.txt tests/fake_packages/FakeApp.egg/FakeApp.egg-info/top_level.txt tests/fake_packages/FakeApp.egg/fakeapp/__init__.py tests/fake_packages/FakeApp.egg/fakeapp/apps.py tests/fake_packages/FakeApp.egg/fakeapp/configapps.py tests/sample_configs/basic_app.ini tests/sample_configs/executable.ini tests/sample_configs/test_config.ini tests/sample_configs/test_config_included.ini tests/sample_configs/test_filter.ini tests/sample_configs/test_filter_with.ini PKŒû4“×2EGG-INFO/dependency_links.txt PKŒû4køYòòEGG-INFO/entry_points.txt [paste.filter_app_factory] config = paste.deploy.config:make_config_filter [Config] prefix = paste.deploy.config:PrefixMiddleware [paste.paster_create_template] paste_deploy=paste.deploy.paster_templates:PasteDeploy PKŒû4KŸÌEGG-INFO/namespace_packages.txtpaste PKŒû4“×2EGG-INFO/not-zip-safe PKŒû4U4æsEGG-INFO/requires.txt [Paste] Paste [Config] PKŒû4KŸÌEGG-INFO/top_level.txtpaste PKå‹û4r.‡°>>´paste/__init__.pyPKŒû4Üæ3ØØ´mpaste/__init__.pycPKå‹û4 ¸__´upaste/deploy/converters.pyPKå‹û4>Õ±!W!W´ paste/deploy/loadwsgi.pyPKå‹û4ëÕ]ÉÉ ´c\paste/deploy/paster_templates.pyPKå‹û4³j>Qbb´japaste/deploy/__init__.pyPKå‹û4Ùt}¬ee´cpaste/deploy/interfaces.pyPKå‹û4‰Hœ@ªª´Ÿypaste/deploy/config.pyPKŒû4ý诽ÖÖ´}“paste/deploy/converters.pycPKŒû4 ¾,êYpYp´Œ˜paste/deploy/loadwsgi.pycPKŒû4™Sá÷÷!´ paste/deploy/paster_templates.pycPKŒû4þ6Y)´Rpaste/deploy/__init__.pycPKŒû4²&ÞÄ&&´›paste/deploy/interfaces.pycPKŒû4%™×ò#ò#´é6paste/deploy/config.pycPKå‹û4˜\„'UU!´[paste/deploy/util/fixtypeerror.pyPKå‹û4©ÞU6««´¤bpaste/deploy/util/__init__.pyPKå‹û4 4‰YY#´Šcpaste/deploy/util/threadinglocal.pyPKŒû4ÂéÄX X "´$ipaste/deploy/util/fixtypeerror.pycPKŒû4Ð2@ªˆˆ´¼spaste/deploy/util/__init__.pycPKŒû4,è?KK$´€tpaste/deploy/util/threadinglocal.pycPKå‹û4΀jèèE´ }paste/deploy/paster_templates/paste_deploy/docs/devel_config.ini_tmplPKŒû4cèváá´XEGG-INFO/PKG-INFOPKŒû4Ðq>>´h„EGG-INFO/SOURCES.txtPKŒû4“×2´ØŠEGG-INFO/dependency_links.txtPKŒû4køYòò´‹EGG-INFO/entry_points.txtPKŒû4KŸÌ´=ŒEGG-INFO/namespace_packages.txtPKŒû4“×2´€ŒEGG-INFO/not-zip-safePKŒû4U4æs´´ŒEGG-INFO/requires.txtPKŒû4KŸÌ´EGG-INFO/top_level.txtPKW;