Some minor additions to the "performance speedup". Extends the list of authors, too.

This commit is contained in:
Jannis Leidel 2011-08-15 12:53:29 +02:00
parent 49eb36775b
commit 09ece4a5e3
4 changed files with 21 additions and 7 deletions

14
AUTHORS Normal file
View file

@ -0,0 +1,14 @@
Alen Mujezinovic
Alex Gaynor
Alex Kamedov
Alexander Artemenko
Arne Brodowski
David Paccoud
Diego Búrigo Zacarão
Jannis Leidel
Jason Mayfield
Kevin Mooney
Matt Dorn
Oliver George
Stephan Peijnik <spe@anexia.at>, ANEXIA Internetdienstleistungs GmbH, http://www.anexia.at/
Zhang Kun

View file

@ -1,3 +0,0 @@
Author: Stephan Peijnik <spe@anexia.at>
ANEXIA Internetdienstleistungs GmbH
http://www.anexia.at/

View file

@ -23,7 +23,7 @@ class Loader(BaseLoader):
# The logic should work like this:
# * Try to find the template in the cache. If found, return it.
# * Now check the cache if a lookup for the given template
# has failed lately and hand over control to the next template
# has failed lately and hand over control to the next template
# loader waiting in line.
# * If this still did not fail we first try to find a site-specific
# template in the database.
@ -53,11 +53,11 @@ class Loader(BaseLoader):
raise TemplateDoesNotExist(template_name)
except:
raise TemplateDoesNotExist(template_name)
# Not marked as not-found, move on...
try:
template = Template.objects.get(name__exact=template_name,
template = Template.objects.get(name__exact=template_name,
sites__in=[site.id])
return set_and_return(cache_key, template.content, display_name)
except Template.DoesNotExist:

View file

@ -15,13 +15,16 @@ def get_cache_key(name):
current_site = Site.objects.get_current()
return 'dbtemplates::%s::%s' % (name, current_site.pk)
def get_cache_notfound_key(name):
return get_cache_key(name)+'::notfound'
return get_cache_key(name) + '::notfound'
def remove_notfound_key(instance):
# Remove notfound key as soon as we save the template.
cache.delete(get_cache_notfound_key(instance.name))
def set_and_return(cache_key, content, display_name):
# Save in cache backend explicitly if manually deleted or invalidated
if cache: