|
[Webware-checkins] r2230 - WSGIKit/trunk/wsgikit
From: <ianb@co...> - 2005-03-26 06:02
|
Author: ianb
Date: 2005-03-25 23:02:50 -0700 (Fri, 25 Mar 2005)
New Revision: 2230
Modified:
WSGIKit/trunk/wsgikit/classinstance.py
Log:
whoops, forgot some code
Modified: WSGIKit/trunk/wsgikit/classinstance.py
===================================================================
--- WSGIKit/trunk/wsgikit/classinstance.py 2005-03-26 06:02:39 UTC (rev 2229)
+++ WSGIKit/trunk/wsgikit/classinstance.py 2005-03-26 06:02:50 UTC (rev 2230)
@@ -11,3 +11,24 @@
def __get__(self, obj, type=None):
return _methodwrapper(self.func, obj=obj, type=type)
+
+class _methodwrapper(object):
+
+ def __init__(self, func, obj, type):
+ self.func = func
+ self.obj = obj
+ self.type = type
+
+ def __call__(self, *args, **kw):
+ assert not kw.has_key('self') and not kw.has_key('cls'), (
+ "You cannot use 'self' or 'cls' arguments to a "
+ "classinstancemethod")
+ return self.func(*((self.obj, self.type) + args), **kw)
+
+ def __repr__(self):
+ if self.obj is None:
+ return ('<bound class method %s.%s>'
+ % (self.type.__name__, self.func.func_name))
+ else:
+ return ('<bound method %s.%s of %r>'
+ % (self.type.__name__, self.func.func_name, self.obj))
|
| Thread | Author | Date |
|---|---|---|
| [Webware-checkins] r2230 - WSGIKit/trunk/wsgikit | <ianb@co...> |