| 
				
			 | 
			
			
				@@ -49,28 +49,32 @@ class StringSetting(Setting): 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				49
			 | 
			
			
				 class EnumStringSetting(Setting): 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				50
			 | 
			
			
				     """Setting of a value which can only come from the given choices""" 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				51
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+    def _validate_selection(self, selection): 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+        if selection not in self.choices: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+            raise ValidationException('Invalid value: "{0}"'.format(selection)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				56
			 | 
			
			
				     def _post_init(self): 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				57
			 | 
			
			
				         if not hasattr(self, 'choices'): 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				58
			 | 
			
			
				             raise MissingArgumentException('Missing argument: choices') 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				-        if self.value != '' and self.value not in self.choices: 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-            raise ValidationException('Invalid default value: {0}'.format(self.value)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+        self._validate_selection(self.value) 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				60
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				59
			 | 
			
				61
			 | 
			
			
				     def parse(self, data): 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-        if data not in self.choices and data != self.value: 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-            raise ValidationException('Invalid choice: {0}'.format(data)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+        self._validate_selection(data) 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				63
			 | 
			
			
				         self.value = data 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				64
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				64
			 | 
			
				65
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				65
			 | 
			
				66
			 | 
			
			
				 class MultipleChoiceSetting(EnumStringSetting): 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				67
			 | 
			
			
				     """Setting of values which can only come from the given choices""" 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				68
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+    def _validate_selections(self, selections): 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+        for item in selections: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				+            if item not in self.choices: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+                raise ValidationException('Invalid value: "{0}"'.format(selections)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				74
			 | 
			
			
				     def _post_init(self): 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				75
			 | 
			
			
				         if not hasattr(self, 'choices'): 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				76
			 | 
			
			
				             raise MissingArgumentException('Missing argument: choices') 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-        for item in self.value: 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-            if item not in self.choices: 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-                raise ValidationException('Invalid default value: {0}'.format(self.value)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+        self._validate_selections(self.value) 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				78
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				75
			 | 
			
				79
			 | 
			
			
				     def parse(self, data): 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				80
			 | 
			
			
				         if data == '': 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -78,9 +82,7 @@ class MultipleChoiceSetting(EnumStringSetting): 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				82
			 | 
			
			
				             return 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				83
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				80
			 | 
			
				84
			 | 
			
			
				         elements = data.split(',') 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				-        for item in elements: 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-            if item not in self.choices: 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-                raise ValidationException('Invalid choice: {0}'.format(item)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+        self._validate_selections(elements) 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				86
			 | 
			
			
				         self.value = elements 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				87
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				86
			 | 
			
				88
			 | 
			
			
				     def parse_form(self, data): 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -214,9 +216,10 @@ class Preferences(object): 
			 | 
		
	
		
			
			| 
				214
			 | 
			
				216
			 | 
			
			
				         super(Preferences, self).__init__() 
			 | 
		
	
		
			
			| 
				215
			 | 
			
				217
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				216
			 | 
			
				218
			 | 
			
			
				         self.key_value_settings = {'categories': MultipleChoiceSetting(['general'], choices=categories), 
			 | 
		
	
		
			
			| 
				217
			 | 
			
				
			 | 
			
			
				-                                   'language': EnumStringSetting('all', choices=LANGUAGE_CODES), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				219
			 | 
			
			
				+                                   'language': EnumStringSetting(settings['search']['language'], 
			 | 
		
	
		
			
			| 
				
			 | 
			
				220
			 | 
			
			
				+                                                                 choices=LANGUAGE_CODES), 
			 | 
		
	
		
			
			| 
				218
			 | 
			
				221
			 | 
			
			
				                                    'locale': EnumStringSetting(settings['ui']['default_locale'], 
			 | 
		
	
		
			
			| 
				219
			 | 
			
				
			 | 
			
			
				-                                                               choices=settings['locales'].keys()), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				222
			 | 
			
			
				+                                                               choices=settings['locales'].keys() + ['']), 
			 | 
		
	
		
			
			| 
				220
			 | 
			
				223
			 | 
			
			
				                                    'autocomplete': EnumStringSetting(settings['search']['autocomplete'], 
			 | 
		
	
		
			
			| 
				221
			 | 
			
				224
			 | 
			
			
				                                                                      choices=autocomplete.backends.keys() + ['']), 
			 | 
		
	
		
			
			| 
				222
			 | 
			
				225
			 | 
			
			
				                                    'image_proxy': MapSetting(settings['server']['image_proxy'], 
			 |