Changes between Version 10 and Version 11 of AddOns


Ignore:
Timestamp:
06/15/12 19:38:37 (23 months ago)
Author:
mitar
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • AddOns

    v10 v11  
    2727`docs` contains reST documentation of the add-on. `src` possible contains C/C++ source code. `datasets` any additional datasets add-on might use. 
    2828 
    29 Package name starts with `_` to signify it is for internal use only. Add-ons register through setuptools hook into Orange namespace. Use relative imports to access other modules inside the package, if possible. 
     29Package name starts with `_` to signify it is for internal use only. Add-ons register through setuptools' entry points (hooks) into Orange namespace. Use relative imports to access other modules inside the package, if possible. 
    3030 
    3131`setup.py`, `Makefile`, and `conf.py` as prepared in Biolab's add-ons can be used to get a good starting point for a new add-on. 
    3232 
    33 == Hooks == 
     33== Entry points (hooks) == 
     34 
     35The following [http://packages.python.org/distribute/setuptools.html#entry-points entry points] are defined and used by Orange: 
     36 
     37 `orange.addons`:: 
     38   Entry point to register add-on into Orange namespace. 
     39 `orange.widgets`:: 
     40   Entry point to add add-on's widgets to Orange canvas. 
     41 `orange.data.io.search_paths`:: 
     42   Entry point to add add-on's datasets' directory to search path for loading datasets. 
     43 
     44Example: 
     45 
     46{{{ 
     47ENTRY_POINTS = { 
     48    'orange.addons': ( 
     49        'foobar = _packagename', 
     50    ), 
     51    'orange.widgets': ( 
     52        'Foobar = _packagename.widgets', 
     53    ), 
     54    'orange.data.io.search_paths': ( 
     55        'packagename = _packagename:datasets', 
     56    ), 
     57} 
     58}}} 
     59 
     60These entry points will inject add-on under `Orange.foobar` namespace. So `_packagename.baz` will be accessible as `Orange.foobar.baz`. 
     61 
     62Widgets will be available under category named `Foobar`. 
     63 
     64And function `datasets` will be called to retrieve additional search paths. 
     65 
     66For example, accordingly to above entry point definition, it could be defined (or just exposed) in `_packagename/__init__.py` as: 
     67 
     68{{{ 
     69import pkg_resources 
     70 
     71def datasets(): 
     72    yield ('foobar', pkg_resources.resource_filename(__name__, 'datasets')) 
     73}}} 
     74` 
     75This would add datasets in `_packagename/datasets/` to the search path, with prefix `foobar`. So: 
     76 
     77{{{ 
     78data = Orange.data.Table("foobar:baz.tab") 
     79}}} 
     80 
     81would load `_packagename/datasets/baz.tab` file. 
    3482 
    3583== Distribution ==