Check expiration date instead of the expired flag (#394)

This commit is contained in:
Frédéric Péters 2011-04-22 12:25:24 +02:00
parent d5ebf4fe07
commit 7e61a8f1d7
1 changed files with 10 additions and 1 deletions

View File

@ -16,6 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
from datetime import datetime
from quixote import get_request, get_publisher
from quixote.errors import AccessError
@ -97,4 +99,11 @@ def is_locked():
return get_boolean_quota('x-asec-locked')
def is_expired():
return get_boolean_quota('x-asec-expired')
t = get_request().get_header('x-asec-expiration-date')
if not t:
return False
try:
expiration_date = datetime.strptime(t, '%Y-%m-%dT%H:%M:%S.%f')
except ValueError:
return False
return expiration_date < datetime.now()