python-redmine
python-redmine copied to clipboard
option to export whole wiki at once
There is no option to export the whole wiki at once, is there?
I used
wiki = redmine.wiki_page.get('Foo', project_id=1)
as described in the wiki and it works great for single pages, but I want to export the whole wiki, like the functionality presented by the export button on the bottom right-hand side when sorting the wiki by "index by title".
Did I just overlooked this functionality? I tried wildcards and stuff like "/", " * ", but it did not work with
redminelib.exceptions.ResourceNotFoundError: Requested resource doesn't exist
Thanks in advance!
Hi, yes, at the moment this is not possible.
There is a bug on the Redmine side which stops us from implementing this functionality. For some reason this specific part of Redmine, i.e. all wiki pages export, doesn't respect the API authentication, which means that export of all wiki pages only works with a standard cookie authentication which we don't support and have no plans to support because that just doesn't make any sense to support as Redmine's API has a separate way of user authentication.
Would appreciate if you could fill a bug report on their forum as more people will complain, hopefully faster this bug will be fixed.
Thank you for the info, I've created an issue there. Should I leave this issue open here for updates?
Awesome, thanks. Hopefully it will get some attention. This issue here should definitely stay open for updates.
Update: nothing changed, the situation is still the same as described in #541360668
Update: a very simple patch from the Redmine issue enabled the export API call, but it only works with single Wiki pages (see Python documentation.
We modified standard.py from my local python3-redminelib (Debian 12.4) to enable exports of whole wiki:
--- a/resources/standard.py 2024-02-02 11:00:58.320483367 +0100
+++ b/resources/standard.py 2024-02-02 11:01:51.116699835 +0100
@@ -262,6 +262,7 @@
container_create = 'wiki_page'
container_update = 'wiki_page'
query_one_export = '/projects/{project_id}/wiki/{0}.{format}'
+ query_all_export = '/projects/{project_id}/wiki/export.{format}'
query_filter = '/projects/{project_id}/wiki/index.json'
query_one = '/projects/{project_id}/wiki/{0}.json'
query_create = '/projects/{project_id}/wiki/{title}.json'
@@ -298,7 +299,7 @@
return super(WikiPage, self).delete(**dict(params, project_id=self.project_id))
def export_url(self, fmt):
- return self.manager.redmine.url + self.query_one_export.format(
+ return self.manager.redmine.url + self.query_all_export.format(
self.internal_id, project_id=self.project_id, format=fmt)
@property
Thanks for your effort!
Hi @Wurzelmann
Many thanks for the info.
Too bad the patch from https://www.redmine.org/issues/32246 still didn't make it to the upstream. Until it gets there I can't make any changes to Python-Redmine as it can create lots of confusion for most people.
Regarding your patch to Python-Redmine - just adding the query_all_export = '/projects/{project_id}/wiki/export.{format}'
should be enough as it will be picked up automatically by ResourceSet
class and the export will work like this:
wikis = redmine.wiki_page.filter(project_id='my_project')
wikis.export('pdf', savepath='/my/local/path')
because right now the second part of your patch disabled the ability to do the single page export OR alternatively you can just create your own custom resource that inherits from WikiPage and use it instead of the WikiPage OR you can monkey patch Python-Redmine like this:
from redminelib import resources, utilities, Redmine
resources.registry['WikiPage']['class'].query_all_export = utilities.ResourceQueryStr('/projects/{project_id}/wiki/export.{format}')
# then you initialise Redmine object and do your queries as usual
This way you won't have to patch Python-Redmine after every new version.
I will reopen this issue with the hope that someday Redmine will patch the upstream and we will be able to introduce the export all feature to Python-Redmine as well.