def render(self, session, principal, **arguments): try: options = [undefer("comments")] return get_or_create_user_principal(session, principal, False, False, options) except ArgumentError: raise NotFoundException("User principal %s not found." % principal)
def render(self, session, principal, **arguments): try: options = [undefer("comments")] return get_or_create_user_principal(session, principal, False, False, options) except ArgumentError: raise NotFoundException("User principal %s not found." % principal)
def render(self, session, principal, role, createuser, createrealm, comments, **arguments): dbrole = Role.get_unique(session, role, compel=True) dbuser = get_or_create_user_principal(session, principal, createuser, createrealm, comments=comments) dbuser.role = dbrole session.flush() return
def render(self, session, principal, role, createuser, createrealm, comments, **arguments): dbrole = Role.get_unique(session, role, compel=True) dbuser = get_or_create_user_principal(session, principal, createuser, createrealm, comments=comments) dbuser.role = dbrole session.add(dbuser) return
def updated_render(self, *args, **kwargs): principal = kwargs["user"] request = kwargs["request"] logger = kwargs["logger"] raising_exception = None rollback_failed = False try: if self.requires_transaction or self.requires_azcheck: # Set up a session... if not "session" in kwargs: if self.is_lock_free: kwargs["session"] = self.dbf.NLSession() else: kwargs["session"] = self.dbf.Session() session = kwargs["session"] if session.bind.dialect.name == "oracle": # Make the name of the command and the request ID # available in v$session. Trying to set a value longer # than the allowed length will generate ORA-24960, so # do an explicit truncation. conn = session.connection() dbapi_con = conn.connection.connection dbapi_con.action = str(self.action)[:32] # TODO: we should include the command number as well, # since that is easier to find in the logs dbapi_con.clientinfo = str(kwargs["requestid"])[:64] # This does a COMMIT, which in turn invalidates the session. # We should therefore avoid looking up anything in the DB # before this point which might be used later. self._record_xtn(session, logger.get_status()) dbuser = get_or_create_user_principal(session, principal, commitoncreate=True) kwargs["dbuser"] = dbuser if self.requires_azcheck: self.az.check(principal=principal, dbuser=dbuser, action=self.action, resource=request.path) if self.requires_readonly: self._set_readonly(session) # begin() is only required if session transactional=False #session.begin() if self.badmode: # pragma: no cover raise UnimplementedError("Command %s not available on " "a %s broker." % (self.command, self.badmode)) for key in kwargs.keys(): if key in self.parameter_checks: kwargs[key] = self.parameter_checks[key]("--" + key, kwargs[key]) # Command is an instance method already having self... retval = command(*args, **kwargs) if self.requires_format: style = kwargs.get("style", None) retval = self.formatter.format(style, retval, request) if "session" in kwargs: session.commit() return retval except Exception, e: raising_exception = e # Need to close after the rollback, or the next time session # is accessed it tries to commit the transaction... (?) if "session" in kwargs: try: session.rollback() except: # pragma: no cover rollback_failed = True raise session.close() raise
def updated_render(self, *args, **kwargs): principal = kwargs["user"] request = kwargs["request"] logger = kwargs["logger"] raising_exception = None rollback_failed = False try: if self.requires_transaction or self.requires_azcheck: # Set up a session... if not "session" in kwargs: if self.is_lock_free: kwargs["session"] = self.dbf.NLSession() else: kwargs["session"] = self.dbf.Session() session = kwargs["session"] if session.bind.dialect.name == "oracle": # Make the name of the command and the request ID # available in v$session. Trying to set a value longer # than the allowed length will generate ORA-24960, so # do an explicit truncation. conn = session.connection() dbapi_con = conn.connection.connection dbapi_con.action = str(self.action)[:32] # TODO: we should include the command number as well, # since that is easier to find in the logs dbapi_con.clientinfo = str(kwargs["requestid"])[:64] # This does a COMMIT, which in turn invalidates the session. # We should therefore avoid looking up anything in the DB # before this point which might be used later. self._record_xtn(session, logger.get_status()) dbuser = get_or_create_user_principal(session, principal, commitoncreate=True) kwargs["dbuser"] = dbuser if self.requires_azcheck: self.az.check(principal=principal, dbuser=dbuser, action=self.action, resource=request.path) if self.requires_readonly: self._set_readonly(session) # begin() is only required if session transactional=False #session.begin() if self.badmode: # pragma: no cover raise UnimplementedError("Command %s not available on " "a %s broker." % (self.command, self.badmode)) for key in kwargs.keys(): if key in self.parameter_checks: kwargs[key] = self.parameter_checks[key]("--" + key, kwargs[key]) # Command is an instance method already having self... retval = command(*args, **kwargs) if self.requires_format: style = kwargs.get("style", None) retval = self.formatter.format(style, retval, request) if "session" in kwargs: session.commit() return retval except Exception, e: raising_exception = e # Need to close after the rollback, or the next time session # is accessed it tries to commit the transaction... (?) if "session" in kwargs: try: session.rollback() except: # pragma: no cover rollback_failed = True raise session.close() raise