This method sets up a method that allows manual setting of the current_tenant. This method should
 be used in a before_action. In addition, a helper is setup that returns the current_tenant
504163
def set_current_tenant_through_filter
      self.class_eval do
        helper_method :current_tenant if respond_to?(:helper_method)

        private
          def set_current_tenant(current_tenant_object)
            ActsAsTenant.current_tenant = current_tenant_object
          end

          def current_tenant
            ActsAsTenant.current_tenant
          end
      end
    end
1270386
def setup_callables(self):
        
        defaults = self.get_default_callables()
        for key, value in list(defaults.items()):
            self._postponed_callables.setdefault(key, value)
        for key in self.callables:
            value = self._postponed_callables.pop(key)
            value.setup_callable_system(self.system, init=True)
            setattr(self, key, value)
1233240
private void setActiveAction() {
		int ks = keyStoreList.getSelectedIndex();
		int alias = aliasTable.getSelectedRow();
		if (ks > -1 && alias>-1) {
			if (!contextManager.isKeyUnlocked(ks, alias)) {


				try {
					if(!contextManager.unlockKeyWithDefaultPassword(ks, alias)){
						String password = getPassword();

						if(!contextManager.unlockKey(ks, alias, password)){
							JOptionPane.showMessageDialog(null, new String[] {
									Constant.messages.getString("options.cert.error.accesskeystore")}, 
									Constant.messages.getString("options.cert.error"), JOptionPane.ERROR_MESSAGE);
						}
					}
				} catch (Exception e) {
					showKeyStoreCertError(e.toString());
				}
			}
			Certificate cert = contextManager.getCertificate(ks, alias);
			try {
				contextManager.getFingerPrint(cert);
			} catch (KeyStoreException kse) {
				showCertError("options.cert.error.fingerprint", kse.toString());
			}

			try {
				contextManager.setDefaultKey(ks, alias);

				OptionsParamCertificate certParam = Model.getSingleton().getOptionsParam().getCertificateParam();
				certParam.setActiveCertificate();

			} catch (KeyStoreException e) {
				logger.error(e.getMessage(), e);
			}
			certificateTextField.setText(contextManager.getDefaultKey());
		}
	}
825043
def init_ivars(current_user)
      guest_user = CryptIdent.config.guest_user
      current_user ||= guest_user
      @current_user = guest_user.class.new(current_user)
    end
1316523
@RequestMapping(value = "/tenants", method = RequestMethod.GET)
    public String getTenants(@RequestParam ("tenantId") Integer tenantId, Locale locale, ModelMap modelMap, Model model) {
        
        AuthenticationProfile authenticationProfile = (AuthenticationProfile)modelMap.get("tenantAuthorization");
        //if there is no active user, go to the auth page.
        if (authenticationProfile == null) {
            setupHomePage (locale, model);
            return "home";

        }

        // if no tenant id was supplied just use the active tenantID in the user auth.
        if (tenantId == null) {
            tenantId = authenticationProfile.getActiveScope().getId();
        }
        
        // we need to get a new auth ticket for the tenant and update the authenticationProfile in session.
        if (tenantId != null && !tenantId.equals(authenticationProfile.getActiveScope().getId())) {
            authenticationProfile = UserAuthenticator.refreshUserAuthTicket(authenticationProfile.getAuthTicket(), tenantId);
            model.addAttribute("tenantAuthorization", authenticationProfile);
        }
        
        // Authorize user and get tenants
        List<Scope> tenants = authenticationProfile.getAuthorizedScopes();
        if (tenants == null) {
            tenants = new ArrayList<Scope>();
            tenants.add(authenticationProfile.getActiveScope());    
        }
        
        
        model.addAttribute("user", authenticationProfile.getUserProfile());
        model.addAttribute("availableTenants", tenants);
        model.addAttribute("tenantId", tenantId);
        List<Site> sites = null;
        if (tenants != null && tenants.size() > 0) {
            sites = getAvailableTenantSites(tenantId);
        } else {
            sites = new ArrayList<Site>();
        }
        model.addAttribute("sites", sites);
                
        return "tenants";
    }
600581
def create_tenant(self, name, description=None, enabled=True):
        
        data = {"tenant": {
                "name": name,
                "enabled": enabled,
                }}
        if description:
            data["tenant"]["description"] = description
        resp, resp_body = self.method_post("tenants", data=data)
        return Tenant(self, resp_body)
269284
def set_schema_to_public(self):
        
        self.tenant = FakeTenant(schema_name=get_public_schema_name())
        self.schema_name = get_public_schema_name()
        self.set_settings_schema(self.schema_name)
        self.search_path_set = False
709102
def setup(self):
        
        self.pre_handlers = pre_handlers = {}
        self.post_handlers = post_handlers = {}
        for name in sorted(vars(type(self))):
            if name.startswith('init_'):
                getattr(self, name)()
            elif name.startswith('pre_'):
                pre_handlers[name[4:]] = getattr(self, name)
            elif name.startswith('post_'):
                post_handlers[name[5:]] = getattr(self, name)
633091
def from_current(cls):
        
        if properties.application_id is None:
            raise context.ValueError("Not running inside a container")

        return cls(properties.appmaster_address,
                   properties.application_id,
                   security=Security.from_default())
1220971
def gotoPrevious(self):
        
        index = self._currentPanel.currentIndex() - 1
        if index < 0:
            index = self._currentPanel.count() - 1
        
        self._currentPanel.setCurrentIndex(index)
836693
def _setup(self):
        
        self._populate_local()
        try:
            self._populate_latest()
        except Exception as e:
            self.log.exception('Unable to retrieve latest %s version information', self.meta_name)
        self._sort()
1098730
def _set_current_options(self, options):
        

        opts = self._get_current_options()
        opts.update(options)
        response = self.__proxy__.set_current_options(opts)
        return response
608569
def __milia_change_tenant!( tid )
    old_id = ( Thread.current[:tenant_id].nil? ? '%' : Thread.current[:tenant_id] )
    new_id = ( tid.nil? ? '%' : tid.to_s )
    Thread.current[:tenant_id] = tid
    session[:tenant_id] = tid  # remember it going forward
    logger.debug("MILIA >>>>> [change tenant] new: #{new_id}\told: #{old_id}") unless logger.nil?
  end
552824
def setup(cls):
        
        try:
            if cls.auto_setup and cls.auto_setup.get('enabled', False):
                if not cls.auto_setup.get('home title', False):
                    warnings.warn(
                        '"home title" is not set in {0}.auto_setup attribute'.format(cls)
                    )
                    return
                if not cls.auto_setup.get('page title', False):
                    warnings.warn(
                        '"page title" is not set in {0}.auto_setup attribute'.format(cls)
                    )
                    return
                if cls.app_name and not cls.auto_setup.get('namespace', False):
                    warnings.warn(
                        '"page title" is not set in {0}.auto_setup attribute'.format(cls)
                    )
                    return
                config = None
                cls._setup_pages(config)
        except Exception:
            # Ignore any error during setup. Worst case: pages are not created, but the instance
            # won't break
            pass
311402
def on_self
      scope  = current_scope
      method = scope.lookup(scope.method_call_type, 'self')

      push_value(method.return_value)
    end
377820
private void initializeTenantStores(Tenant tenant) {
        DBService.instance(tenant).createStoreIfAbsent(SchemaService.APPS_STORE_NAME, false);
        DBService.instance(tenant).createStoreIfAbsent(TaskManagerService.TASKS_STORE_NAME, false);
    }
1028939
public void setValue(final Duration tenantDuration) {
        if (tenantDuration == null) {
            // no tenant specific configuration
            checkBox.setValue(false);
            durationField.setDuration(globalDuration);
            durationField.setEnabled(false);
            return;
        }

        checkBox.setValue(true);
        durationField.setDuration(tenantDuration);
        durationField.setEnabled(true);
    }