wiki.models package

Submodules

class wiki.models.article.BaseRevisionMixin(*args, **kwargs)

Bases: django.db.models.base.Model

This is an abstract model used as a mixin: Do not override any of the core model methods but respect the inheritor’s freedom to do so itself.

class Meta
abstract = False
BaseRevisionMixin.get_next_by_created(*moreargs, **morekwargs)
BaseRevisionMixin.get_next_by_modified(*moreargs, **morekwargs)
BaseRevisionMixin.get_previous_by_created(*moreargs, **morekwargs)
BaseRevisionMixin.get_previous_by_modified(*moreargs, **morekwargs)
BaseRevisionMixin.previous_revision
BaseRevisionMixin.set_from_request(request)
BaseRevisionMixin.user
wiki.models.article.on_article_delete_clear_cache(instance, **kwargs)
wiki.models.article.on_article_save_clear_cache(instance, **kwargs)
exception wiki.models.pluginbase.SimplePluginCreateError

Bases: exceptions.Exception

wiki.models.pluginbase.on_article_plugin_post_save(**kwargs)
wiki.models.pluginbase.on_reusable_plugin_post_save(**kwargs)
wiki.models.pluginbase.on_revision_plugin_revision_post_save(**kwargs)
wiki.models.pluginbase.update_simple_plugins(**kwargs)

Every time a new article revision is created, we update all active plugins to match this article revision

class wiki.models.section.Section(*args, **kwargs)

Bases: django.db.models.base.Model

Section(id, current_revision_id, deleted, locked, created, modified, owner_id, group_id, group_read, group_write, other_read, other_write)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Section.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Section.add_revision(new_revision, save=True)

Sets the properties of a revision and ensures its the current revision.

Section.can_assign(user)
Section.can_delete(user)
Section.can_moderate(user)
Section.can_read(user)
Section.can_write(user)
Section.clear_cache()
Section.current_revision
Section.get_cache_key()
Section.get_cached_content()

Returns cached

Section.get_next_by_created(*moreargs, **morekwargs)
Section.get_next_by_modified(*moreargs, **morekwargs)
Section.get_previous_by_created(*moreargs, **morekwargs)
Section.get_previous_by_modified(*moreargs, **morekwargs)
Section.group
Section.node
Section.objects = <wiki.managers.PermissionManager object at 0x348fa50>
Section.owner
Section.render(preview_content=None)
Section.sectionrevision_set
class wiki.models.section.SectionNode(*args, **kwargs)

Bases: mptt.models.MPTTModel

SectionNode(id, parent_id, section_id, article_id, slug)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception SectionNode.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

SectionNode.article
SectionNode.children
SectionNode.objects = <mptt.managers.TreeManager object at 0x34995d0>
SectionNode.parent
SectionNode.section
class wiki.models.section.SectionRevision(*args, **kwargs)

Bases: wiki.models.article.BaseRevisionMixin, django.db.models.base.Model

This is where main revision data is stored. To make it easier to copy, do NEVER create m2m relationships.

SectionRevision is directly copied from ArticleRevision.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception SectionRevision.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

SectionRevision.current_set
SectionRevision.get_next_by_created(*moreargs, **morekwargs)
SectionRevision.get_next_by_modified(*moreargs, **morekwargs)
SectionRevision.get_previous_by_created(*moreargs, **morekwargs)
SectionRevision.get_previous_by_modified(*moreargs, **morekwargs)
SectionRevision.inherit_predecessor(section)

Inherit certain properties from predecessor because it’s very convenient. Remember to always call this method before setting properties :)

SectionRevision.objects = <django.db.models.manager.Manager object at 0x3489f50>
SectionRevision.previous_revision
SectionRevision.save(*args, **kwargs)
SectionRevision.section
SectionRevision.sectionrevision_set
SectionRevision.user
class wiki.models.urlpath.Namespace
class wiki.models.urlpath.URLPath(*args, **kwargs)

Bases: mptt.models.MPTTModel

Strategy: Very few fields go here, as most has to be managed through an article’s revision. As a side-effect, the URL resolution remains slim and swift.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

URLPath.INHERIT_PERMISSIONS = True
exception URLPath.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

URLPath.SLUG_MAX_LENGTH = 50
URLPath.article
URLPath.articles

This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.

URLPath.cached_ancestors

This returns the ancestors of this urlpath. These ancestors are hopefully cached from the article path lookup. Accessing a foreign key included in add_selecte_related on one of these ancestors will not occur an additional sql query, as they were retrieved with a select_related.

If the cached ancestors were not set explicitly, they will be retrieved from the database.

URLPath.children
URLPath.clean(*args, **kwargs)
classmethod URLPath.create_article(parent, slug, site=None, title='Root', article_kwargs={}, **kwargs)

Utility function: Create a new urlpath with an article and a new revision for the article

classmethod URLPath.create_root(site=None, title='Root', request=None, **kwargs)
URLPath.delete(*args, **kwargs)
URLPath.delete_subtree()

NB! This deletes this urlpath, its children, and ALL of the related articles. This is a purged delete and CANNOT be undone.

URLPath.first_deleted_ancestor()
URLPath.get_absolute_url(*moreargs, **morekwargs)
classmethod URLPath.get_by_path(path, select_related=False)

Strategy: Don’t handle all kinds of weird cases. Be strict. Accepts paths both starting with and without ‘/’

URLPath.is_deleted()

Returns True if this article or any of its ancestors have been deleted

URLPath.objects = <wiki.managers.URLPathManager object at 0x3499bd0>
URLPath.parent
URLPath.path
classmethod URLPath.root()
URLPath.save(*args, **kwargs)
URLPath.set_cached_ancestors_from_parent(parent)
URLPath.site
wiki.models.urlpath.on_article_delete(instance, *args, **kwargs)
wiki.models.urlpath.on_article_relation_save(**kwargs)

Module contents

wiki.models.reverse(*args, **kwargs)

Now this is a crazy and silly hack, but it is basically here to enforce that an empty path always takes precedence over an article_id such that the root article doesn’t get resolved to /ID/ but /.

Another crazy hack that this supports is transforming every wiki url by a function. If _transform_url is set on this function, it will return the result of calling reverse._transform_url(reversed_url) for every url in the wiki namespace.

Table Of Contents

This Page