To be able to easily customize stoq/stoqlib outside of our svn a plugin system is needed. The design of the gedit-plugin system is most likely sufficient:
- an ini file describing the plugin and entrypoint
- a .py file with a class which implements:
- activate: loading the plugin
- get_migration: for getting a SchemaMigration subclass
That's generic enough for the plugin authors to be able to do everything they want.
However, we should provide a certain set of hooks so it's easy to listen for specific events such as:
- Creating a new Sale
- Adding a sellable item to a Sale
- Closing a Sale
It should use a simple observer pattern, similar to GObject, but it does not need to be that powerful. The idea is to be able to write support for Fiscal Printers without touching the rest of the core.
SQLObject is including a copy of PyDispatcher, it seems that it is sufficient for what we need.
Use case: ECF
The Fiscalprinter support in Stoq consists of:
- StartApplication: POS, Till
- Coupon events:
- add item
- remove item
- Admin app: ECFPrinterDialog, DeviceConstantEditor
- Till app: summary, memory
- POS app: summary, memory