summaryrefslogtreecommitdiffstats
path: root/public/views.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-19 10:37:14 -0600
committerDan McGee <dan@archlinux.org>2013-01-19 10:37:16 -0600
commit23ef118ac129e17d251634d2ef3c88c6d74279e3 (patch)
tree3fb5eac4a8e06e27dc45aab1a8d16d9a53da7217 /public/views.py
parent721f092e4a36a58da2f701973521fb087a977693 (diff)
downloadarchweb-23ef118ac129e17d251634d2ef3c88c6d74279e3.tar.gz
archweb-23ef118ac129e17d251634d2ef3c88c6d74279e3.zip
Don't redefine mirror_url function every call
If we pull this out and define it at the top level once, we save the interpreter a fair amount of work. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'public/views.py')
-rw-r--r--public/views.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/public/views.py b/public/views.py
index 3c823c9d..22cb8759 100644
--- a/public/views.py
+++ b/public/views.py
@@ -76,6 +76,16 @@ def donate(request):
return render(request, 'public/donate.html', context)
+def _mirror_urls():
+ '''In order to ensure this is lazily evaluated since we can't do
+ sorting at the database level, make it a callable.'''
+ urls = MirrorUrl.objects.select_related('mirror').filter(
+ protocol__default=True,
+ mirror__public=True, mirror__active=True, mirror__isos=True)
+ sort_by = attrgetter('country.name', 'mirror.name')
+ return sorted(urls, key=sort_by)
+
+
@cache_control(max_age=300)
def download(request):
try:
@@ -83,20 +93,11 @@ def download(request):
except Release.DoesNotExist:
release = None
- def mirror_urls():
- '''In order to ensure this is lazily evaluated since we can't do
- sorting at the database level, make it a callable.'''
- urls = MirrorUrl.objects.select_related('mirror').filter(
- protocol__default=True,
- mirror__public=True, mirror__active=True, mirror__isos=True)
- sort_by = attrgetter('country.name', 'mirror.name')
- return sorted(urls, key=sort_by)
-
context = {
'release': release,
'releng_iso_url': settings.ISO_LIST_URL,
'releng_pxeboot_url': settings.PXEBOOT_URL,
- 'mirror_urls': mirror_urls,
+ 'mirror_urls': _mirror_urls,
}
return render(request, 'public/download.html', context)