SiteTree

class silverflask.models.SiteTree.SiteTree

The SiteTree is the database model from which all pages have to inherit. It defines the parent/children relationships of the page tree. It also defines everything that’s needed to get nice URL slugs working.

Mixins

hh Silverflask defines a number of mixins that can be utilized to enhance DataObjects (and are used in the SiteTree class for example).

class silverflask.mixins.OrderableMixin.OrderableMixin

A mixin that makes a DataObject sortable by adding a sort_order database field. Classes with this mixin automatically keep the sort_order in sync.

classmethod check_duplicates()

Check the table for duplicates and if there are duplicates reindex :return: nothing

init_order()

Sort element to the end

insert_after(index, orderable_base_class=None, index_absolute=True, query=None)

Inser after index variable

Parameters:
  • index – index (this is the sort_order variable of the element that you want to insert after!)
  • orderable_base_class – baseclass (useful in certain circumstances e.g. gridfields)
Returns:

nothing

move_after(obj)

Move current DataObject after index (= sort_order) of another element

Parameters:index – obj element where to move after or sort order of other elements
Returns:nothing
classmethod reindex()

Reindexes the table.

The sort order field can have “jumps” in it (e.g. 1, 4, 5, 8, 9) and reindex brings that back to a linearly ascending order: (1,2,3,4...)

class silverflask.mixins.VersionedMixin.VersionedMixin

A mixin that adds versioning support to DataObjects. It adds a new live table that saves the object on a publish operation, a new query_live operator that queries the live versions of the object and a versions relationship that saves all versions of this object (a version is automatically created on a save operation).

can_publish()

Override this function to control who is allowed to publish pages in the CMS :return: Boolean (True if allowed to publish)

mark_as_published()

Create a copy of the current draft to the live table and publish this DataObject (make it visible to the outside world). :return: empty