From 7f722a40c41ce996fdf9d7b94669e9361eb891f9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 18 Sep 2011 01:07:00 +0000 Subject: [PATCH] deep copy config before manipulating it --- pandora/api/views.py | 3 ++- pandora/user/models.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora/api/views.py b/pandora/api/views.py index 9994a0ff..d8cc115b 100644 --- a/pandora/api/views.py +++ b/pandora/api/views.py @@ -3,6 +3,7 @@ from __future__ import division, with_statement import os +import copy from django.shortcuts import render_to_response from django.template import RequestContext @@ -54,7 +55,7 @@ def init(request): ''' #data = json.loads(request.POST['data']) response = json_response({}) - config = settings.CONFIG.copy() + config = copy.deepcopy(settings.CONFIG) del config['keys'] #is this needed? #populate max values for percent requests diff --git a/pandora/user/models.py b/pandora/user/models.py index 126a12df..76aeeabf 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 +import copy from datetime import datetime from django.contrib.auth.models import User @@ -29,7 +30,7 @@ class UserProfile(models.Model): def get_ui(self): ui = {} - config = settings.CONFIG.copy() + config = copy.deepcopy(settings.CONFIG) ui.update(config['user']['ui']) def updateUI(ui, new): ''' @@ -44,7 +45,7 @@ class UserProfile(models.Model): ui = updateUI(ui, self.ui) if not 'lists' in ui: ui['lists'] = {} - ui['lists'][''] = config['uiDefaults']['list'] + ui['lists'][''] = copy.deepcopy(config['user']['ui']['lists']['']) def add(lists, section): ids = []