Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index backends by id, not by name #931

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cpitclaudel
Copy link

This allows GTG to have multiple backends of one kind at the same time.

  • GTG/backends/init.py (BackendFactory.get_saved_backends_list): Rename
    backend to backend_id for clarity. Call config.rename_backend_section on
    each backend for compatibility with previous versions of GTG.
  • GTG/core/config.py (CoreConfig_.rename_backend_section): New function to
    rename a config section (from backend name to backend ID).
    (CoreConfig_.get_all_backends): Rename backend to backend_id for clarity.
  • GTG/core/datastore.py (DataStore.save): Retrieve config section by backend id,
    not by backend name.

Fixes #930.

@diegogangl
Copy link
Contributor

@cpitclaudel hey, thanks! We're in the middle of a big port ATM and I'm focusing all the time I can find in that. Once #894 is ready to land, I'll review this and merge. Luckly it looks like this branch won't generate any conflicts, though we'll have to port the change in datastore over to the new datastore.

@cpitclaudel
Copy link
Author

Looking forward to that :) Good luck with the port!

@@ -180,10 +180,14 @@ def save(self):
self._save_function()


class CoreConfig():
class CoreConfig_():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the underscore here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility: CoreConfig is redefined below:

def CoreConfig():
    return CoreConfig_.get_instance()

@nekohayo
Copy link
Member

It is time now! Monsieur @cpitclaudel, rebasez donc cette branche, et lâchez les chiens!

See also the updated general status and convenient links in #737.

@nekohayo nekohayo added the plugins Plugins and extra backends label Feb 26, 2024
@nekohayo nekohayo marked this pull request as draft February 26, 2024 18:15
@nekohayo
Copy link
Member

This will also be relevant to @jaesivsm's interests.

This prevents the configuration from being read and modified in two different
places (`CoreConfig` objects are created in `datastore.py`, `treefactory.py`,
and `backends/__init__.py`).

* GTG/core/config.py (CoreConfig_): Rename from `CoreConfig`.
(CoreConfig_.INSTANCE): New field (use it to store the unique config instance).
(CoreConfig_.__init__): Make sure that we are only ever initialized once.
(CoreConfig_.get_instance): New method.
(CoreConfig): New function to initialize and return the singleton config object.
This allows GTG to have multiple backends of one kind at the same time.

* GTG/backends/__init__.py (BackendFactory.get_saved_backends_list): Rename
`backend` to `backend_id` for clarity.  Call `config.rename_backend_section` on
each backend for compatibility with previous versions of GTG.
* GTG/core/config.py (CoreConfig_.rename_backend_section): New function to
rename a config section (from backend name to backend ID).
(CoreConfig_.get_all_backends): Rename `backend` to `backend_id` for clarity.

Fixes getting-things-gnome#930.
@cpitclaudel cpitclaudel force-pushed the cpitclaudel_multiple-caldav branch from cb090d5 to f56a620 Compare March 2, 2024 20:58
@cpitclaudel
Copy link
Author

Congrats on the big merge! :)

I rebased this, but I'll need help to test:

  • I haven't used GTG since I opened this PR
  • I'm not familiar with the code base anymore
  • At first glance, I'm not 100% sure how the new datastore should be updated

After a quick glance through the code, I'm also not entirely certain of what a backend module refers to, so the change may not be right in the new architecture?

@diegogangl
Copy link
Contributor

Hi @cpitclaudel, sorry for the delay. At first glance, this sounds like a good idea. The problem is that the only backend module we have now is caldav, since the "local" backend is now integrated into the datastore. And the Caldav backend has a fair share of bugs too from the refactor. On top of that, there are some potential problems with having more than caldav backend like race conditions when synchronizing that need careful work and testing.

Since we are trying to finish 0.7 at this moment, I'll remove the milestone for this and leave it open for later

@cpitclaudel
Copy link
Author

Sure thing, good luck with the 0.7 release! I look forward to using GTG when CalDAV is back :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement plugins Plugins and extra backends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GTG allows creating multiple backends of type CalDAV, but they do not persist across restarts
3 participants