Zinnia API

zinnia Package

Zinnia

apps Module

Apps for Zinnia

class zinnia.apps.ZinniaConfig(app_name, app_module)

Bases: django.apps.config.AppConfig

Config for Zinnia application.

label = 'zinnia'
name = 'zinnia'
ready()
verbose_name = <django.utils.functional.__proxy__ object>

breadcrumbs Module

Breadcrumb module for Zinnia

class zinnia.breadcrumbs.Crumb(name, url=None)

Bases: object

Part of the breadcrumbs.

zinnia.breadcrumbs.day_crumb(date)

Crumb for a day.

zinnia.breadcrumbs.entry_breadcrumbs(entry)

Breadcrumbs for an Entry.

zinnia.breadcrumbs.handle_page_crumb(func)

Decorator for handling the current page in the breadcrumbs.

zinnia.breadcrumbs.month_crumb(date)

Crumb for a month.

zinnia.breadcrumbs.retrieve_breadcrumbs(path, model, page, root_name)

Build a semi-hardcoded breadcrumbs based of the model’s url handled by Zinnia.

zinnia.breadcrumbs.year_crumb(date)

Crumb for a year.

calendar Module

Calendar module for Zinnia

class zinnia.calendar.Calendar

Bases: calendar.HTMLCalendar

Extension of the HTMLCalendar.

formatday(day, weekday)

Return a day as a table cell with a link if entries are published this day.

formatfooter(previous_month, next_month)

Return a footer for a previous and next month.

formatmonth(theyear, themonth, withyear=True, previous_month=None, next_month=None)

Return a formatted month as a table with new attributes computed for formatting a day, and thead/tfooter.

formatmonthname(theyear, themonth, withyear=True)

Return a month name translated as a table row.

formatweekday(day)

Return a weekday name translated as a table header.

formatweekheader()

Return a header for a week as a table row.

comparison Module

Comparison tools for Zinnia

class zinnia.comparison.CachedModelVectorBuilder(**kwargs)

Bases: zinnia.comparison.ModelVectorBuilder

Cached version of VectorBuilder.

cache

Get the cache from cache.

cache_backend

Try to access to comparison cache value, if fail use the default cache backend config.

cache_flush()

Flush the cache for this instance.

cache_key

Key for the cache.

columns_dataset

Implement high level cache system for columns and dataset.

get_cache()

Get the cache from cache.

Implement high level cache system for get_related.

set_cache(value)

Assign the cache in cache.

class zinnia.comparison.EntryPublishedVectorBuilder(**kwargs)

Bases: zinnia.comparison.CachedModelVectorBuilder

Vector builder for published entries.

cache_key

Key for the cache handling current site.

fields = ['title', 'lead', 'content', 'excerpt', 'image_caption', 'tags']
limit = 100
queryset = <zinnia.managers.EntryPublishedManager object>
class zinnia.comparison.ModelVectorBuilder(**kwargs)

Bases: object

Build a list of vectors based on a Queryset.

columns

Access to columns.

columns_dataset

Generate the columns and the whole dataset.

Compute the most related pks to an object’s pk.

dataset

Access to dataset.

fields = None

Return a list of the most related objects to instance.

limit = None
queryset = None
raw_clean(datas)

Apply a cleaning on raw datas.

raw_dataset

Generate a raw dataset based on the queryset and the specified fields.

zinnia.comparison.pearson_score(list1, list2)

Compute the Pearson’ score between 2 lists of vectors.

context_processors Module

Context Processors for Zinnia

zinnia.context_processors.version(request)

Add version of Zinnia to the context.

context Module

Context module for Zinnia

zinnia.context.get_context_first_matching_object(context, context_lookups)

Return the first object found in the context, from a list of keys, with the matching key.

zinnia.context.get_context_first_object(context, context_lookups)

Return the first object found in the context, from a list of keys.

zinnia.context.get_context_loop_positions(context)

Return the paginated current position within a loop, and the non-paginated position.

feeds Module

Feeds for Zinnia

class zinnia.feeds.AuthorEntries

Bases: zinnia.feeds.EntryFeed

Feed filtered by an author.

description(obj)

Description of the feed.

get_object(request, username)

Retrieve the author by his username.

get_title(obj)

Title of the feed.

items(obj)

Items are the published entries of the author.

URL of the author.

