Class hierarchy

Class Entities

Currently, picurl consists of three class entities:

  • a store class, that provides an abstracted interface to store specific file access (e.g. FTP commands, picasa requests,...)
  • an image class, which is instantiated for each image located on a store. it offers access to the image data itself and some metadata (filename, resolution,...)
  • a store manager class, that deals with the different store objects and passes requests to them.

Developping a store plugin

you can add support for new stores (e.g. PHP Gallery,..) to picurl by writing a store plugin. This is a python module that subclasses both PicurlStoreand PicurlImageclasses and wraps the store specific file access in these classes. So your plugin consists of two classes:

  • MyStore (PicurlStore)
  • MyStoreImage (PicurlImage)

Required functionality

it must redefine the methods below to provide the following functionalities:

  • authentication (if necessary)
  • read and write access (read-only stores do not need to implement the addImage/deleteImage methods. calling these methods on such stores will therefore raise a picurlException.StoreNotWriteable)
  • retrieve a list of all picurlImages on the store.

Registering the plugin

Your plugin will reside in the store subdirectory. it must import the picurl.py module from the main directory and call the StoreManager.register() method with the following parameters: tbd...

import picurl

class PicurlStore:

    def get_imagetype (self):
        pass
    
    def list_images (self,fnmatchexpr=None):
        pass

    def refresh (self):
        pass

    def delete_image (self, filename):
        raise picurlException.StoreNotWriteable

    def list_images (self,fnmatchexpr=None):
        pass

    def add_image (self, picurlImage):
     """returns a new picurl Image object for the store"""
        raise picurlException.StoreNotWriteable

#call picurl.register (protocol,????) to register your plugin.

class PicurlImage:
    def __init__ (self, location, mode="rb",**kw):
        self.location = location
        self.mode = mode
        self.__dict__.update(kw) # update class namespace with optional init arguments
        self._init()
        
    def read (self,bytes=None):
        raise picurlExceptions.FileNotReadable

    def get_localfilepath (self):
        raise picurlExceptions.LocalFilePathDoesNotExist

    def get_bytes_read (self):
        raise picurlExceptions.FileNotReadable

    def get_filename (self):
        raise picurlExceptions.FileNotReadable

    def get_file_size (self):
        raise picurlExceptions.NotImplemented
    
    def _init (self):
        pass

StoreManager class (relevant for plugin registration)

class StoreManager:
"""interacts with the stores - to be defined """
  pass

Stores -> StoreManager interaction cf http://svn.berlios.de/svnroot/repos/gpodder/trunk/src/gpodder/libconverter.py