0.23 Python bindings/Upcoming

From MythTV Official Wiki
Jump to: navigation, search

This page is to document new classes, methods, and behavior currently the development version of MythTV. During the current feature freeze, this will be used to document additions to be made after the branch of 0.23.

Deletions

All old classes and methods for partial backwards compatibility with the old 0.22 bindings will be removed. This includes:

  • MythTV()
Renamed to MythBE().
  • MythDB.getChannel()
Replaced by Channel().
  • MythDB.getGuideData()
Replaced by MythDB.searchGuide().
  • MythDB.getSetting
Accessible through MythDB.settings attribute.
  • MythDB.setSetting
Accessible through MythDB.settings attribute.
  • MythVideo.pruneMetadata()
Replaced by MythVideo.scanStorageGroups().
  • MythVideo.getTitleId()
Behavior not directly replaced, as there should be no need for direct search for IDs. Use MythVideo.searchVideos() instead.
  • MythVideo.getMetadataDictionary()
Accessible through dict(Video()).
  • MythVideo.setMetadata()
Replaced by Video.update().
  • MythVideo.getMetadataId()
Behavior not directly replaced, as there should be no need for direct search for IDs. Use MythVideo.searchVideos() instead.
  • MythVideo.hasMetadata()
Behavior not directly replaced. Use MythVideo.searchVideos() instead.
  • MythVideo.rmMetadata()
Replaced by Video.delete().
  • MythVideo.rtnVideoStorageGroup()
Replaced by MythDB.getStorageGroup(groupname='Videos').
  • MythVideo.getTableFieldNames()
Accessible through MythDB.tablefields attribute.
  • MythVideo.setCast()
Replaced by Video.cast.add().
  • MythVideo.setGenres()
Replaced by Video.genres.add().
  • MythVideo.setCountry()
Replaced by Video.country.add().
  • MythVideo.cleanCast()
Replaced by Video.cast.clean()
  • MythVideo.cleanGenres()
Replaced by Video.genre.clean()
  • MythVideo.cleanCountry()
Replaced by Video.country.clean()

Internal Renaming

Internal variables in the DictData family have been prepended with underscores, to prevent any possible name collisions with database field names. This should be transparent externally, but will cause problems if one has written subclasses.

The base connection classes have been renamed to DBConnection, BEConnection, and XMLConnection for the connections, and DBCache and BECache for the caches. The higher level classes (MythBE, MythDB, MythXML, MythVideo) will remain the same.

Socket Blocking

The socket code has been rewritten to be non-blocking. MythBE now accepts a 'timeout' keyword as the default for the connection, as does backendCommand for a one-time override.

Event System

Several classes have been added for interfacing with events being sent by the backend. As a result, BECache (and by proxy MythBE) have slightly different inputs. The 'type' keyword is replaced with a boolean 'noshutdown', to decide whether the connection will be 'Monitor' or 'Playback'.

BEEvent

This class adds event support to the base BECache class. It adds 'systemevents' and 'generalevents' keywords to denote which types it wants to receive. This class provides automatic registering of any handlers listed by the '_listhandlers' method. Any handlers registered using this method should optionally accept an event string. If the event is not given, it is to return a regular expression for matching against event strings.

Eventhandlers can be manually registered using the BEConnection.registerevent(regex, func) method.

MythSystemEvent

This class duplicates the event handling behavior of each frontend, backend, and jobqueue, introduced in changeset [23012]. Database defined actions can be overridden by providing a function of the same name as the event, in lowercase. The 'systemeventhandler' decorator class provides regular expressions and event string processing. Decorated methods are given a dictionary capable of being processed by the SystemEvent class.

SystemEvent

This is a modified System class, intended for processing and execution of system event command strings specified in the database.

System

The Grabber class has been renamed to System, to denote its use as a general purpose system call handler. Grabber is currently just a duplicate of System, and will likely be removed after 0.24.

QuickDictData

Adapted DictData class for arbitrary storage of data.

>>> a = QuickDictData((('val1',1),('val2',20)))
>>> a
<MythBase.QuickDictData object at 0x80375d6d0>
>>> a.items()
[('val1', 1), ('val2', 20)]
>>> a.val3 = 14
>>> a['val4'] = 12
>>> a.items()
[('val1', 1), ('val2', 20), ('val3', 14), ('val4', 12)]
>>> a.clear()
>>> a.items()
[]

MythDB.tablefields

This pseudo-variable has been updated to use the QuickDictData class, and to provide field attribute information.

>>> db = MythDB()
>>> db.tablefields.storagegroup
[u'id', u'groupname', u'hostname', u'dirname']
>>> db.tablefields.storagegroup[0]
u'id'
>>> db.tablefields.storagegroup.id.items()
[('type', u'int(11)'), ('null', u'NO'), ('key', u'PRI'), ('default', None), ('extra', u'auto_increment')]

MythDB.settings

This pseudo-variable has been updated to use the QuickDictData class, and provide a 'getall()' method.

>>> db = MythDB()
>>> db.settings.NULL.getall()
[('DBSchemaVer', u'1254'), ..., (u'NetvisionDBSchemaVer', u'1004')]

databaseSearch decorator

This class now allows searches against multiple cross referenced values.

>>> mvid = MythVideo()
>>> mvid.searchVideos(cast='Ed Harris')
[<Video 'The Right Stuff' at 0x803851950>, <Video 'The Abyss' at 0x803853e10>, <Video 'Apollo 13' at 0x803857490>]
>>> mvid.searchVideos(cast='Ed Harris,Tom Hanks')
[<Video 'Apollo 13' at 0x803855050>]