class zinnia.feeds.CategoryEntries

Bases: zinnia.feeds.EntryFeed

Feed filtered by a category.

description(obj)

Description of the feed.

get_object(request, path)

Retrieve the category by his path.

get_title(obj)

Title of the feed.

items(obj)

Items are the published entries of the category.

URL of the category.

class zinnia.feeds.DiscussionFeed

Bases: zinnia.feeds.ZinniaFeed

Base class for discussion Feed.

description_template = 'feeds/discussion_description.html'
item_author_email(item)

Author’s email of the discussion item.

Author’s URL of the discussion.

item_author_name(item)

Author of the discussion item.

URL of the discussion item.

item_pubdate(item)

Publication date of a discussion.

title_template = 'feeds/discussion_title.html'
class zinnia.feeds.EntryComments

Bases: zinnia.feeds.EntryDiscussions

Feed for comments on an entry.

description(obj)

Description of the feed.

description_template = 'feeds/comment_description.html'
get_title(obj)

Title of the feed.

item_enclosure_length(item)

Hardcoded enclosure length.

item_enclosure_mime_type(item)

Hardcoded enclosure mimetype.

item_enclosure_url(item)

Return a gravatar image for enclosure.

URL of the comment.

items(obj)

Items are the comments on the entry.

title_template = 'feeds/comment_title.html'
class zinnia.feeds.EntryDiscussions

Bases: zinnia.feeds.DiscussionFeed

Feed for discussions on an entry.

description(obj)

Description of the feed.

get_object(request, year, month, day, slug)

Retrieve the discussions by entry’s slug.

get_title(obj)

Title of the feed.

items(obj)

Items are the discussions on the entry.

URL of the entry.

class zinnia.feeds.EntryFeed

Bases: zinnia.feeds.ZinniaFeed

Base Entry Feed.

description_template = 'feeds/entry_description.html'
item_author_email(item)

Return the first author’s email. Should not be called if self.item_author_name has returned None.

Return the author’s URL. Should not be called if self.item_author_name has returned None.

item_author_name(item)

Return the first author of an entry.

item_categories(item)

Entry’s categories.

item_enclosure_length(item)

Try to obtain the size of the enclosure if it’s present on the FS, otherwise returns an hardcoded value. Note: this method is only called if item_enclosure_url has returned something.

item_enclosure_mime_type(item)

Guess the enclosure’s mimetype. Note: this method is only called if item_enclosure_url has returned something.

item_enclosure_url(item)

Return an image for enclosure.

item_pubdate(item)

Publication date of an entry.

item_updateddate(item)

Update date of an entry.

title_template = 'feeds/entry_title.html'
class zinnia.feeds.EntryPingbacks

Bases: zinnia.feeds.EntryDiscussions

Feed for pingbacks on an entry.

description(obj)

Description of the feed.

description_template = 'feeds/pingback_description.html'
get_title(obj)

Title of the feed.

URL of the pingback.

items(obj)

Items are the pingbacks on the entry.

title_template = 'feeds/pingback_title.html'
class zinnia.feeds.EntryTrackbacks

Bases: zinnia.feeds.EntryDiscussions

Feed for trackbacks on an entry.

description(obj)

Description of the feed.

description_template = 'feeds/trackback_description.html'
get_title(obj)

Title of the feed.

URL of the trackback.

items(obj)

Items are the trackbacks on the entry.

title_template = 'feeds/trackback_title.html'
class zinnia.feeds.LastDiscussions

Bases: zinnia.feeds.DiscussionFeed

Feed for the last discussions.

description()

Description of the feed.

get_title(obj)

Title of the feed.

items()

Items are the discussions on the entries.

URL of last discussions.

class zinnia.feeds.LastEntries

Bases: zinnia.feeds.EntryFeed

Feed for the last entries.

description()

Description of the feed.

get_title(obj)

Title of the feed

items()

Items are published entries.

URL of last entries.

class zinnia.feeds.SearchEntries

Bases: zinnia.feeds.EntryFeed

Feed filtered by a search pattern.

description(obj)

Description of the feed.

get_object(request)

The GET parameter ‘pattern’ is the object.

get_title(obj)

Title of the feed.

items(obj)

Items are the published entries founds.

URL of the search request.

class zinnia.feeds.TagEntries

Bases: zinnia.feeds.EntryFeed

