* Use unicode_literals thoughout the package.
* Add indexes to '{}'.format(), unindexed version unsupported in Py2.6.
* Remove remnants of Python 2.5 support (Django 1.5 is required anyway).
* Stop relying on `hasattr` on OneToOneField, won't work on Python 3.2 + Django 1.6
(see https://code.djangoproject.com/ticket/21563).
13 files changed:
+from __future__ import unicode_literals
+
from django.conf import settings
__all__ = []
from django.conf import settings
__all__ = []
+from __future__ import unicode_literals
+
from django.contrib import admin
from .models import *
from django.contrib import admin
from .models import *
+from __future__ import unicode_literals
+
from lxml import etree
import collections
from lxml import etree
import collections
def jasig(auth_success, attrs):
attributes = etree.SubElement(auth_success, CAS + 'attributes')
style = etree.SubElement(attributes, CAS + 'attraStyle')
def jasig(auth_success, attrs):
attributes = etree.SubElement(auth_success, CAS + 'attributes')
style = etree.SubElement(attributes, CAS + 'attraStyle')
for name, value in sorted(attrs.items()):
if isinstance(value, collections.Iterable) and not isinstance(value, basestring):
for e in value:
for name, value in sorted(attrs.items()):
if isinstance(value, collections.Iterable) and not isinstance(value, basestring):
for e in value:
def ruby_cas(auth_success, attrs):
style = etree.SubElement(auth_success, CAS + 'attraStyle')
def ruby_cas(auth_success, attrs):
style = etree.SubElement(auth_success, CAS + 'attraStyle')
- style.text = u'RubyCAS'
for name, value in sorted(attrs.items()):
if isinstance(value, collections.Iterable) and not isinstance(value, basestring):
for e in value:
for name, value in sorted(attrs.items()):
if isinstance(value, collections.Iterable) and not isinstance(value, basestring):
for e in value:
def name_value(auth_success, attrs):
def name_value(auth_success, attrs):
- etree.SubElement(auth_success, CAS + 'attribute', name=u'attraStyle', value=u'Name-Value')
+ etree.SubElement(auth_success, CAS + 'attribute', name='attraStyle', value='Name-Value')
for name, value in sorted(attrs.items()):
if isinstance(value, collections.Iterable) and not isinstance(value, basestring):
for e in value:
for name, value in sorted(attrs.items()):
if isinstance(value, collections.Iterable) and not isinstance(value, basestring):
for e in value:
# -*- coding: utf-8 -*-
"""cas_provider.exceptions -- exceptions defined for CAS login workflows
"""
# -*- coding: utf-8 -*-
"""cas_provider.exceptions -- exceptions defined for CAS login workflows
"""
+from __future__ import unicode_literals
class SameEmailMismatchedPasswords(Exception): pass
class SameEmailMismatchedPasswords(Exception): pass
+from __future__ import unicode_literals
+
from django import forms
from django.utils.translation import ugettext_lazy as _
from django import forms
from django.utils.translation import ugettext_lazy as _
contains the actual logic for determining which accounts are deleted.
"""
contains the actual logic for determining which accounts are deleted.
"""
-from __future__ import print_function
+from __future__ import print_function, unicode_literals
from django.core.management.base import NoArgsCommand
from django.conf import settings
from django.core.management.base import NoArgsCommand
from django.conf import settings
+from __future__ import unicode_literals
+
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
except ImportError:
from urllib import urlencode
from urlparse import urlparse, ParseResult
except ImportError:
from urllib import urlencode
from urlparse import urlparse, ParseResult
- try:
- from urlparse import parse_qs
- except: # Python <2.6 compatibility
- from cgi import parse_qs
+ from urlparse import parse_qs
__all__ = ['ServiceTicket', 'LoginTicket', 'ProxyGrantingTicket', 'ProxyTicket', 'ProxyGrantingTicketIOU']
__all__ = ['ServiceTicket', 'LoginTicket', 'ProxyGrantingTicket', 'ProxyTicket', 'ProxyGrantingTicketIOU']
def _generate_ticket(self, length=ticket.max_length, chars=string.ascii_letters + string.digits):
""" Generates a random string of the requested length. Used for creation of tickets. """
def _generate_ticket(self, length=ticket.max_length, chars=string.ascii_letters + string.digits):
""" Generates a random string of the requested length. Used for creation of tickets. """
- return u"%s-%s" % (self.prefix, ''.join(Random().sample(chars, length - (len(self.prefix) + 1))))
+ return "%s-%s" % (self.prefix, ''.join(Random().sample(chars, length - (len(self.prefix) + 1))))
class ServiceTicket(BaseTicket):
class ServiceTicket(BaseTicket):
def __init__(self, *args, **kwargs):
if 'pgtiou' not in kwargs:
def __init__(self, *args, **kwargs):
if 'pgtiou' not in kwargs:
- kwargs['pgtiou'] = u"PGTIOU-%s" % (''.join(Random().sample(string.ascii_letters + string.digits, 50)))
+ kwargs['pgtiou'] = "PGTIOU-%s" % (''.join(Random().sample(string.ascii_letters + string.digits, 50)))
super(ProxyGrantingTicket, self).__init__(*args, **kwargs)
class Meta:
super(ProxyGrantingTicket, self).__init__(*args, **kwargs)
class Meta:
# -*- coding: utf-8 -*-
"""cas_provider.signals -- signal definitions for cas_provider
"""
# -*- coding: utf-8 -*-
"""cas_provider.signals -- signal definitions for cas_provider
"""
+from __future__ import unicode_literals
+
from django import dispatch
from django import dispatch
+from __future__ import unicode_literals
+
from django.conf.urls import patterns, url
from django.conf.urls import patterns, url
+from __future__ import unicode_literals
+
import logging
logger = logging.getLogger('cas_provider.views')
import logging
logger = logging.getLogger('cas_provider.views')
INTERNAL_ERROR = 'INTERNAL_ERROR'
ERROR_MESSAGES = (
INTERNAL_ERROR = 'INTERNAL_ERROR'
ERROR_MESSAGES = (
- (INVALID_TICKET, u'The provided ticket is invalid.'),
- (INVALID_SERVICE, u'Service is invalid'),
- (INVALID_REQUEST, u'Not all required parameters were sent.'),
- (INTERNAL_ERROR, u'An internal error occurred during ticket validation'),
+ (INVALID_TICKET, 'The provided ticket is invalid.'),
+ (INVALID_SERVICE, 'Service is invalid'),
+ (INVALID_REQUEST, 'Not all required parameters were sent.'),
+ (INTERNAL_ERROR, 'An internal error occurred during ticket validation'),
if pgt:
pgtIouId = pgt.pgtiou
if pgt:
pgtIouId = pgt.pgtiou
- if hasattr(ticket, 'proxyticket'):
- pgt = ticket.proxyticket.proxyGrantingTicket
+ try:
+ proxyTicket = ticket.proxyticket
+ except ProxyTicket.DoesNotExist:
+ pass
+ else:
+ pgt = proxyTicket.proxyGrantingTicket
# I am issued by this proxy granting ticket
while pgt.pgt is not None:
proxies += (pgt.service,)
# I am issued by this proxy granting ticket
while pgt.pgt is not None:
proxies += (pgt.service,)
urlopen(urlunsplit(uri))
except HTTPError as e:
if not e.code in proxy_callback_good_status:
urlopen(urlunsplit(uri))
except HTTPError as e:
if not e.code in proxy_callback_good_status:
- logger.debug('Checking Proxy Callback URL {} returned {}. Not issuing PGT.'.format(uri, e.code))
+ logger.debug('Checking Proxy Callback URL {0} returned {1}. Not issuing PGT.'.format(uri, e.code))
return
except URLError as e:
return
except URLError as e:
- logger.debug('Checking Proxy Callback URL {} raised URLError. Not issuing PGT.'.format(uri))
+ logger.debug('Checking Proxy Callback URL {0} raised URLError. Not issuing PGT.'.format(uri))
def _cas2_error_response(code, message=None):
def _cas2_error_response(code, message=None):
- return HttpResponse(u'''<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
+ return HttpResponse('''<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
<cas:authenticationFailure code="%(code)s">
%(message)s
</cas:authenticationFailure>
<cas:authenticationFailure code="%(code)s">
%(message)s
</cas:authenticationFailure>
+from __future__ import unicode_literals
+
+from __future__ import unicode_literals
+
# Django settings for xxx project.
DEBUG = True
# Django settings for xxx project.
DEBUG = True
+from __future__ import unicode_literals
+
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic import TemplateView
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic import TemplateView