Changeset e15435c for fedd


Ignore:
Timestamp:
Jun 30, 2011 11:51:18 AM (13 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master
Children:
b3c4896
Parents:
9b76f1a
Message:

Correct application of multipl maps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/remote_service.py

    r9b76f1a re15435c  
    3131    service_port_name = 'getfeddPort'
    3232    internal_service_port_name = 'getfedd_internal_port'
    33 
    3433from util import fedd_ssl_context
    3534from fedid import fedid
     
    6160    # A map used to convert fedid fields to fedid objects (when the field is
    6261    # already a string)
    63     fedid_to_object = ( ('fedid', lambda x: fedid(bits=x)),)
     62    fedid_to_object = {'fedid': lambda x: fedid(bits=x)}
    6463    # A map used by apply_to_tags to convert fedids from xmlrpclib.Binary
    6564    # objects to fedid objects in one sweep.
    66     decap_fedids = (('fedid', lambda x: fedid(bits=x.data)),)
     65    decap_fedids = {'fedid': lambda x: fedid(bits=x.data),
     66            'credential': lambda x: x.data}
    6767    # A map used to encapsulate fedids into xmlrpclib.Binary objects
    68     encap_fedids = (('fedid', to_binary),)
     68    encap_fedids = {'fedid': to_binary, 'credential': to_binary}
    6969
    7070    # fields that are never unicoded, because they represent non strings.
     
    142142        if isinstance(e, dict):
    143143            for k in e.keys():
    144                 for tag, fcn in map:
    145                     if k == tag:
    146                         if isinstance(e[k], list):
    147                             e[k] = [ fcn(b) for b in e[k]]
    148                         else:
    149                             e[k] = fcn(e[k])
    150                     elif isinstance(e[k], dict):
    151                         remote_service_base.apply_to_tags(e[k], map)
    152                     elif isinstance(e[k], list):
    153                         for ee in e[k]:
    154                             remote_service_base.apply_to_tags(ee, map)
     144                if k in map:
     145                    fcn = map[k]
     146                    if isinstance(e[k], list):
     147                        e[k] = [ fcn(b) for b in e[k]]
     148                    else:
     149                        e[k] = fcn(e[k])
     150                elif isinstance(e[k], dict):
     151                    remote_service_base.apply_to_tags(e[k], map)
     152                elif isinstance(e[k], list):
     153                    for ee in e[k]:
     154                        remote_service_base.apply_to_tags(ee, map)
    155155        # Other types end the recursion - they should be leaves
    156156        return e
Note: See TracChangeset for help on using the changeset viewer.