Feed filtered by a tag.

description(obj)

Description of the feed.

get_object(request, tag)

Retrieve the tag by his name.

get_title(obj)

Title of the feed.

items(obj)

Items are the published entries of the tag.

URL of the tag.

class zinnia.feeds.ZinniaFeed

Bases: django.contrib.syndication.views.Feed

Base Feed class for the Zinnia application, enriched for a more convenient usage.

feed_format = 'rss'
get_title(obj)
limit = 15
protocol = 'http'
site

Acquire the current site used.

site_url

Return the URL of the current site.

title(obj=None)

Title of the feed prefixed with the site name.

flags Module

Comment flags for Zinnia

zinnia.flags.get_user_flagger(*args, **kwds)

Return an User instance used by the system when flagging a comment as trackback or pingback.

managers Module

Managers of Zinnia

class zinnia.managers.EntryPublishedManager

Bases: django.db.models.manager.Manager

Manager to retrieve published entries.

Advanced search on entries.

Basic search on entries.

get_queryset()

Return published entries.

on_site()

Return entries published on current site.

search(pattern)

Top level search method on entries.

class zinnia.managers.EntryRelatedPublishedManager

Bases: django.db.models.manager.Manager

Manager to retrieve objects associated with published entries.

get_queryset()

Return a queryset containing published entries.

zinnia.managers.entries_published(queryset)

Return only the entries published.

zinnia.managers.tags_published()

Return the published tags.

markups Module

Set of” markup” function to transform plain text into HTML for Zinnia. Code originally provided by django.contrib.markups

zinnia.markups.html_format(value)

Returns the value formatted in HTML, depends on MARKUP_LANGUAGE setting.

zinnia.markups.markdown(value, extensions=[])

Markdown processing with optionally using various extensions that python-markdown supports. extensions is an iterable of either markdown.Extension instances or extension paths.

zinnia.markups.restructuredtext(value, settings={})

RestructuredText processing with optionnally custom settings.

zinnia.markups.textile(value)

Textile processing.

moderator Module

Moderator of Zinnia comments

class zinnia.moderator.EntryCommentModerator(model)

Bases: django_comments.moderation.CommentModerator

Moderate the comments on entries.

auto_close_field = 'start_publication'
auto_moderate_comments = False
close_after = None
do_email_authors(comment, entry, site)

Send email notification of a new comment to the authors of the entry.

do_email_notification(comment, entry, site)

Send email notification of a new comment to site staff.

do_email_reply(comment, entry, site)

Send email notification of a new comment to the authors of the previous comments.

email(comment, entry, request)

Send email notifications needed.

email_authors = True
email_reply = False
enable_field = 'comment_enabled'
mail_comment_notification_recipients = []
moderate(comment, entry, request)

Determine if a new comment should be marked as non-public and await approval. Return True to put the comment into the moderator queue, or False to allow it to be showed up immediately.

spam_checker_backends = []

ping Module

Pings utilities for Zinnia

class zinnia.ping.DirectoryPinger(server_name, entries, timeout=10)

Bases: threading.Thread

Threaded web directory pinger.

ping_entry(entry)

Ping an entry to a directory.

run()

Ping entries to a directory in a thread.

class zinnia.ping.ExternalUrlsPinger(entry, timeout=10)

Bases: threading.Thread

Threaded external URLs pinger.

find_external_urls(entry)

Find external URLs in an entry.

find_pingback_href(content)

Try to find LINK markups to pingback URL.

find_pingback_urls(urls)

Find the pingback URL for each URLs.

is_external_url(url, site_url)

Check if the URL is an external URL.

pingback_url(server_name, target_url)

Do a pingback call for the target URL.

run()

Ping external URLs in a Thread.

class zinnia.ping.URLRessources

Bases: object

Object defining the ressources of the Website.

preview Module

Preview for Zinnia

class zinnia.preview.HTMLPreview(content, lead='', splitters=['<!-- more -->', '<!--more-->'], max_words=55, more_string=' ...')

Bases: object

Build an HTML preview of an HTML content.

build_preview()

Build the preview by:

  • Returning the lead attribut if not empty.
  • Checking if a split marker is present in the content Then split the content with the marker to build the preview.
  • Splitting the content to a fixed number of words.
displayed_percent

Return the percentage of the content displayed in the preview.

