assembl.models package

Module contents

The SQLAlchemy models of IdeaLoom.

The base class of all models is Base, derived from assembl.lib.sqla.BaseOps. Here, we also define some other base-level classes, such as DiscussionBoundBase and DiscussionBoundTombstone.


Entity-relation diagram

class assembl.models.AbstractBase(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

class assembl.models.ContextualNamedClassMixin[source]

Bases: assembl.models.NamedClassMixin

A mix-in for models that have a unique name within a context

class assembl.models.DeclarativeAbstractMeta(name, bases, namespace, **kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.DeclarativeMeta, abc.ABCMeta

Allows to declare abstract SQLAlchemy classes

class assembl.models.DiscussionBoundBase(**kwargs)[source]

Bases: assembl.models.AbstractBase

Base class for models that are bound to a specific discussion.

These models will deleted if the discussion is deleted. They need to have a relationship to the discussion, but this relationship need not be direct. Subclasses need to define get_discussion_id() and get_discussion_conditions().


What is the URL where we expect to find this resource

abstract classmethod get_discussion_conditions(discussion_id, alias_maker=None)[source]

Returns a list of SQLA expressions that constrain a query on this class to a given discussion.

abstract get_discussion_id()[source]

Get the ID of an associated discussion object, if any.

send_to_changes(connection=None, operation=<CrudOperation.UPDATE: 0>, discussion_id=None, view_def='changes')[source]

Ask for this object to be sent on the changes websocket.

See assembl.tasks.changes_router.


Return a Tombstone object.

This object will be sent on the websocket and will express that this object has been deleted.


returns a couple (query, usable), with a sqla query for conflicting similar objects. usable is true if the query has to be enforced; sometimes it makes sense to return un-usable query that will be used to construct queries of subclasses. Note that when a duplicate is found, you’ll often want to expunge the original.

class assembl.models.DiscussionBoundTombstone(ob, **kwargs)[source]

Bases: assembl.lib.sqla.Tombstone

A assembl.lib.sqla.Tombstone that is bound to a discussion

class assembl.models.NamedClassMixin[source]

Bases: object

A mix-in for models that have a globally unique name