RedwoodAdmin/RedwoodResources — pull request #1 by marmphco (2014-06-08 22:44:29+00:00)
Title: changed URL_PREFIX in config.json to /redwood

The keys that the redwood router uses to store data in Redis are harcoded into the source. For example, the key used to store the period for subject 1 in session 2 is stored like:

“ period:redwood:2:1” = “period_number”

However, the Django component queries Redis like this (from redwood/expecon/views.py):

def session_experiment(request, session, subject):
session = get_object_or_404(Session, pk=session)
r = redis.Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)
instance = settings.URL_PREFIX.strip('/')
period = r.get('period:%s:%s:%s' % (instance, session.id, subject))
if not period or period == "0":
page = get_object_or_404(session.experiment.page_set, name='Wait')
else:
page_name = r.get('page:%s:%s:%s' % (instance, session.id, subject))
page = get_object_or_404(session.experiment.page_set, name=page_name)
return HttpResponse(page.render(context_instance=RequestContext(request)))

If URL_PREFIX is empty, then the resulting Redis query will be “period::2:1”, which will return an empty result. So the subject ends up being shown the “Wait” page over and over.

settings.URL_PREFIX is read from the config.json file in apache.tar.gz. Previously it was set to ""; with this change it is "/redwood".

Have a nice day :)