diff options
| author | Lyudmil Nenov <lyudmil.nenov@gmail.com> | 2017-11-03 16:05:17 +0200 |
|---|---|---|
| committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-11-03 15:05:17 +0100 |
| commit | 226e6ce9e5217367c896125a2b4b9d16afd2cf94 (patch) | |
| tree | a02b5fe4e9f235be3c2b9b128f931a99da03a0bc /gitlab/__init__.py | |
| parent | 38d446737f45ea54136d1f03f75fbddf46c45e00 (diff) | |
| download | gitlab-226e6ce9e5217367c896125a2b4b9d16afd2cf94.tar.gz | |
Module's base objects serialization (#359)
Make gitlab objects serializable
With current implementation of API v3 and v4 support, some instances
have properties of type module and are not serializable. Handle
these properties manually with setstate and getstate methods.
Diffstat (limited to 'gitlab/__init__.py')
| -rw-r--r-- | gitlab/__init__.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index b721030..965bf38 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -138,6 +138,17 @@ class Gitlab(object): manager = getattr(objects, cls_name)(self) setattr(self, var_name, manager) + def __getstate__(self): + state = self.__dict__.copy() + state.pop('_objects') + return state + + def __setstate__(self, state): + self.__dict__.update(state) + objects = importlib.import_module('gitlab.v%s.objects' % + self._api_version) + self._objects = objects + @property def api_version(self): return self._api_version |
