'Returns a query with all accessible records for the currently
logged-in user
@param method: the access method as string, one of:
"create", "read", "update" or "delete"
@param table: the table or table name
@param c: the controller name (overrides current.request)
@param f: the function name (overrides current.request)
@note: This method does not work on GAE because it uses JOIN and IN'

def s3_accessible_query(self, method, table, c=None, f=None):

    if self.override:
        return (table.id > 0)
    sr = self.get_system_roles()
    if (not hasattr(table, '_tablename')):
        table = current.s3db[table]
    policy = current.deployment_settings.get_security_policy()
    if (policy == 1):
        return (table.id > 0)
    elif (policy == 2):
        return (table.id > 0)
    elif (policy in (3, 4, 5, 6, 7, 8)):
        query = self.permission.accessible_query(method, table, c=c, f=f)
        return query
    if self.s3_has_role(sr.ADMIN):
        return (table.id > 0)
    try:
        user_id = self.user.id
    except:
        user_id = 0
    if self.has_permission(method, table, 0, user_id):
        return (table.id > 0)
    current.session.warning = current.T('Only    showing    accessible    records!')
    membership = self.settings.table_membership
    permission = self.settings.table_permission
    query = ((((membership.user_id == user_id) & (membership.group_id == permission.group_id)) & (permission.name == method)) & (permission.table_name == table))
    return table.id.belongs(current.db(query)._select(permission.record_id))
