Tag-based Categorization

Content can be labelled in an ad-hoc fashion with tags. Typically tags will be displayed on the frontend using a ‘tag cloud’, rather than listing all tags. This means you can tag all you want!

class mediadrop.model.tags.Tag(name=None, slug=None)

Tag (keyword) for labelling content


Display name


A unique URL-friendly permalink string for looking up this object.


Convert a comma separated string into a list of tag names.

NOTE: The space-stripping here is necessary to patch a leaky abstraction.
MySQL’s string comparison with varchar columns is pretty fuzzy when it comes to space characters, and is even inconsistent between versions. We strip all preceding/trailing/duplicated spaces to be safe.

Return a list of Tag instances that match the given names.

Tag names that don’t yet exist are created automatically and returned alongside the results that did already exist.

If you try to create a new tag that would have the same slug as an already existing tag, the existing tag is used instead.

Parameters:tag_names (list) – The display
Returns:A list of Tag instances.
Return type:TagList instance


class mediadrop.model.categories.Category(name=None, slug=None)

Category Mapped Class


Return a list of ancestors, starting with the root node.

This method is optimized for when all categories have already been fetched in the current DBSession:

>>> Category.query.all()    # run one query
>>> row = Category.query.get(50)   # doesn't use a query
>>> row.parent    # the DBSession recognized the primary key
<Category: parent>
>>> print row.ancestors()
 <Category: great-grand-parent>,
 <Category: grand-parent>,
 <Category: parent>]

Return this category’s distance from the root of the tree.


Return a list of descendants in depth-first order.


Iterate over all nested categories in depth-first order.

You're reading the documentation for MediaDrop 0.11dev (current git master). For the latest stable release please consult the documentation for MediaCore CE 0.10.

Table Of Contents

Current topic

Previous topic


Next topic

Model Helpers

This Page