summaryrefslogtreecommitdiff
path: root/routes/__init__.py
diff options
context:
space:
mode:
authorbbangert <none@none>2005-12-18 14:56:34 -0800
committerbbangert <none@none>2005-12-18 14:56:34 -0800
commitea4df47db6dc074dee228a2f5ec7ad5a2ba26292 (patch)
treefae36682911980a7cd67bbaa25cfb40830b723a9 /routes/__init__.py
parent8813b0be0583065ffd352b5abdaa10a1921d68b9 (diff)
downloadroutes-ea4df47db6dc074dee228a2f5ec7ad5a2ba26292.tar.gz
[svn] request_config can now handle a user-supplied thread/request local container which is assumed to be a callable
--HG-- branch : trunk
Diffstat (limited to 'routes/__init__.py')
-rw-r--r--routes/__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/routes/__init__.py b/routes/__init__.py
index ac5010b..b2eda10 100644
--- a/routes/__init__.py
+++ b/routes/__init__.py
@@ -22,7 +22,7 @@ else:
def __setattr__(self, name, value):
return self.__shared_state.__setattr__(name, value)
-def request_config():
+def request_config(original=False):
"""
Returns the Routes RequestConfig object.
@@ -54,7 +54,24 @@ def request_config():
Set to the WSGI environ for automatic prefix support if the
webapp is underneath a 'SCRIPT_NAME'
+ If you have your own request local object that you'd like to use instead of the default
+ thread local provided by Routes, you can configure Routes to use it::
+
+ from routes import request_config()
+ config = request_config()
+ if hasattr(config, 'using_request_local'):
+ config.request_local = YourLocalCallable
+ config = request_config()
+
+ Once you have configured request_config, its advisable you retrieve it again to get the
+ object you wanted. The variable you assign to request_local is assumed to be a callable
+ that will get the local config object you wish.
"""
+ obj = _RequestConfig()
+ if hasattr(obj, 'request_local') and original is False:
+ return getattr(obj, 'request_local')()
+ else:
+ obj.using_request_local = False
return _RequestConfig()
from base import Mapper