# GetNodes update
# first replace the call method so we can translate fields
c = getattr(v42legacy.import_deep("PLC.Methods.GetNodes"),"GetNodes")
-# rename call to newcall so we can still invoke
+# rename call to __origcall so we can still invoke
original = getattr(c,"call")
-setattr(c,"newcall",original)
+setattr(c,"__origcall",original)
# 4.2 legacy support; update node_fields to include nodenetwork_ids
from PLC.Parameter import Parameter, Mixed, python_type
setattr(c,"returns",newreturns)
def GetNodesCall(self, auth, node_filter = None, return_fields = None):
- global original
# convert nodenetwork_ids -> interface_ids
if node_filter <> None and \
node_filter.has_key('nodenetwork_ids') and \
not node_filter.has_key('interface_ids'):
node_filter['interface_ids']=node_filter['nodenetwork_ids']
- nodes = original(self,auth,node_filter,return_fields)
+ nodes = self.__origcall(auth,node_filter,return_fields)
# add in a interface_ids -> nodenetwork_ids
for node in nodes:
def make_class (legacyname,newname,path,v42rename,v43rename):
# locate new class
newclass=getattr(import_deep(path+newname),newname)
+ setattr(newclass,"__origcall",getattr(newclass,"call"))
# create class for legacy name
legacyclass = type(legacyname,(newclass,),
{"__doc__":"Legacy method - please use %s instead"%newname})
# print "%s: self.caller = %s, self=%s" % (legacyname,self.caller,self)
newargs=[patch(x,v42rename) for x in args]
newkwds=dict ( [ (k,patch(v,v42rename)) for (k,v) in kwds.iteritems() ] )
- results = getattr(newclass,"call")(self,auth,*newargs,**newkwds)
+ results = self.__origcall(auth,*newargs,**newkwds)
return patch(results,v43rename)
setattr(legacyclass,"call",wrapped_call)