Fixed (again) django settings override

This commit is contained in:
Bernardo Heynemann 2012-03-12 21:56:57 -03:00
parent a1d4f938b5
commit cdf22222ad

View file

@ -41,16 +41,19 @@ class DjangoServer(object):
def start(self, settings): def start(self, settings):
self.thr = Thread(target=run_app, args=(self.host, self.port)) self.thr = Thread(target=run_app, args=(self.host, self.port))
self.thr.daemon = True self.thr.daemon = True
self.thr.settings = {}
for k, v in settings.iteritems():
self.thr.settings[k] = v
self.thr.start() self.thr.start()
while not len(self.thr.server.requests._threads): while not len(self.thr.server.requests._threads):
sleep(0.1) sleep(0.1)
for _thread in self.thr.server.requests._threads: for _thread in self.thr.server.requests._threads:
_thread.settings = hasattr(_thread, 'settings') and _thread.settings or {} _thread.settings = {}
for k, v in settings.iteritems(): for k, v in settings.iteritems():
_thread.settings[k] = v _thread.settings[k] = v
#setattr(_thread.settings, k, v)