Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Plugin-System - HOWTO
    primarykey
    data
    text
    <p>I'm writing a Python application which stores some data. For storing the data i've wrote a Connection class with abstract methods (using Python's abc module). This class is the super class all storage back-ends derive from. Each storage back-end has only one purpose, e.g. storing the data in plain text files or in a XML file.</p> <p>All storage backends (inclusive the module where the super class is located) are in one package called 'data_handler'. And each back-end is in one module.</p> <p>My application should be able the store data in multiple back-ends simultaneously and determinate at runtime which storage back-ends are available. To do this i had the idea to write a singleton class where each back-end have to register at their import. But this seems to be not so good in a dynamic language (please correct me if I misinterpret this). Another way could be the import of the package with <code>import data_handler</code> and then get the <code>__file__</code> attribute of the package and search all Python files in the dir for subclasses of the super Connection class.</p> <p>What method should I use, or are there other (maybe better) methods to do this.</p> <p>Stefan</p> <hr> <blockquote> <p><em>Is discovering the back-ends at runtime a strict requirement or would static enumeration of them in the code do?</em></p> </blockquote> <p>This feature will be nice to note have to edit the code when I add a new back-end</p> <hr> <blockquote> <p><em>But should your application always write to all backends?</em></p> </blockquote> <p>I will have a class where I can register available handler. And the data shall be written to each registered handler. But not all available handlers have to be registered.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload