3
6ßL]>  ã               @   sN   d Z yddlZW n ek
r,   ddlZY nX dd„ Zdd„ Zdaejƒ adS )a¾   Manages a singleton updater that acts as a global registry.

    Our goal is to enable the apptools.sweet_pickle framework to
    understand how pickled data should be treated during unpickling so
    that the resulting object hierarchy reflects the current versions
    of the object's classes -AND- that this should work no matter who
    is doing the unpickling.  This requires a global registry since
    there is no way to know in advance what objects are contained within
    a given pickle file, and thus no way to gather the required
    information to know how to treat the pickle data during unpickling.

    For example, a pickle of an Envisage project may contain many
    custom classes, instantiated at the behest of various plugins,
    which have gone through various versionings and refactorings.  But
    it is the project plugin that needs to unpickle these objects to
    'load' a project, not the other plugins that added those custom
    class instances into the project.


    This registry is used by the apptools.sweet_pickle framework's
    unpickler only by default.   That is, only if no updater was
    explicitly provided.


    It is important that users interact with the registry through the
    provided methods.  If they do not, then the reference they receive
    will be the one that was in place at the time of the import which
    may or MAY NOT be the current repository due to the way this
    framework manages the repository.
é    Nc           
   C   s>   t dkr:tjƒ  zt dkr,ddlm}  | ƒ a W dtjƒ  X t S )zY Returns the global registry in a manner that allows for lazy
        instantiation.
    Né   )ÚUpdater)Ú_global_registryÚ_global_registry_lockÚacquireZupdaterr   Úrelease)r   © r   úK/tmp/pip-install-5sebvq2j/apptools/apptools/sweet_pickle/global_registry.pyÚget_global_registry3   s    

r
   c               C   s   da dS )zè Clears out the current global registry.

        This exists purely to allow testing of the global registry and the
        apptools.sweet_pickle framework.  THIS METHOD SHOULD NEVER BE
        CALLED DURING NORMAL OPERATIONS!
    N)r   r   r   r   r	   Ú_clear_global_registryP   s    r   )	Ú__doc__Ú_threadÚImportErrorÚ_dummy_threadr
   r   r   Úallocate_lockr   r   r   r   r	   Ú<module>'   s   