Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for django context settings

  • Loading branch information...
commit 3f2ab0777add5ca1d0b45333d569efb43e7ba397 1 parent 0f1b99e
@heynemann heynemann authored
Showing with 12 additions and 1 deletion.
  1. +1 −0  .gitignore
  2. +11 −1 django_pyvows/context.py
View
1  .gitignore
@@ -9,3 +9,4 @@
dist/
.project
.pydevproject
+build/
View
12 django_pyvows/context.py
@@ -10,6 +10,7 @@
import os
import re
+from threading import local, current_thread
from pyvows import Vows
from django.http import HttpRequest
@@ -31,15 +32,24 @@ def start_environment(cls, settings_path):
os.environ['DJANGO_SETTINGS_MODULE'] = settings_path
settings_tracker.install()
+
def __init__(self, parent):
super(DjangoContext, self).__init__(parent)
- self.settings = {}
self.ignore('get_settings', 'template', 'request', 'model', 'url', 'find_in_parent',
'start_environment', 'port', 'host', 'get_url', 'get', 'post')
+
+ @property
+ def settings(self):
+ thread = current_thread()
+ if not hasattr(thread, "settings"):
+ thread.settings = local()
+ return thread.settings
+
def setup(self):
DjangoContext.start_environment(self.get_settings())
+
def get_settings(self):
if 'DJANGO_SETTINGS_MODULE' in os.environ:
return os.environ['DJANGO_SETTINGS_MODULE']
Please sign in to comment.
Something went wrong with that request. Please try again.