Пример #1
0
    def setUp(self):
        # call the base implementation
        super(ConfigurationEnabledTestCase, self).setUp()

        # configure the local service
        local.request = local.Process()
        local.worker = local.Process()

        # read the configuration
        conf_path = test_resource_path('conf', 'eureka.cfg.template')
        defaults = dict(here='string(default="%s")' %
                        os.path.abspath(os.path.dirname(conf_path)))
        conf = read_application_options(conf_path, self.fail, defaults)

        # initialize the application context
        # no root component since we only want to perform the configuration
        app = BaseApplication(None)
        app.PLATFORM = "Eureka base"
        app.set_config(conf_path, conf, self.fail)
        app.set_base_url('http://localhost/')  # dummy server host
        app.set_locale(i18n.Locale('en', 'US'))  # Set the default Locale

        # install the configuration
        registry.configure(app.configuration)

        # configure the security manager
        security.set_manager(app.security)
Пример #2
0
def configure():
    """Configure the batch environment"""

    global apps
    # we suppose that the batch addresses only one application
    app_name, app = apps.items()[0]

    local.request = local.Process()
    local.worker = local.Process()

    log.set_logger('nagare.application.' + app.name)

    security.set_manager(app.security)

    # initialize the application context
    app.set_base_url('http://localhost/')  # dummy server host
    app.set_locale(i18n.Locale('en', 'US'))  # Set the default Locale

    # install the configuration
    registry.configure(app.configuration)

    # log the start of the script
    logger = log.get_logger('.' + __name__)
    logger.debug('----')
    logger.debug('Running %s\n' % sys.argv[0])
Пример #3
0
    def setUp(self):
        # call the base implementation
        super(ConfigurationEnabledTestCase, self).setUp()

        # configure the local service
        local.request = local.Process()
        local.worker = local.Process()

        # read the configuration
        conf_path = test_resource_path('conf', 'eureka.cfg.template')
        defaults = dict(
            here='string(default="%s")' %
            os.path.abspath(os.path.dirname(conf_path))
        )
        conf = read_application_options(conf_path, self.fail, defaults)

        # initialize the application context
        # no root component since we only want to perform the configuration
        app = BaseApplication(None)
        app.PLATFORM = "Eureka base"
        app.set_config(conf_path, conf, self.fail)
        app.set_base_url('http://localhost/')  # dummy server host
        app.set_locale(i18n.Locale('en', 'US'))  # Set the default Locale

        # install the configuration
        registry.configure(app.configuration)

        # configure the security manager
        security.set_manager(app.security)
Пример #4
0
    def start_request(self, root, request, response):
        """A new request is received, setup its dedicated environment

        In:
          - ``root`` -- the application root component
          - ``request`` -- the web request object
          - ``response`` -- the web response object
        """
        security.set_manager(self.security) # Set the security manager
        security.set_user(self.security.create_user(request, response)) # Create the User object

        self.set_locale(self.default_locale) # Set the default Locale
Пример #5
0
    def start_request(self, root, request, response):
        """A new request is received, setup its dedicated environment

        In:
          - ``root`` -- the application root component
          - ``request`` -- the web request object
          - ``response`` -- the web response object
        """
        security.set_manager(self.security)  # Set the security manager
        security.set_user(self.security.create_user(
            request, response))  # Create the User object

        self.set_locale(self.default_locale)  # Set the default Locale
Пример #6
0
    def authenticate(self, **params):
        if get_user() is not None:
            return None, None

        set_manager(self)

        # Retrieve the data associated with the connected user
        principal, credentials, response = self.get_principal(**params)
        user = self.create_user(principal, **credentials)
        if isinstance(user, User):
            user.credentials.setdefault('principal', principal)
            for k, v in credentials.items():
                user.credentials.setdefault(k, v)

        set_user(user)

        return user, response
Пример #7
0
def set_context(user=None):
    """ """
    local.request = local.Thread()
    security.set_user(user)
    security.set_manager(SecurityManager('somekey'))
Пример #8
0
def set_dummy_context():
    """Set a dummy context for security permission checks
    """
    local.request = local.Thread()
    security.set_user(None)
    security.set_manager(DummySecurityManager())
Пример #9
0
 def __exit__(self, *args, **kw):
     """Pop these security rules from the stack
     """
     security.set_manager(self._previous_rules)
Пример #10
0
 def __enter__(self):
     """Push these security rules to the stack
     """
     self._previous_rules = security.get_manager()
     security.set_manager(self)
Пример #11
0
def set_context(user=None):
    """ """
    local.request = local.Thread()
    security.set_user(user)
    security.set_manager(SecurityManager('somekey'))
Пример #12
0
def set_dummy_context():
    """Set a dummy context for security permission checks
    """
    local.request = local.Thread()
    security.set_user(None)
    security.set_manager(DummySecurityManager())
Пример #13
0
 def __exit__(self, *args, **kw):
     """Pop these security rules from the stack
     """
     security.set_manager(self._previous_rules)
Пример #14
0
 def __enter__(self):
     """Push these security rules to the stack
     """
     self._previous_rules = security.get_manager()
     security.set_manager(self)