assembl.models.path_utils module

Utilities for traversing the set of content related to an idea and vice-versa.

class assembl.models.path_utils.DiscussionGlobalData(db, discussion_id, user_id=None, discussion=None)[source]

Bases: object

Cache for global discussion data, lasts as long as the pyramid request object.

idea_ancestry(idea_id)[source]

generator of ids of ancestor ideas

parent_dict

dictionary child_idea.id -> parent_idea.id.

TODO: Make it dict(id->id[]) for multiparenting

class assembl.models.path_utils.PostPathCombiner(discussion)[source]

Bases: assembl.models.path_utils.PostPathGlobalCollection, assembl.models.idea.IdeaVisitor

A traversal that will combine the PostPathLocalCollections of an idea with those of the idea’s ancestors. The result is that the as_clause of each PostPathLocalCollections in self.paths is globally complete

class assembl.models.path_utils.PostPathCounter(discussion, user_id=None, calc_subset=None)[source]

Bases: assembl.models.path_utils.PostPathCombiner

Adds the ability to do post counts to PostPathCombiner.

class assembl.models.path_utils.PostPathData(post_path, positive)[source]

Bases: object

Data about a single post_path.

class assembl.models.path_utils.PostPathGlobalCollection(discussion=None)[source]

Bases: object

Collects PostPathLocalCollections for each idea in the discussion Maintains paths, a dictionary of PostPathLocalCollections by idea_id

class assembl.models.path_utils.PostPathLocalCollection[source]

Bases: object

Data about all PostPaths local to an Idea.

as_clause_base(db, discussion_id, include_breakpoints=False, include_deleted=False)[source]

Express collection as a SQLAlchemy query clause.

Parameters
  • include_breakpoints (bool) – Include posts where a threadbreak happens

  • include_deleted – Include posts in deleted_publication_states. True means only deleted posts, None means all posts, False means only live posts or deleted posts with live descendants.

combine(other)[source]

Combine the paths from two collections (different ideas).

includes_post(post_path)[source]

Is this post (given as path) included in this collection?

reduce()[source]

Reduce overlapping paths. For example, <1,+>,<1,2,+> becomes <1,+> But <1,+>,<1,2,->,<1,2,3,+> remains as-is And <1,+>,<1,2,->,<1,3,4,+> becomes <1,+>,<1,2,->