
    Bh[                     V    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  G d de	      Z
y)	    )ValidationError)Q)apphook_pool)Page)Menuc                   N     e Zd ZdZdZdZdZ fdZed        Z	ed        Z
 xZS )CMSAttachMenuzLBase class that can be subclassed to allow your app to attach its own menus.TNc                     t        |   |i | | j                  r/| j                  s"t	        d| j
                  j                  z        y y )Nz7the menu %s is a CMSAttachMenu but has no name defined!)super__init__cms_enablednamer   	__class____name__)selfargskwargsr   s      >/home/dcms/DCMS/lib/python3.12/site-packages/cms/menu_bases.pyr   zCMSAttachMenu.__init__   sN    $)&)DII!I''() ) %.    c                     g }t        j                         D ]>  \  }}t        j                  |      }| |j                         v s.|j	                  |       @ |S )z
        Returns a list of apphooks to which this CMSAttachMenu is attached.

        Calling this does **not** produce DB queries.
        )r   get_apphooksget_apphook	get_menusappend)clsappskey_apps        r   r   zCMSAttachMenu.get_apphooks   sV     "//1 	!FC**3/Ccmmo%C 	! r   c                     g }| j                         D ]'  }|j                  |j                  j                         ) t        j
                  j                  t        |      t        | j                        z        S )z
        Return a queryset of all CMS Page objects (in this case)
        that are currently using this CMSAttachMenu either directly as a
        navigation_extender, or, as part of an apphook.

        Calling this **does** perform a DB query.
        )application_urls__in)navigation_extenders)r   r   r   r   r   objectsfilterr   )r   parent_appsr   s      r   get_instanceszCMSAttachMenu.get_instances$   si     ##% 	7Cs}}556	7||"";/S\\23
 	
r   )r   
__module____qualname____doc__r   instancer   r   classmethodr   r&   __classcell__)r   s   @r   r	   r	   	   sB    VKHD)   
 
r   r	   N)django.core.exceptionsr   django.db.modelsr   cms.apphook_poolr   
cms.modelsr   
menus.baser   r	    r   r   <module>r3      s     2  )  *
D *
r   