问题描述
我正在使用 atlassian-python-api 来更新文档中所述的页面:
from atlassian import Confluence
conf = Confluence(url=srvr,username=usr,password=pswd)
page_id = '12345'
new_page_title = 'This is a new title'
new_page_body = '<p>This is a new body</p>'
conf.update_page(page_id,new_page_title,new_page_body)
这很好用。我现在想添加一条更新评论/提交消息,就像手动编辑页面时可以输入的那样(“你改变了什么?”)。
update_page()
的 atlassian-python-api 文档没有这样的选项。可能吗?
data = {
'id': {page_id}
'title': new_page_title,'body': {
'storage':{
'value': new_page_body,'representation':'storage',}
},'version': {
'number': 2
},'comment': 'Changed the title and the body.'
}
但我想这不是 update_page()
的工作方式,我得到一个
AttributeError: 'dict' 对象没有属性 'strip'
解决方法
这实际上可以通过 update_page()
直接实现,尽管您是对的,但是 method's documentation 中没有记录。
我在 source code 中发现方法 update_page()
接受一个可选参数 version_comment
。这是您要设置的注释。
扩展您的示例:
from atlassian import Confluence
conf = Confluence(url=srvr,username=usr,password=pswd)
page_id = '12345'
new_page_title = 'This is a new title'
new_page_body = '<p>This is a new body</p>'
commit_msg = 'Changed the title and the body.'
conf.update_page(page_id,new_page_title,new_page_body,version_comment=commit_msg)
这应该可以满足您的需求。