from dispatch.interfaces import * |
from dispatch.interfaces import * |
|
|
import protocols, inspect, sys, dispatch |
import protocols, inspect, sys, dispatch |
from protocols.advice import add_assignment_advisor,getFrameInfo,addClassAdvisor |
from peak.util.decorators import decorate_assignment, frameinfo, decorate_class |
from protocols.interfaces import allocate_lock |
from protocols.interfaces import allocate_lock |
from new import instancemethod |
from new import instancemethod |
from types import FunctionType, ClassType, InstanceType |
from types import FunctionType, ClassType, InstanceType |
if old_locals.get(name) is func: |
if old_locals.get(name) is func: |
return func |
return func |
return value |
return value |
return add_assignment_advisor(callback) |
return decorate_assignment(callback) |
|
|
|
|
|
|
else: |
else: |
func = qualifier,value |
func = qualifier,value |
|
|
kind,module,locals_,globals_ = getFrameInfo(frm) |
kind,module,locals_,globals_ = frameinfo(frm) |
if kind=='class': |
if kind=='class': |
# 'when()' in class body; defer adding the method |
# 'when()' in class body; defer adding the method |
def registerClassSpecificMethod(cls): |
def registerClassSpecificMethod(cls): |
self.addMethod(req & cond, func) |
self.addMethod(req & cond, func) |
return cls |
return cls |
|
|
addClassAdvisor(registerClassSpecificMethod,frame=frm) |
decorate_class(registerClassSpecificMethod,frame=frm) |
else: |
else: |
self.addMethod(cond,func) |
self.addMethod(cond,func) |
|
|
|
|
return value |
return value |
|
|
return add_assignment_advisor(registerMethod,frame=frame) |
return decorate_assignment(registerMethod,frame=frame) |
|
|
|
|
|
|