コード例 #1
0
 def get_persistence_instance():
     if((ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH]=="") and \
             (ZohoOAuthConstants.CUSTOM_PERSISTENCE_HANDLER_PATH not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ZohoOAuthConstants.CUSTOM_PERSISTENCE_HANDLER_PATH] == "")):
         return ZohoOAuthPersistenceHandler()
     elif((ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH in ZohoOAuth.configProperties) and ZohoOAuth.configProperties[ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH] != ""):
         return ZohoOAuthPersistenceFileHandler()
     else:
         try:
             from sys import path
             import importlib
             custompersistence_handler = ZohoOAuth.configProperties[ZohoOAuthConstants.CUSTOM_PERSISTENCE_HANDLER_PATH]
             custompersistence_classname = ZohoOAuth.configProperties[ZohoOAuthConstants.CUSTOM_PERSISTENCE_HANDLER_CLASS]
             if custompersistence_classname == "":
                 raise ZohoOAuthException("Token Persistence Class must be given.")
             splitter = "/" if "/" in custompersistence_handler else "\\"
             custompersistence_directory = custompersistence_handler.strip(custompersistence_handler.split(splitter)[-1]).rstrip(splitter)
             path.append(custompersistence_directory)
             custompersistence_modulename = custompersistence_handler.split(splitter)[-1].rstrip(".py")
             try:
                 custompersistence_module = importlib.import_module(custompersistence_modulename)
                 custompersistence_class = getattr(custompersistence_module, custompersistence_classname)
                 custompersistence_instance = custompersistence_class()
                 return custompersistence_instance
             except Exception as e:
                 raise e
         except Exception as ex:
             OAuthLogger.add_log("Exception occured while fetching instance for Custom DB Persistence", logging.ERROR, ex)
             raise ex
コード例 #2
0
 def get_persistence_instance():
     if (ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH
             not in ZohoOAuth.configProperties
             or ZohoOAuth.configProperties[
                 ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH] == ""):
         return ZohoOAuthPersistenceHandler()
     else:
         return ZohoOAuthPersistenceFileHandler()