"""
    MoinMoin - LicensePage action

    Allows users to specify a license for a particular page.

    @copyright: 2007 Nathan R. Yergler <nathan@yergler.net>
    @license: GNU GPL, see COPYING for details.
"""

import os
import urllib
import urllib2

from MoinMoin import wikiutil
from MoinMoin.Page import Page
from MoinMoin.PageEditor import PageEditor
from MoinMoin.action import ActionBase

from license import LicenseActionBase

class LicensePage(LicenseActionBase):
    """ License page action
    """

    LICENSE_PAGE_TEXT="""This page is licensed under the [%(license_uri)s %(license_name)s] license."""

    def __init__(self, pagename, request):
        LicenseActionBase.__init__(self, pagename, request)

        self.form_trigger_label = self._('License Page')

    def is_allowed(self):
        may = self.request.user.may
        return may.write(self.pagename)


    def get_license_pagename(self, pagename):
        """Return the page name where license information for this page
        is stored."""

        return "%s/%s" % (pagename, 'PageLicense')

def execute(pagename, request):
    """ Glue code for actions """
    LicensePage(pagename, request).render()

