def __init__(self):
     """
     Set the global ACL collection and attach the application-specific
     authorization controls to it.
     
     If there's an ACL collection set in the ``GLOBAL_ACL_COLLECTION``
     setting, then use it instead.
     
     """
     # If there's no global ACL collection, create one:
     if hasattr(settings, "GLOBAL_ACL_COLLECTION"):
         self.acl_collection = resolve_object(settings.GLOBAL_ACL_COLLECTION)
     else:
         self.acl_collection = ACLCollection()
     
     # Let's get the authorization controls for every Django application:
     secured_apps = []
     for app in settings.INSTALLED_APPS:
         authz_module_name = "%s.authz" % app
         try:
             authz_module = import_module(authz_module_name)
         except ImportError:
             continue
         if not hasattr(authz_module, "control"):
             continue
         self.acl_collection.add_acl(authz_module.control)
         secured_apps.append(app)
     
     if secured_apps:
         secured_apps = ", ".join(secured_apps)
         _LOGGER.info("The following applications are secured: %s",
                      secured_apps)
     else:
         _LOGGER.warn("No application is secured")
Beispiel #2
0
    def __init__(self):
        """
        Set the global ACL collection and attach the application-specific
        authorization controls to it.
        
        If there's an ACL collection set in the ``GLOBAL_ACL_COLLECTION``
        setting, then use it instead.
        
        """
        # If there's no global ACL collection, create one:
        if hasattr(settings, "GLOBAL_ACL_COLLECTION"):
            self.acl_collection = resolve_object(
                settings.GLOBAL_ACL_COLLECTION)
        else:
            self.acl_collection = ACLCollection()

        # Let's get the authorization controls for every Django application:
        secured_apps = []
        for app in settings.INSTALLED_APPS:
            authz_module_name = "%s.authz" % app
            try:
                authz_module = import_module(authz_module_name)
            except ImportError:
                continue
            if not hasattr(authz_module, "control"):
                continue
            self.acl_collection.add_acl(authz_module.control)
            secured_apps.append(app)

        if secured_apps:
            secured_apps = ", ".join(secured_apps)
            _LOGGER.info("The following applications are secured: %s",
                         secured_apps)
        else:
            _LOGGER.warn("No application is secured")
Beispiel #3
0
 def test_getting_none_object(self):
     object_ = resolve_object(FIXTURES_MODULE + "my_none")
     eq_(object_, None)
Beispiel #4
0
 def test_getting_object(self):
     object_ = resolve_object(FIXTURES_MODULE + "my_object")
     eq_(object_, my_object)
 def test_getting_none_object(self):
     object_ = resolve_object(FIXTURES_MODULE + "my_none")
     eq_(object_, None)
 def test_getting_object(self):
     object_ = resolve_object(FIXTURES_MODULE + "my_object")
     eq_(object_, my_object)