Package isnLib :: Package img :: Module ShelfDB :: Class ShelfDB
[show private | hide private]
[frames | no frames]

Class ShelfDB

ImgDB --+
        |
       ShelfDB


This class implements the metadata/structured image database using python's shelve module.

All features independent of 'shelve' should be placed on ImgDB.py

Usage of shelve module, just for future reference:
---------------------
shelve module example
---------------------
import shelve

db = shelve.open("database", "c")
db["1"] = "one"
db["2"] = ["two","fooooo"]
db["3"] = "three"
db.close()
db = shelve.open("database", "r")
for key in db.keys():
    print repr(key), repr(db[key])

Method Summary
  __init__(self, env)
  addImg(self, fname)
TODO4: check if image path already in db returns -1 on error or newid on success
  checkNewFiles(self)
  checkSanity(self)
  delImg(self, id)
  extractEXIF(self, fid)
hook for exif library.
  extractIPTC(self, fid)
hook for iptc PIL library.
  getImgCount(self)
  getImgData(self, id)
  getImgDBStatus(self)
  getImgPath(self, id)
  getImgThumbData(self, id)
  getPopularity(self, id)
return at most nres popular image ids
  getRandomID(self)
  getRandomIDs(self, n)
returns UP TO n random ids.
  getThumbPath(self, id)
  hasID(self, id)
  maintain(self)
called from time to time to update cached sorted data
  onFinishedAdd(self, idList, newKey)
called when add job is done.
  open(self)
init c++ module db
  queryKeyword(self, key, nres)
return at most nres image ids with this key.
  queryMostPopular(self, nres)
return at most nres popular image ids
  queryRandom(self, count)
  regenThumbs(self, force)
#TODO3: finish - regenerate missing thumbnails.
  setImageKeyword(self, id, key)
  shutdown(self)
  sync(self, reopen)
save image database to disk.
    Inherited from ImgDB
  addDir(self, dirn, recurse, callback)
this function should be called by UI to add files.
  addFiles(self, files, status, callback)
this function is called recusively through reactor.callLater status is a list of values to be passed through calls: [number_of_added, number_of_rejected] files is the list of files that still has to be added
  calcSig(self, img)
  delDir(self, dirId)
  generateImageID(self)
need to return something unique
  getSig(self, id)
  getThumbName(self, fname)
return the thumbnail full path for the image given by fname (fname is full path)
  queryId(self, id, numres)
list querySig(self, sig, numres, thres)
query for similar images.

Method Details

addImg(self, fname)

TODO4: check if image path already in db returns -1 on error or newid on success
Overrides:
isnLib.img.Img_DB.ImgDB.addImg

extractEXIF(self, fid)

hook for exif library.
Parameters:
fid - set metadata for the image with this id.

extractIPTC(self, fid)

hook for iptc PIL library.
Parameters:
fid - set metadata for the image with this id.

getPopularity(self, id)

return at most nres popular image ids

getRandomIDs(self, n)

returns UP TO n random ids. This is done this way for performance reasons

maintain(self)

called from time to time to update cached sorted data

onFinishedAdd(self, idList, newKey)

called when add job is done.

The parm list here should match the one constructed on ImgDB.addFiles()

open(self, noisy=1)

init c++ module db
Overrides:
isnLib.img.Img_DB.ImgDB.open (inherited documentation)

queryKeyword(self, key, nres)

return at most nres image ids with this key. Sorted by popularity

queryMostPopular(self, nres)

return at most nres popular image ids

regenThumbs(self, force=0)

#TODO3: finish - regenerate missing thumbnails. if force, regen even if they already exist

sync(self, reopen=1)

save image database to disk.
Overrides:
isnLib.img.Img_DB.ImgDB.sync

Generated by Epydoc 2.0 on Thu Dec 25 10:59:57 2003 http://epydoc.sf.net