<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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