diff options
author | 2011-10-29 16:11:27 +0200 | |
---|---|---|
committer | 2011-10-31 00:34:31 +0100 | |
commit | c23698e64f3244636290ffa4065f3b70ba5151e9 (patch) | |
tree | 37fee2463eb1aedbf758fe1b9b9afd173c5908c8 /github3/handlers/base.py | |
parent | Update requests (fixs with auth) (diff) | |
download | python-github3-c23698e64f3244636290ffa4065f3b70ba5151e9.tar.xz python-github3-c23698e64f3244636290ffa4065f3b70ba5151e9.zip |
Wip on handlers
Diffstat (limited to 'github3/handlers/base.py')
-rw-r--r-- | github3/handlers/base.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/github3/handlers/base.py b/github3/handlers/base.py new file mode 100644 index 0000000..6a5ac65 --- /dev/null +++ b/github3/handlers/base.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# author: David Medina + +import models + +class Handler(object): + """ Abstract handler, that inject github.api """ + + def __init__(self, gh): + self._gh = gh + super(Handler, self).__init__() + + def _extend_url(self, *args): + return self._url + args + + def _get_resource(self, *args, **kwargs): + url = self._extend_url(*args) + map_model = kwargs.get('model', self._model) + return self._gh._get_resource(url, map_model, **kwargs) + + def _get_resources(self, *args, **kwargs): + url = self._extend_url(*args) + map_model = kwargs.get('model', self._model) + return self._gh._get_resources(url, map_model, **kwargs) |