Changeset 456

Show
Ignore:
Timestamp:
05/13/08 17:50:27 (8 months ago)
Author:
mgoldman
Message:

Updated bools() to new style.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/trunk-pmd-intproto/server/master.py

    r455 r456  
    3838        return b 
    3939 
     40def const(a): 
     41        return (lambda *args: a) 
     42 
    4043def targetexpand((type, list)): 
    4144        if(type == "IP"): 
     
    97100                return msg 
    98101 
    99         def bools(self, (mgr,info), msg, clientid=None): 
    100                 self.clients.send_all(msg) 
    101                 res = [] 
    102                 for (c, i) in self.clients.get_clients().items(): 
    103                         ret = pickle.load(c.makefile()) 
    104                         n = storage.NodeStatus(i[0], storage_root) 
    105                         for bool in val.body.keys(): 
    106                                 n.set_bool_status(bool, msg.body[bool]) 
    107                         n.update() 
    108                         res.append((ret, i)) 
    109                 return res 
     102###     Old style of doing this.  handler sent messages and processed results. 
     103###     Now Bad! 
     104###     def bools(self, (mgr,info), msg, clientid=None): 
     105###             self.clients.send_all(msg) 
     106###             res = [] 
     107###             for (c, i) in self.clients.get_clients().items(): 
     108###                     ret = pickle.load(c.makefile()) 
     109###                     n = storage.NodeStatus(i[0], storage_root) 
     110###                     for bool in val.body.keys(): 
     111###                             n.set_bool_status(bool, msg.body[bool]) 
     112###                     n.update() 
     113###                     res.append((ret, i)) 
     114###             return res 
     115        # Now does the work of handling a single result from the result of comm() 
     116        # for the server side part. 
     117        def bools(self, (val, clientid)): 
     118                n = storage.NodeStatus(clientid, storage_root) 
     119                for (key,val) in val.items(): 
     120                        n.set_bool_status(key, val) 
     121                n.update() 
     122 
    110123 
    111124        def list(self, (mgr,info), msg, clientid=None): 
     
    188201                                        res = self.updategroup((mgr, info), val) 
    189202                                elif val.msg == 'bools': 
    190                                         res = self.bools((mgr, info), val) 
     203                                        resp = self.comm(const(val), val, (mgr, info)) 
     204                                        res = map(self.bools, resp) 
    191205                                elif val.msg == 'list': 
    192206                                        res = self.list((mgr, info), val)