diff options
-rw-r--r-- | paste/deploy/__init__.py | 7 | ||||
-rw-r--r-- | paste/deploy/config.py | 4 | ||||
-rw-r--r-- | paste/deploy/util/__init__.py | 1 | ||||
-rw-r--r-- | paste/deploy/util/threadinglocal.py | 39 | ||||
-rw-r--r-- | setup.py | 2 |
5 files changed, 48 insertions, 5 deletions
diff --git a/paste/deploy/__init__.py b/paste/deploy/__init__.py index 5c83a6d..1677202 100644 --- a/paste/deploy/__init__.py +++ b/paste/deploy/__init__.py @@ -1,3 +1,8 @@ from loadwsgi import loadapp, loadfilter, loadserver -from config import CONFIG +try: + from config import CONFIG +except ImportError: + # @@: Or should we require Paste? Or should we put threadlocal + # into this package too? + pass diff --git a/paste/deploy/config.py b/paste/deploy/config.py index 23b811d..055a1c2 100644 --- a/paste/deploy/config.py +++ b/paste/deploy/config.py @@ -10,9 +10,7 @@ def local_dict(): try: return config_local.wsgi_dict except NameError: - import pkg_resources - pkg_resources.require('Paste>=0.1') - from paste.util.threadinglocal import local + from paste.deploy.util.threadinglocal import local config_local = local() config_local.wsgi_dict = result = {} return result diff --git a/paste/deploy/util/__init__.py b/paste/deploy/util/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/paste/deploy/util/__init__.py @@ -0,0 +1 @@ +# diff --git a/paste/deploy/util/threadinglocal.py b/paste/deploy/util/threadinglocal.py new file mode 100644 index 0000000..57afa17 --- /dev/null +++ b/paste/deploy/util/threadinglocal.py @@ -0,0 +1,39 @@ +# (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())) + @@ -31,7 +31,7 @@ files. }, zip_safe=False, extras_require={ - 'Config': ['Paste'], + 'Config': [], 'Paste': ['Paste'], }, entry_points=""" |