summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-04-19 10:39:56 -0600
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-05-08 10:20:52 -0600
commit60b891ecb03184ac9d26039ba57466ad712d52b9 (patch)
tree30a4e845442e0aa1bcb7e0cc59ac4f7a06ff9767
parent7efa08b0d1d50aa48ccaa82314ba2231b56821dc (diff)
downloadaskbot-60b891ecb03184ac9d26039ba57466ad712d52b9.tar.gz
askbot-60b891ecb03184ac9d26039ba57466ad712d52b9.tar.bz2
askbot-60b891ecb03184ac9d26039ba57466ad712d52b9.zip
added fallback for update_media_revision
-rw-r--r--askbot/skins/utils.py36
1 files changed, 28 insertions, 8 deletions
diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py
index a07b1fa9..20c29669 100644
--- a/askbot/skins/utils.py
+++ b/askbot/skins/utils.py
@@ -3,7 +3,7 @@
the lookup resolution process for templates and media works as follows:
* look up item in selected skin
* if not found look in 'default'
-* raise an exception
+* raise an exception
"""
import os
import logging
@@ -56,7 +56,7 @@ def get_available_skins(selected=None):
#re-insert default as a last item
skins['default'] = default_dir
- skins['common'] = common_dir
+ skins['common'] = common_dir
return skins
@@ -71,7 +71,7 @@ def get_path_to_skin(skin):
return skin_dirs.get(skin, None)
def get_skin_choices():
- """returns a tuple for use as a set of
+ """returns a tuple for use as a set of
choices in the form"""
skin_names = list(reversed(get_available_skins().keys()))
return zip(skin_names, skin_names)
@@ -86,7 +86,7 @@ def resolve_skin_for_media(media=None, preferred_skin = None):
def get_media_url(url, ignore_missing = False):
"""returns url prefixed with the skin name
- of the first skin that contains the file
+ of the first skin that contains the file
directories are searched in this order:
askbot_settings.ASKBOT_DEFAULT_SKIN, then 'default', then 'commmon'
if file is not found - returns None
@@ -156,7 +156,7 @@ def get_media_url(url, ignore_missing = False):
url = django_settings.STATIC_URL + use_skin + '/media/' + url
url = os.path.normpath(url).replace('\\', '/')
-
+
if resource_revision:
url += '?v=%d' % resource_revision
@@ -174,7 +174,7 @@ def update_media_revision(skin = None):
if skin in get_skin_choices():
skin_path = get_path_to_skin(skin)
else:
- raise MediaNotFound('Skin %s not found' % skin)
+ raise MediaNotFound('Skin %s not found' % skin)
else:
skin = 'default'
skin_path = get_path_to_skin(askbot_settings.ASKBOT_DEFAULT_SKIN)
@@ -193,6 +193,26 @@ def update_media_revision(skin = None):
if current_hash != askbot_settings.MEDIA_RESOURCE_REVISION_HASH:
askbot_settings.update('MEDIA_RESOURCE_REVISION', resource_revision + 1)
- askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
+ askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
+ try:
+ askbot_settings.update('MEDIA_RESOURCE_REVISION', resource_revision + 1)
+ logging.debug('media revision worked for MEDIA_RESOURCE_REVISION')
+ except Exception, e:
+ logging.critical(e.message)
+ safe_settings_update('MEDIA_RESOURCE_REVISION', resource_revision + 1)
+
+ try:
+ askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
+ logging.debug('media revision worked for MEDIA_RESOURCE_REVISION_HASH')
+ except Exception, e:
+ logging.critical(e.message)
+ safe_settings_update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
logging.debug('MEDIA_RESOURCE_REVISION changed')
- askbot_settings.MEDIA_RESOURCE_REVISION
+
+
+def safe_settings_update(key, value):
+ '''Fallback when IntegrityError bug raises'''
+ from askbot.deps.livesettings.models import Setting
+ setting = Setting.objects.get(key=key)
+ setting.value = value
+ setting.save()