everest.orm

ORM related services.

class everest.orm.OrderClauseList(*clauses, **kwargs)[source]

Bases: sqlalchemy.sql.expression.ClauseList

Custom clause list for ORDER BY clauses.

Suppresses the grouping parentheses which would trigger a syntax error.

everest.orm.Session = <sqlalchemy.orm.scoping.ScopedSession object at 0x2f6edd0>

The scoped session maker. Instantiate this to obtain a thread local session instance.

everest.orm.as_slug_expression(attr)[source]

Converts the given instrumented string attribute into an SQL expression that can be used as a slug.

Slugs are identifiers for members in a collection that can be used in an URL. We create slug columns by replacing non-URL characters with dashes and lower casing the result. We need this at the ORM level so that we can use the slug in a query expression.

everest.orm.clear_mappers()[source]

Clears all mappers set up by SA and also clears all custom “id” and “slug” attributes inserted by the mapper() function in this module.

This should only ever bee needed in a testing context.

everest.orm.commit_veto(environ, status, headers)[source]

Strict commit veto to use with the transaction manager.

Unlike the default commit veto supplied with the transaction manager, this will veto all commits for HTTP status codes other than 2xx unless a commit is explicitly requested by setting the “x-tm” response header to “commit”.

everest.orm.empty_metadata(engine)[source]

The default metadata factory.

everest.orm.mapper(class_, local_table=None, id_attribute='id', slug_expression=None, *args, **kwargs)[source]

Convenience wrapper around the SA mapper which will set up the hybrid “id” and “slug” attributes required by everest after calling the SA mapper.

If you (e.g., for testing purposes) want to clear mappers created with this function, use the clear_mappers() function in this module.

Parameters:
  • id_attribute (str) – the name of the column in the table to use as ID column (will be aliased to a new “id” attribute in the mapped class)
  • slug_expression – function to generate a slug SQL expression given the mapped class as argument.

Project Versions

Previous topic

everest.mime

Next topic

everest.relationship

This Page