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)
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])
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)
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
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
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
def set_context(user=None): """ """ local.request = local.Thread() security.set_user(user) security.set_manager(SecurityManager('somekey'))
def set_dummy_context(): """Set a dummy context for security permission checks """ local.request = local.Thread() security.set_user(None) security.set_manager(DummySecurityManager())
def __exit__(self, *args, **kw): """Pop these security rules from the stack """ security.set_manager(self._previous_rules)
def __enter__(self): """Push these security rules to the stack """ self._previous_rules = security.get_manager() security.set_manager(self)