evennia-wiki API

evennia-wiki offers easy-to-use entry points into the wiki, so you can access and modify wiki pages very simply from your code.

Retrieving a page object

evennia_wiki.utils.get_content(address): get the page at the specific address. No permission control is done (it is assumed you have all privileges).

from evennia_wiki.utils import get_content

root = get_content("/") # get the root page or None
rule = get_content("/rule") # Get the /rule page or None

if rule:
    title = rule.title
    address = rule.address
    datetime = rule.created_on
    author = rule.author
    # do not modify these fields manually
    markdown = rule.content # last markdown content of the page
    html = rule.html # last HTML content of this page

The content and html attributes are automatic caches of the last revision’s Markdown and HTML content. Updating them manually is not advisable, rather, use the update_content or create_or_update_content utilities.

Updating content

Three utility functions are provided to create pages or update contents. The first one is probably the one you want to use as it’s more generic:

Here’s a very basic usage example:

from evennia import AccountDB
from evennia_wiki.utils import create_or_update_content

superuser = AccountDB.objects.get(id=1) # superuser always has ID 1
text = """
Welcome to my **game**.

It's really great!

- Check it out using the webclient.
- Built with [Evennia](www.evennia.com).

"""

page = create_or_update_content("/", superuser, text, force_update=False)
page.title = "The root page"
page.save()