"""
Give automatic admin rights for users for their home page or sub pages.

Bypass page acl for the "owner" of the page, use page acl for other 
users. Amdins always has admin rights if they are in acl_rights_before.

Note that anyone can register with an existing page name and then admin that page ignoring the page acl.
"""

# If you want to use antispam, sub class from antispam:
# from MoinMoin.util.antispam import SecurityPolicy as Permissions
from MoinMoin.security import Permissions

from MoinMoin import wikiutil

class SecurityPolicy(Permissions):
    def admin(self, pagename):
        # Give right if page name starts with username, bypassing page acl
        if (self.request.user.valid and 
            pagename.startswith(self.request.user.name) and
            (not wikiutil.isSystemPage(self.request, pagename))):
            return True

        # Use base class policy:
        return Permissions.__getattr__(self, 'admin')(pagename)
        