Mercurial > hg > orthanc-book
comparison Sphinx/source/plugins/python.rst @ 748:a296fe06fd86
Implementing a custom storage area in Python
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 12 Aug 2021 17:51:54 +0200 |
parents | 56d48f6e52cc |
children | 4e9dc26a5cb9 |
comparison
equal
deleted
inserted
replaced
747:56d48f6e52cc | 748:a296fe06fd86 |
---|---|
713 | 713 |
714 .. literalinclude:: python/exception.py | 714 .. literalinclude:: python/exception.py |
715 :language: python | 715 :language: python |
716 | 716 |
717 | 717 |
718 .. _python_storage_area: | |
719 | |
720 Implementing a custom storage area (new in 3.3) | |
721 ............................................... | |
722 | |
723 Starting with release 3.3 of the Python plugin, it is possible to | |
724 replace the built-in storage area of Orthanc (that writes | |
725 :ref:`attachments <metadata>` onto the filesystem in the | |
726 ``OrthancStorage`` folder by default), by providing 3 Python callbacks | |
727 to the ``orthanc.RegisterStorageArea()`` function: | |
728 | |
729 * The first callback indicates how to **create** an attachment into | |
730 the storage area. | |
731 | |
732 * The second callback indicates how to **read** an attachment from the | |
733 storage area. | |
734 | |
735 * The third callback indicates how to **remove** an attachment out of | |
736 the storage area. | |
737 | |
738 This feature can be used to quickly and easily interface Orthanc with | |
739 any `object-based storage | |
740 <https://en.wikipedia.org/wiki/Object_storage>`__ technology available | |
741 in Python (such as `Ceph | |
742 <https://en.wikipedia.org/wiki/Ceph_(software)>`__ or AWS S3-like | |
743 tools). The performance will not be as good as a C/C++ native plugin | |
744 (cf. the :ref:`cloud storage <object-storage>`, the :ref:`PostgreSQL | |
745 <postgresql>` and the :ref:`MySQL <mysql>` plugins), but it can be | |
746 used for prototyping or for basic setups. | |
747 | |
748 Here is a full, self-explaining sample: | |
749 | |
750 .. literalinclude:: python/storage-area.py | |
751 :language: python | |
752 | |
753 The ``contentType`` can be used to apply a special treatment to some | |
754 types of attachments (typically, DICOM instances). This parameter | |
755 takes its values from the ``orthanc.ContentType`` enumeration. | |
756 | |
757 | |
718 Performance and concurrency | 758 Performance and concurrency |
719 --------------------------- | 759 --------------------------- |
720 | 760 |
721 **Important:** This section only applies to UNIX-like systems. The | 761 **Important:** This section only applies to UNIX-like systems. The |
722 ``multiprocessing`` package will not work on Microsoft Windows as the | 762 ``multiprocessing`` package will not work on Microsoft Windows as the |