# vim: tabstop=4 shiftwidth=4 expandtab
"""
C{README} multiauthor
This plugin adds the variable $author that can be used in a
story template.  It corresponds to the UID of the poster
"""
import Pyblosxom, os, pwd, sys
from stat import *
from Pyblosxom.pyblosxom import Request
from Pyblosxom.renderers.blosxom import BlosxomRenderer
from Pyblosxom.entries.base import EntryBase
from Pyblosxom.pyblosxom import PyBlosxom
def cb_story(args = {'renderer':'The Blosxom renderer',
                     'entry':'The entry to render',
                     'template':'The template to be filled in'}):
    """
    set story-author to whoever owns the file
    """
    f = args['entry'].getMetadata('filename')
    owner = os.stat(f)[ST_UID]
    author = pwd.getpwuid(owner)[0]
    args['entry'].setMetadata('story-author', author)
