Archive:Eden API changes: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Theuni
>Theuni
Line 8: Line 8:
*Do not assume the cwd is the root directory of the add-on. In-fact, the usage of cwd is highly discouraged.
*Do not assume the cwd is the root directory of the add-on. In-fact, the usage of cwd is highly discouraged.
*Do not use 'special://' paths with os python module functionality (file or directory create/delete/access/read/write/stat/etc).
*Do not use 'special://' paths with os python module functionality (file or directory create/delete/access/read/write/stat/etc).
*Newer python (2.5 and up) includes a python module. You should import sqlite3 instead. An acceptable import that works in both versions would be:
*Newer python (2.5 and up) includes a python module so there is no need for pysqlite. You should import sqlite3 instead. An acceptable import that works in both versions would be:
<source lang="python">
<source lang="python">
try:
try:

Revision as of 01:41, 16 April 2011

Eden will represent the first repository update, and as a result we have taken the opportunity to change the API for several subsystems. Any add-ons that are submitted for inclusion in Eden-pre and Eden will require compatibility with the new APIs.

The Eden-pre repository will be created soon, while the APIs may still change somewhat. When the APIs are frozen, the final Eden repository will open and final API compatibility will be enforced.

Scripts and Plugins

XBMC now uses an external version of Python rather than a self-built one. This brings many benefits but means that some plugins/scripts will have to change slightly. In order to be considered for inclusion in the Eden repository, the following must be true.

  • The addon.xml must require xbmc.python version 2.0 or higher. This enforces use of non-deprecated functions. See the Backwards-compatibility section below.
  • Do not assume the cwd is the root directory of the add-on. In-fact, the usage of cwd is highly discouraged.
  • Do not use 'special://' paths with os python module functionality (file or directory create/delete/access/read/write/stat/etc).
  • Newer python (2.5 and up) includes a python module so there is no need for pysqlite. You should import sqlite3 instead. An acceptable import that works in both versions would be:
try:
    from sqlite3 import dbapi2 as sqlite
    logFile.info("Loading sqlite3 as DB engine")
except:
    from pysqlite2 import dbapi2 as sqlite
    logFile.info("Loading pysqlite2 as DB engine")
  • The xbmc.vfs module is now available for disk operations. It is suitably abstracted and should work across all platforms.

Backwards Compatibility

If your add-on depends on xbmc.python version less than 2.0, backwards-compatibly mode is enabled. This was done in an effort to try to keep out-of-date addons working.

Certain deprecated functions like os.getcwd() will produce a warning in backwards-compatibility mode, whereas they will fail otherwise. Addons with this enabled will not be accepted into the Eden repo, they should instead be updated.

Skins

JsonRPC