StorageFactory.py

Go to the documentation of this file.
00001 ## \package StorageFactory
00002 # Singleton - makes storage mechanism
00003 # \author mullerb@musc.edu
00004 
00005 import GOError
00006 import Storage
00007 
00008 
00009 ## Simple singleton factory for making storage mechanisms
00010 # \see Storage.BasicStorage
00011 class StorageFactory:
00012     __state = {}
00013     ## Constructor.  All instances share state.
00014     def __init__(self):
00015         self.__dict__ = self.__state
00016 
00017     ## Return an instance the class requested
00018     # @param stype The storage type to make
00019     # @param args Additional arguments for the storage type (if any)
00020     # @param kwargs Additional keyword arguments for the storage type (if any)    
00021     # \return The class requested if it exists, Storage.BasicStorage otherwise.
00022     # \see Storage.__init__.Types
00023     @classmethod
00024     def makeStorage(klass, stype, *args, **kwargs):
00025         error = GOError.GOError()
00026         if stype == Storage.Types.MYSQL:
00027             return Storage.MysqlStorage(*args, **kwargs)
00028         elif stype == Storage.Types.FILEBASED:
00029             return Storage.FilebasedStorage(*args, **kwargs)
00030         else:
00031             error.handleFatal("Attept to create non existant storage in the factory: %s" % stype)

Generated on Tue Apr 7 11:34:50 2009 for GOGrapher by  doxygen 1.5.6