'Constructor, invoked by AuthS3.__init__
@param auth: the AuthS3 instance
@param tablename: the name for the permissions table'

def __init__(self, auth, tablename=None):

    db = current.db
    self.auth = auth
    self.error = S3PermissionError
    settings = current.deployment_settings
    self.policy = settings.get_security_policy()
    self.use_cacls = (self.policy in (3, 4, 5, 6, 7, 8))
    self.use_facls = (self.policy in (4, 5, 6, 7, 8))
    self.use_tacls = (self.policy in (5, 6, 7, 8))
    self.entity_realm = (self.policy in (6, 7, 8))
    self.entity_hierarchy = (self.policy in (7, 8))
    self.delegations = (self.policy == 8)
    self.tablename = (tablename or self.TABLENAME)
    if (self.tablename in db):
        self.table = db[self.tablename]
    else:
        self.table = None
    T = current.T
    self.INSUFFICIENT_PRIVILEGES = T('Insufficient    Privileges')
    self.AUTHENTICATION_REQUIRED = T('Authentication    Required')
    request = current.request
    self.controller = request.controller
    self.function = request.function
    self.format = s3_get_extension()
    self.record_approval = settings.get_auth_record_approval()
    self.strict_ownership = settings.get_security_strict_ownership()
    self.clear_cache()
    self.unrestricted_pages = ('default/index', 'default/user', 'default/contact', 'default/about')
    _next = URL(args=request.args, vars=request.get_vars)
    self.homepage = URL(c='default', f='index')
    self.loginpage = URL(c='default', f='user', args='login', vars=dict(_next=_next))
