Permalink
Browse files

Basic python3 support

  • Loading branch information...
jpic committed Sep 25, 2013
1 parent cfd0ba5 commit 188f3238b112475601b55693d891777ecc6dd3f8
View
@@ -1,6 +1,6 @@
from registry import RuleRegistry, registry, run, require, autodiscover
from class_decorator import class_decorator
from decorators import make_decorator
from exceptions import Denied, DoesNotExist, RulesLightException
from middleware import Middleware
from shortcuts import is_authenticated, is_staff
from .registry import RuleRegistry, registry, run, require, autodiscover
from .class_decorator import class_decorator
from .decorators import make_decorator
from .exceptions import Denied, DoesNotExist, RulesLightException
from .middleware import Middleware
from .shortcuts import is_authenticated, is_staff
@@ -1,6 +1,7 @@
"""
"""
from __future__ import unicode_literals
from django.views import generic
@@ -25,6 +25,7 @@ def my_book(user, rule, book):
rules_light.registry['do_something'] = my_book
"""
from __future__ import unicode_literals
def make_decorator(_rule):
@@ -1,3 +1,6 @@
from __future__ import unicode_literals
class RulesLightException(Exception):
""" Base class for all exceptions of this package. """
pass
@@ -2,6 +2,7 @@
The role of the middleware is to present a user friendly error page when a rule
denied process of the request by raising ``Denied``.
"""
from __future__ import unicode_literals
from django import template
from django import http
View
@@ -8,9 +8,11 @@
A rule can be a callback or a variable that will be evaluated as bool.
"""
from __future__ import unicode_literals
import logging
from django.utils.encoding import smart_unicode
from django.utils.encoding import smart_text
from exceptions import Denied, DoesNotExist
@@ -80,11 +82,11 @@ def as_text(self, user, name, *args, **kwargs):
formated_args = []
for arg in args:
formated_args.append(u'"%s"' % smart_unicode(arg))
formated_args.append(u'"%s"' % smart_text(arg))
for key, value in kwargs.items():
formated_args.append(u'%s="%s"' % (smart_unicode(key),
smart_unicode(value)))
formated_args.append(u'%s="%s"' % (smart_text(key),
smart_text(value)))
formated_args = u', '.join(formated_args)
if hasattr(self[name], '__call__'):
@@ -110,7 +112,7 @@ def rule_text_name(self, rule):
elif hasattr(rule, '__name__'):
return rule.__name__
else:
return smart_unicode(rule)
return smart_text(rule)
registry = RuleRegistry()
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
import rules_light
View
@@ -22,6 +22,7 @@ def my_book(user, rule, book):
rules_light.registry.setdefault('your_app.your_model.update', my_book)
"""
from __future__ import unicode_literals
from decorators import make_decorator
@@ -1,6 +1,6 @@
from registry import RegistryTestCase
from class_decorator import ClassDecoratorTestCase
from autodiscover import AutodiscoverTestCase
from views import ViewsTestCase
from decorators import DecoratorsTestCase
from shortcuts import ShortcutsTestCase
from .registry import RegistryTestCase
from .class_decorator import ClassDecoratorTestCase
from .autodiscover import AutodiscoverTestCase
from .views import ViewsTestCase
from .decorators import DecoratorsTestCase
from .shortcuts import ShortcutsTestCase
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
import unittest
import rules_light
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
import unittest
from django.views import generic
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from django.views import generic
from django.contrib.auth.models import User
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
import unittest
import rules_light
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
import unittest
from django.test.client import Client
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import logging
import unittest
from mock import Mock
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
import unittest
from django.contrib.auth.models import User
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
import unittest
from django.test.client import RequestFactory
View
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from django.conf.urls import patterns, include, url
import rules_light
View
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from django.views import generic
import rules_light
View
@@ -38,7 +38,6 @@ def run(self):
if 'django.mo' in filenames:
os.unlink(os.path.join(dirpath, 'django.mo'))
print 'unlink', os.path.join(dirpath, 'django.mo')
else:
# if django is there, compile the po files to mo,
try:
@@ -141,4 +141,4 @@
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
from rules_logging import LOGGING
from .rules_logging import LOGGING

0 comments on commit 188f323

Please sign in to comment.