
    BhM                     T    d dl mZmZ  G d d      Z G d d      Z G d de      Zy	)
    )ABCMetaabstractmethodc                   `     e Zd ZdZg Zg ZdZdZdZdZ	g Z
 fdZd Zd Zd Zd
dZd
d	Z xZS )CMSAppzBase class for creating apphooks. Apphooks live in a file called ``cms_apps.py``.
    To create an AppHook subclass ``CMSApp`` in ``cms_apps.py``
    ::
        class MyAppHook(CMSApp):
            name = "Problem solver"
    NTc                 D   | j                   rt        | j                   dd      r]| j                   j                  | k7  rDt        d| j                   j                  j                  d| j                   j                  d      | | j                   _        t
        |   |       S )z
        We want to bind the CMSapp class to a specific AppHookConfig, but only one at a time
        Checking for the runtime attribute should be a sane fix
        cmsappNz?Only one AppHook per AppHookConfiguration must exists.
AppHook z already defined for z AppHookConfig)
app_configgetattrr   RuntimeError__name__super__new__)cls	__class__s    </home/dcms/DCMS/lib/python3.12/site-packages/cms/app_base.pyr   zCMSApp.__new__   s~    
 >>s~~x63>>;P;PTW;W" --668O8O  %(CNN!ws##    c                     t        d      )zr
        Returns all the apphook configuration instances.

        To be implemented by apphook subclass.
        0Configurable AppHooks must implement this methodNotImplementedErrorselfs    r   get_configszCMSApp.get_configs,        ""TUUr   c                     t        d      )z
        Returns the apphook configuration instance linked to the given namespace

        To be implemented by apphook subclass.
        r   r   )r   	namespaces     r   
get_configzCMSApp.get_config4   r   r   c                     t        d      )z
        Returns the url to add a new apphook configuration instance
        (usually the model admin add view)

        To be implemented by apphook subclass.
        r   r   r   s    r   get_config_add_urlzCMSApp.get_config_add_url<   s     ""TUUr   c                     | j                   S )a  
        Returns the menus for the apphook instance, eventually selected according
        to the given arguments.

        By default, it returns the menus assigned to :py:attr:`CMSApp._menus`.

        The method accepts page, language and generic keyword arguments:
        you can customize this function to return different list of menu classes
        according to the given arguments.

        If no menus are returned, then the user will need to attach menus to pages
        manually in the admin.

        If no page and language are provided, this method **must** return **all the
        menus used by this apphook**. Example::

            if page and page.reverse_id == 'page1':
                return [Menu1]
            elif page and page.reverse_id == 'page2':
                return [Menu2]
            else:
                return [Menu1, Menu2]

        :param page: page the apphook is attached to
        :param language: current site language
        :return: list of menu classes
        )_menusr   pagelanguagekwargss       r   	get_menuszCMSApp.get_menusE   s    8 {{r   c                     | j                   S )a  
        Returns the urlconfs for the apphook instance, eventually selected
        according to the given arguments.

        By default, it returns the urls assigned to :py:attr:`CMSApp._urls`

        The method accepts page, language and generic keyword arguments:
        you can customize this function to return different list of menu classes
        according to the given arguments.

        This method **must** return a non-empty list of urlconfs,
        even if no argument is passed.

        :param page: page the apphook is attached to
        :param language: current site language
        :return: list of urlconfs strings
        )_urlsr"   s       r   get_urlszCMSApp.get_urlsc   s    $ zzr   )NN)r   
__module____qualname____doc__r(   r!   nameapp_namer	   permissionsexclude_permissionsr   r   r   r   r&   r)   __classcell__)r   s   @r   r   r      sS     EF D HJK$ VVV<r   r   c                       e Zd ZdZd Zy)CMSAppConfigaZ  
    .. versionadded:: 4.0

    Base class that all cms app configurations should inherit from.

    CMSAppConfig live in a file called ``cms_config.py``.

    Apps subclassing ``CMSAppConfig`` can set ``cms_enabled = True`` for their app config to
    use django CMS' wizard functionality. Additional wizzwards are listed in the app config's
    ``cms_wizzards`` property.

    The second functionality that django CMS offers is attaching Model objects to the toolbar. To use
    this functionality, set list the Model classes in ``cms_toolbar_enabled_models`` and have
    ``cms_enabled = True``
    c                     || _         y )N)r	   )r   django_app_configs     r   __init__zCMSAppConfig.__init__   s	    +r   N)r   r*   r+   r,   r6    r   r   r3   r3   x   s     ,r   r3   c                   &    e Zd ZdZed        Zd Zy)CMSAppExtensiona  
    .. versionadded:: 4.0

    Base class that all cms app extensions should inherit from. App extensions allow
    apps to offer their functionality to other apps, e.g., as done by djangocms-versioning.

    CMSAppExtensions live in a file called ``cms_config.py``.
    c                      y)a  
        Implement this method if the app provides functionality that
        other apps can use and configure.

        This method will be run once for every app that defines an
        attribute like ``<app_label>_enabled`` as ``True`` on its cms app
        config class.

        So for example, if app A with label "app_a" implements this
        method and app B and app C define ``app_a_enabled = True`` on their
        cms config classes, the method app A has defined will run twice,
        once for app B and once for app C.

        :param cms_config: the cms config class of the app registering for additional functionality
        :type cms_config: :class:`CMSAppConfig` subclass
        Nr7   )r   
cms_configs     r   configure_appzCMSAppExtension.configure_app   s    $ 	r   c                      y)zOverride this method to run code after all CMS extensions
        have been configured.

        This method will be run once, even if no cms app config sets
        its ``<app_label>_enabled`` attribute to ``True``Nr7   r   s    r   readyzCMSAppExtension.ready   s     	r   N)r   r*   r+   r,   r   r<   r>   r7   r   r   r9   r9      s       &r   r9   )	metaclassN)abcr   r   r   r3   r9   r7   r   r   <module>rA      s+    'q qh, ,*$ $r   