From 575549ae33e35c0ceb884765399d8b7942e6ee4a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 3 Jan 2014 00:54:49 +0530 Subject: [PATCH] only add api methods to API instance --- ox/api.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ox/api.py b/ox/api.py index 64024bb..5447b42 100644 --- a/ox/api.py +++ b/ox/api.py @@ -7,6 +7,7 @@ import cookielib import gzip import StringIO import urllib2 +from types import MethodType from . import __version__ from .utils import json @@ -15,9 +16,7 @@ from .form import MultiPartForm __all__ = ['getAPI', 'API'] def getAPI(url, cj=None): - class A(API): - pass - return A(url, cj) + return API(url, cj) class API(object): __version__ = __version__ @@ -46,7 +45,7 @@ class API(object): def _add_method(self, method, name): if name is None: name = method.func_name - setattr(self.__class__, name, method) + setattr(self, name, MethodType(method, self, type(self))) def _add_action(self, action): def method(self, *args, **kw):