summaryrefslogtreecommitdiff
path: root/gitlab/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/base.py')
-rw-r--r--gitlab/base.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/gitlab/base.py b/gitlab/base.py
index 4213d2f..ec5f698 100644
--- a/gitlab/base.py
+++ b/gitlab/base.py
@@ -416,6 +416,17 @@ class GitlabObject(object):
if not hasattr(self, "id"):
self.id = None
+ def __getstate__(self):
+ state = self.__dict__.copy()
+ module = state.pop('_module')
+ state['_module_name'] = module.__name__
+ return state
+
+ def __setstate__(self, state):
+ module_name = state.pop('_module_name')
+ self.__dict__.update(state)
+ self._module = importlib.import_module(module_name)
+
def _set_manager(self, var, cls, attrs):
manager = cls(self.gitlab, self, attrs)
setattr(self, var, manager)
@@ -555,6 +566,17 @@ class RESTObject(object):
self.__dict__['_parent_attrs'] = self.manager.parent_attrs
self._create_managers()
+ def __getstate__(self):
+ state = self.__dict__.copy()
+ module = state.pop('_module')
+ state['_module_name'] = module.__name__
+ return state
+
+ def __setstate__(self, state):
+ module_name = state.pop('_module_name')
+ self.__dict__.update(state)
+ self._module = importlib.import_module(module_name)
+
def __getattr__(self, name):
try:
return self.__dict__['_updated_attrs'][name]