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.

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

Bases: sqlalchemy.ext.declarative.api.Base

class assembl.models.DeclarativeAbstractMeta(classname, bases, dict_)[source]

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

Allows to declare abstract SQLAlchemy classes

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

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().

container_url()[source]

What is the URL where we expect to find this resource

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.

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.

tombstone()[source]

Return a Tombstone object.

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

unique_query()[source]

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 unique name