#780: BibCatalog: fix instantiation of abstract class
-------------------------+--------------------
Reporter: jlavik | Owner: jlavik
Type: enhancement | Status: new
Priority: major | Milestone:
Component: BibCatalog | Version:
Keywords: |
-------------------------+--------------------
The class BibCatalogSystem is considered a template/abstract class in
bibcatalog_system.py, but it is instantiated when the BibCatalog interface
is called (bibcatalog.py). An abstract class should not be instantiated as
a concept in it self as the template object is useless on it's own,
containing no implementations of its methods.
Currently, if a system is configured to use a sub-class of
BibCatalogSystem, the abstract object is replaced with the implemented
sub-class when the interface is called. However, this behaviour can lead
to confusion when the system is not configured to any ticket system (like
RT), and clients calling BibCatalog are given an instantiation of an
abstract class, expecting something usable (or None).
Therefore the following changes are proposed:
* The interface for BibCatalogSystem (and sub-classes) (bibcatalog.py)
should not instantiate the abstract class BibCatalogSystem and rather
return None if no ticket system is defined.
* The current clients using the BibCatalog classes should be amended to
call the BibCatalog interface, but have checks to see if none are
available.
* OAI harvest deamon (oai_harvest_deamon.py) should be amended to call
BibCatalog interface and not BibCatalogSystemRT directly. This also
includes adding a check of the returned value as above.
* Let the methods in BibCatalogSystem raise NotImplementedError instead of
'pass' when trying to call a function from an instantiated object. Amend
method docstrings as well in BibCatalogSystem to show this change (@raise
etc.).
* Also update any documentation and add tests if time permits.
--
Ticket URL: <http://invenio-software.org/ticket/780>
Invenio <http://invenio-software.org>