U
    Lk7gú  ã                   @   s   i Z g Zd d„ ZdS )c                 C   sæ   | t krt  | ¡S d}tsFddlm} t |¡ ddlm} t |¡ t}d}| dkrjddlm} dg}nZ| |kr„ddl	m} |}n@| |kržddl	m
} |}n&| |kr¸ddl	m} |}ntd	|  ƒ‚|D ]}t||ƒt |< qÈt  | ¡S )
a™  Cache mechanism for imports.

    Due to complications of circular imports mongoengine needs to do lots of
    inline imports in functions.  This is inefficient as classes are
    imported repeated throughout the mongoengine code.  This is
    compounded by some recursive functions requiring inline imports.

    :mod:`mongoengine.common` provides a single point to import all these
    classes.  Circular imports aren't an issue as it dynamically imports the
    class when first needed.  Subsequent calls to the
    :func:`~mongoengine.common._import_class` can then directly retrieve the
    class from the :data:`mongoengine.common._class_registry_cache`.
    )ÚDocumentZDynamicEmbeddedDocumentZEmbeddedDocumentZMapReduceDocumenté    )Ú__all__)ZDeReferenceZBaseDocument)Údocument)Úfields)ÚdereferencezNo import set for: %s)Ú_class_registry_cacheÚgetÚ_field_list_cacheZmongoengine.fieldsr   ÚextendZmongoengine.base.fieldsZmongoengine.baser   Zmongoenginer   r   Ú
ValueErrorÚgetattr)Zcls_nameZdoc_classesr   Zfield_classesZderef_classesÚmoduleZimport_classesÚcls© r   ú6/tmp/pip-unpacked-wheel-n1etwkgt/mongoengine/common.pyÚ_import_class   s4    


r   N)r   r	   r   r   r   r   r   Ú<module>   s   