From 12ded2b841e863455923828fd333dae3e1473ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Sat, 2 May 2015 16:41:53 +0200 Subject: [PATCH] Added a class to addon clients to add more namespaces --- elasticsearch/client/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/elasticsearch/client/utils.py b/elasticsearch/client/utils.py index 360208aa..f66592bd 100644 --- a/elasticsearch/client/utils.py +++ b/elasticsearch/client/utils.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import weakref from datetime import date, datetime from functools import wraps from ..compat import string_types, quote_plus @@ -77,3 +78,10 @@ class NamespacedClient(object): @property def transport(self): return self.client.transport + +class AddonClient(NamespacedClient): + @classmethod + def infect_client(cls, client): + addon = cls(weakref.proxy(client)) + setattr(client, cls.namespace, addon) + return client