4
4
from django import forms
5
5
from django .core .exceptions import ValidationError
6
6
from django .core .validators import URLValidator
7
- from django .core .cache import cache
8
7
from django .db import models
9
8
from django .db import IntegrityError
10
9
from django .template .defaultfilters import filesizeformat
11
10
from django .utils .translation import ugettext_lazy as _
12
11
from django .utils .encoding import smart_unicode
12
+ from django .utils import importlib
13
13
14
14
from ixxy_url_field .choice_with_other import ChoiceWithOtherField
15
15
@@ -27,18 +27,11 @@ def formfield(self, **kwargs):
27
27
'form_class' : IxxyURLFormField ,
28
28
}
29
29
defaults .update (kwargs )
30
- cache_key = 'get_linklist_context'
31
- linklists = cache .get (cache_key )
32
- if not linklists :
33
- from cms .admin_views import get_linklist_context
34
- linklists = get_linklist_context ()
35
- cache .set (cache_key , linklists )
36
- choices = []
37
- keys = ['links' , 'documents' , 'secure_documents' , ]
38
- for key in keys :
39
- choices .extend ([(link [1 ], link [0 ]) for link in linklists [key ] or []])
40
- choices .append (['' , '' ])
41
-
30
+ from django .conf import settings
31
+ mod_path , func_name = settings .URL_CHOICES_FUNC .rsplit ('.' , 1 )
32
+ mod = importlib .import_module (mod_path )
33
+ choices_func = getattr (mod , func_name )
34
+ choices = choices_func ()
42
35
required = not self .blank
43
36
return ChoiceWithOtherField (choices = choices , required = required )
44
37
0 commit comments