Python API

Classes

class polar.Relation(kind: str, other_type: str, my_field: str, other_field: str)

An object representing a relation between two types registered with Oso.

class polar.DataFilter(model, relations, conditions, types)

An object representing an abstract query over a particular data type

class polar.Condition(left, cmp, right)

An object representing a WHERE condition on a query.

cmp is an equality or inequality operator.

left and right may be Projections or literal data.

class polar.Projection(source, field)

An object representing a named property (field) of a particular data type (source). field may be None, which user code must translate to a field (usually the primary key column in a database) that uniquely identifies the record.

class polar.data.adapter.sqlalchemy_adapter.SqlAlchemyAdapter(session: Session)

Exceptions

exception oso.exceptions.AuthorizationError(message=None, details=None)

Bases: OsoError

exception oso.exceptions.ForbiddenError

Bases: AuthorizationError

Thrown by the authorize, authorize_field, and authorize_request methods when the action is not allowed.

Most of the time, your app should handle this error by returning a 403 HTTP error to the client.

exception oso.exceptions.NotFoundError

Bases: AuthorizationError

Thrown by the authorize method of an Oso instance. This error indicates that the actor is not only not allowed to perform the given action but also is not allowed to "read" the given resource.

Most of the time, your app should handle this error by returning a 404 HTTP error to the client.

To control which action is used for the distinction between NotFoundError and ForbiddenError, you can customize the read_action on your Oso instance.

Exceptions used within Oso.

exception polar.exceptions.DuplicateClassAliasError(name, old, new)

Bases: PolarRuntimeError

Raised on attempts to register a class with the same name as a class that has already been registered

exception polar.exceptions.DuplicateInstanceRegistrationError(message=None, details=None)

Bases: PolarRuntimeError

exception polar.exceptions.ExtraToken(message=None, details=None)

Bases: ParserError

exception polar.exceptions.FFIErrorNotFound(message=None, details=None)

Bases: OsoError

Raised when an error is generated by the Oso Rust core, but the error type is not found.

exception polar.exceptions.InlineQueryFailedError(source)

Bases: PolarRuntimeError

exception polar.exceptions.IntegerOverflow(message=None, details=None)

Bases: ParserError

exception polar.exceptions.InvalidCallError(message=None, details=None)

Bases: PolarRuntimeError

Invalid attempt to call a field or method on an object in Polar

exception polar.exceptions.InvalidConstructorError(message=None, details=None)

Bases: PolarRuntimeError

exception polar.exceptions.InvalidIteratorError(message=None, details=None)

Bases: PolarRuntimeError

Invalid attempt to iterate over a non-iterable value

exception polar.exceptions.InvalidQueryTypeError(message=None, details=None)

Bases: PolarRuntimeError

exception polar.exceptions.InvalidToken(message=None, details=None)

Bases: ParserError

exception polar.exceptions.InvalidTokenCharacter(message=None, details=None)

Bases: ParserError

exception polar.exceptions.OperationalError(message=None, details=None)

Bases: OsoError

Errors from polar that are not necessarily the user’s fault. OOM etc…

exception polar.exceptions.OsoError(message=None, details=None)

Bases: Exception

Base exception class for Oso.

exception polar.exceptions.ParserError(message=None, details=None)

Bases: OsoError

Parse time errors.

exception polar.exceptions.PolarFileExtensionError(file)

Bases: PolarRuntimeError

exception polar.exceptions.PolarFileNotFoundError(file)

Bases: PolarRuntimeError

exception polar.exceptions.PolarRuntimeError(message=None, details=None)

Bases: OsoError

Errors generated by Oso at runtime

exception polar.exceptions.PolarTypeError(message=None, details=None)

Bases: PolarRuntimeError

Error related to the type of a Polar object, generated by the Rust core

exception polar.exceptions.StackOverflowError(message=None, details=None)

Bases: PolarRuntimeError

Polar stack overflow error, generated by the Rust core

exception polar.exceptions.UnexpectedPolarTypeError(message=None, details=None)

Bases: PolarRuntimeError

exception polar.exceptions.UnknownError(message=None, details=None)

Bases: OperationalError

exception polar.exceptions.UnrecognizedEOF(message=None, details=None)

Bases: ParserError

exception polar.exceptions.UnrecognizedToken(message=None, details=None)

Bases: ParserError

exception polar.exceptions.UnregisteredClassError(message=None, details=None)

Bases: PolarRuntimeError

Raised on attempts to reference unregistered Python classes from a Polar policy.

exception polar.exceptions.UnregisteredInstanceError(message=None, details=None)

Bases: PolarRuntimeError

exception polar.exceptions.UnsupportedError(message=None, details=None)

Bases: PolarRuntimeError

Unsupported action error generated by the Rust core

exception polar.exceptions.ValidationError(message=None, details=None)

Bases: OsoError