Refresh API now flushes the cache as well

This commit is contained in:
2010-06-04 08:43:01 +01:00
parent c7aa1b16b2
commit 41d7a731e4
2 changed files with 3 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ from eve_api.app_defines import *
from eve_api.api_exceptions import APIAuthException, APINoUserIDException from eve_api.api_exceptions import APIAuthException, APINoUserIDException
from eve_api.models import EVEAccount, EVEPlayerCharacter, EVEPlayerCorporation from eve_api.models import EVEAccount, EVEPlayerCharacter, EVEPlayerCorporation
def import_eve_account(api_key, user_id): def import_eve_account(api_key, user_id, force_cache=False):
""" """
Imports an account from the API into the EVEAccount model. Imports an account from the API into the EVEAccount model.
""" """
@@ -27,7 +27,7 @@ def import_eve_account(api_key, user_id):
try: try:
account_doc = CachedDocument.objects.api_query('/account/Characters.xml.aspx', account_doc = CachedDocument.objects.api_query('/account/Characters.xml.aspx',
params=auth_params, params=auth_params,
no_cache=False) no_cache=force_cache)
except APIAuthException: except APIAuthException:
try: try:
account = EVEAccount.objects.get(id=user_id) account = EVEAccount.objects.get(id=user_id)

View File

@@ -128,7 +128,7 @@ def eveapi_refresh(request, userid=0):
except EVEAccount.DoesNotExist: except EVEAccount.DoesNotExist:
pass pass
else: else:
import_eve_account(acc.api_key, acc.api_user_id) import_eve_account(acc.api_key, acc.api_user_id, force_cache=True)
request.user.get_profile().update_access() request.user.get_profile().update_access()
request.user.message_set.create(message="Key %s has been refreshed from the EVE API." % acc.api_user_id) request.user.message_set.create(message="Key %s has been refreshed from the EVE API." % acc.api_user_id)