displayed_words

Return the number of words displayed in the preview.

has_more

Boolean telling if the preview has hidden content.

preview

The preview is a cached property.

remaining_percent

Return the percentage of the content remaining after the preview.

remaining_words

Return the number of words remaining after the preview.

split(splitter)

Split the HTML content with a marker without breaking closing markups.

total_words

Return the total of words contained in the content and in the lead.

truncate()

Truncate the content with the Truncator object.

search Module

Search module with complex query parsing for Zinnia

Parse the grammar of a pattern and build a queryset with it.

zinnia.search.create_q(token)

Creates the Q() object.

zinnia.search.union_q(token)

Appends all the Q() objects.

signals Module

Signal handlers of Zinnia

zinnia.signals.connect_discussion_signals()

Connect all the signals on the Comment model to maintains a valid discussion count on each entries when an action is done with the comments.

zinnia.signals.connect_entry_signals()

Connect all the signals on Entry model.

zinnia.signals.count_comments_handler(sender, **kwargs)

Update Entry.comment_count when a public comment was posted.

zinnia.signals.count_discussions_handler(sender, **kwargs)

Update the count of each type of discussion on an entry.

zinnia.signals.count_pingbacks_handler(sender, **kwargs)

Update Entry.pingback_count when a pingback was posted.

zinnia.signals.count_trackbacks_handler(sender, **kwargs)

Update Entry.trackback_count when a trackback was posted.

zinnia.signals.disable_for_loaddata(signal_handler)

Decorator for disabling signals sent by ‘post_save’ on loaddata command. http://code.djangoproject.com/ticket/8399

zinnia.signals.disconnect_discussion_signals()

Disconnect all the signals on Comment model provided by Zinnia.

zinnia.signals.disconnect_entry_signals()

Disconnect all the signals on Entry model.

zinnia.signals.flush_similar_cache_handler(*args, **kwargs)

Flush the cache of similar entries when an entry is saved.

zinnia.signals.ping_directories_handler(*args, **kwargs)

Ping directories when an entry is saved.

zinnia.signals.ping_external_urls_handler(*args, **kwargs)

Ping externals URLS when an entry is saved.

sitemaps Module

Sitemaps for Zinnia

class zinnia.sitemaps.AuthorSitemap

Bases: zinnia.sitemaps.EntryRelatedSitemap

Sitemap for authors.

model

alias of Author

class zinnia.sitemaps.CategorySitemap

Bases: zinnia.sitemaps.EntryRelatedSitemap

Sitemap for categories.

model

alias of Category

class zinnia.sitemaps.EntryRelatedSitemap

Bases: zinnia.sitemaps.ZinniaSitemap

Sitemap for models related to Entries.

cache_infos(queryset)

Cache infos like the number of entries published and the last modification date for standardized access later.

changefreq = 'monthly'
get_queryset()

Build a queryset of items with published entries and annotated with the number of entries and the latest modification date.

items()

Get a queryset, cache infos for standardized access to them later then compute the maximum of entries to define the priority of each items.

lastmod(item)

The last modification date is defined by the latest entry last update in the cache.

model = None
priority(item)

The priority of the item depends of the number of entries published in the cache divided by the maximum of entries.

set_max_entries()

Define the maximum of entries for computing the priority of each items later.

class zinnia.sitemaps.EntrySitemap

Bases: zinnia.sitemaps.ZinniaSitemap

Sitemap for entries.

changefreq = 'weekly'
items()

Return published entries.

lastmod(obj)

Return last modification of an entry.

priority = 0.5
class zinnia.sitemaps.TagSitemap

Bases: zinnia.sitemaps.EntryRelatedSitemap

Sitemap for tags.

cache_infos(queryset)

Cache the number of entries published and the last modification date under each tag.

get_queryset()

Return the published Tags with option counts.

location(item)

Return URL of the tag.

class zinnia.sitemaps.ZinniaSitemap

Bases: django.contrib.sitemaps.Sitemap

Base Sitemap class for Zinnia.

protocol = 'http'

templates Module

Templates module for Zinnia

zinnia.templates.append_position(path, position, separator='')

Concatenate a path and a position, between the filename and the extension.

zinnia.templates.loop_template_list(loop_positions, instance, instance_type, default_template, registry)

Build a list of templates from a position within a loop and a registry of templates.