Browse files

Django pyvows FIXED

  • Loading branch information...
1 parent 5c90b4e commit d26f1de0dbe5b4269cba17a9faac4ec34da8df69 @heynemann heynemann committed Mar 9, 2012
Showing with 35 additions and 37 deletions.
  1. +1 −1 Makefile
  2. +3 −6 django_pyvows/server.py
  3. +2 −2 django_pyvows/settings_manager.py
  4. +29 −28 vows/settings_vows.py
View
2 Makefile
@@ -1,5 +1,5 @@
pyvows: db
- @env PYTHONPATH=$$PYTHONPATH:vows/sandbox/:. pyvows --cover --cover_package=django_pyvows --cover_threshold=95 vows/settings_vows.py
+ @env PYTHONPATH=$$PYTHONPATH:vows/sandbox/:. pyvows --cover --cover_package=django_pyvows --cover_threshold=95 vows/
ci_test:
@env PYTHONPATH=$$PYTHONPATH:vows/sandbox/:. python vows/sandbox/manage.py syncdb && pyvows --no_color --cover --cover_package=django_pyvows --cover_threshold=100 -r django_pyvows.coverage.xml -x vows/
View
9 django_pyvows/server.py
@@ -16,10 +16,6 @@
from django.core.handlers.wsgi import WSGIHandler
-def make_response_thread(thread, settings):
- if not hasattr(thread, 'settings'):
- thread.settings = settings
-
def run_app(host, port):
server = wsgiserver.CherryPyWSGIServer(
(host, port),
@@ -51,9 +47,10 @@ def start(self, settings):
sleep(0.1)
for _thread in self.thr.server.requests._threads:
- _thread.settings = hasattr(_thread, 'settings') and _thread.settings or local()
+ _thread.settings = hasattr(_thread, 'settings') and _thread.settings or {}
for k, v in settings.iteritems():
- setattr(_thread.settings, k, v)
+ _thread.settings[k] = v
+ #setattr(_thread.settings, k, v)
View
4 django_pyvows/settings_manager.py
@@ -35,8 +35,8 @@ def __init__(self, original_settings):
def __getattr__(self, attr_name):
thread = current_thread()
if hasattr(thread, 'settings'):
- if hasattr(thread.settings, attr_name):
- return getattr(thread.settings, attr_name)
+ if attr_name in thread.settings:
+ return thread.settings[attr_name]
return getattr(self.original_settings, attr_name)
settings_tracker = SettingsTracker()
View
57 vows/settings_vows.py
@@ -23,50 +23,51 @@ class WhenIUseTheSettingsTracker(DjangoContext):
def topic(self):
settings_tracker.install()
- #class WhenImportFromDjangoConf(DjangoContext):
+ class WhenImportFromDjangoConf(DjangoContext):
- #def topic(self):
- #from django.conf import settings
- #return settings
+ def topic(self):
+ from django.conf import settings
+ return settings
- #def should_be_the_vows_settings(self, topic):
- #expect(topic).to_be_instance_of(VowsSettings)
+ def should_be_the_vows_settings(self, topic):
+ expect(topic).to_be_instance_of(VowsSettings)
- #class WhenIImportOnlyConfAndThenUseSettings(DjangoContext):
+ class WhenIImportOnlyConfAndThenUseSettings(DjangoContext):
- #def topic(self):
- #from django import conf
- #return conf.settings
+ def topic(self):
+ from django import conf
+ return conf.settings
- #def should_be_the_vows_settings(self, topic):
- #expect(topic).to_be_instance_of(VowsSettings)
+ def should_be_the_vows_settings(self, topic):
+ expect(topic).to_be_instance_of(VowsSettings)
- #class WhenIImportTheCompletePathAndThenUseSettings(DjangoContext):
+ class WhenIImportTheCompletePathAndThenUseSettings(DjangoContext):
- #def topic(self):
- #import django.conf
- #return django.conf.settings
+ def topic(self):
+ import django.conf
+ return django.conf.settings
- #def should_be_the_vows_settings(self, topic):
- #expect(topic).to_be_instance_of(VowsSettings)
+ def should_be_the_vows_settings(self, topic):
+ expect(topic).to_be_instance_of(VowsSettings)
- #class CannotSayHelloWithoutName(DjangoHTTPContext):
+ class CannotSayHelloWithoutName(DjangoHTTPContext):
- #def topic(self):
- #self.settings.SAY_HELLO_WITHOUT_NAME = False
- #self.start_server(port=9000)
- #return self.get('/say/')
+ def topic(self):
+ self.start_server(port=9000, settings={
+ 'SAY_HELLO_WITHOUT_NAME': False
+ })
+
+ return self.get('/say/')
- #def should_be_ok(self, (topic, content)):
- #expect(topic.status).to_equal(200)
+ def should_be_ok(self, (topic, content)):
+ expect(topic.status).to_equal(200)
- #def should_ask_for_my_name(self, (topic, content)):
- #expect(content).to_equal("What's your name?")
+ def should_ask_for_my_name(self, (topic, content)):
+ expect(content).to_equal("What's your name?")
class SayHelloWithoutName(DjangoHTTPContext):
def topic(self):
- #self.settings.SAY_HELLO_WITHOUT_NAME = True
self.start_server(port=9001, settings={
'SAY_HELLO_WITHOUT_NAME': True
})

0 comments on commit d26f1de

Please sign in to comment.