一个用于 Python 的 CMIS API 库,第 2 部分: 使用 Python 和 cmislib 构建真正的 ECM 工具
2010-05-05 00:00:00 来源:WEB开发网清单 1. 样例 cmisxcopy.cfg 文件
[cmis_repository]
# service url for the repository that you will be copying to
serviceURL=http://localhost:8080/p8cmis/resources/DaphneA/Service
# TARGET CLASS
# the cmis:objectTypeId of the class that you wish to create
targetClassName=cmis:document
# DEBUG MODE
debug=false
#USER CREDENTIALS
user_id=admin
password=password
标准 Python 库 ConfigParser 将有效地读取这个配置文件数据,如 清单 2 所示:
清单 2. 使用 ConfigParser 读取配置文件值
import ConfigParser
# config file related constants
configFileName = 'cmisxcopy.cfg'
cmisConfigSectionName = 'cmis_repository'
# read in the config values
config = ConfigParser.RawConfigParser()
config.read(configFileName)
try:
UrlCmisService = config.get(cmisConfigSectionName, "serviceURL")
targetClassName = config.get(cmisConfigSectionName, "targetClassName")
user_id = config.get(cmisConfigSectionName, "user_id")
password = config.get(cmisConfigSectionName, "password")
debugMode = config.get(cmisConfigSectionName, "debug")
except:
print "There was a problem finding the config file:" + configFileName + \
" or one of the settings in the [" + cmisConfigSectionName + "] section ."
sys.exit()
更多精彩
赞助商链接