Generate names for permissions.

def generate_permissions(urlpatterns, permissions={}):
    """Generate names for permissions."""
    for pattern in urlpatterns:
        if isinstance(pattern, urlresolvers.RegexURLPattern):
            perm = generate_perm_name(pattern.callback)
            if is_allowed_view(perm) and perm not in permissions:
                permissions[ACL_CODE_PREFIX + perm] = ACL_NAME_PREFIX + perm
        elif isinstance(pattern, urlresolvers.RegexURLResolver):
            generate_permissions(pattern.url_patterns, permissions)
    return permissions