Changeset 9c73557 for fedd


Ignore:
Timestamp:
Apr 7, 2011 7:10:47 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, info-ops, master
Children:
37ecf7e
Parents:
8f1db21
Message:

apply_to_tags miscoded for multiple applications of the map. Basic python stuff. This is from when I was learning.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/remote_service.py

    r8f1db21 r9c73557  
    6161    # A map used to convert fedid fields to fedid objects (when the field is
    6262    # already a string)
    63     fedid_to_object = ( ('fedid', lambda x: fedid(bits=x)),)
     63    fedid_to_object = {'fedid': lambda x: fedid(bits=x)}
    6464    # A map used by apply_to_tags to convert fedids from xmlrpclib.Binary
    6565    # objects to fedid objects in one sweep.
    66     decap_fedids = (('fedid', lambda x: fedid(bits=x.data)),)
     66    decap_fedids = {'fedid': lambda x: fedid(bits=x.data),
     67            'credential': lambda x: x.data}
    6768    # A map used to encapsulate fedids into xmlrpclib.Binary objects
    68     encap_fedids = (('fedid', to_binary),)
     69    encap_fedids = {'fedid': to_binary, 'credential': to_binary}
    6970
    7071    # fields that are never unicoded, because they represent non strings.
     
    142143        if isinstance(e, dict):
    143144            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)
     145                if k in map:
     146                    fcn = map[k]
     147                    if isinstance(e[k], list):
     148                        e[k] = [ fcn(b) for b in e[k]]
     149                    else:
     150                        e[k] = fcn(e[k])
     151                elif isinstance(e[k], dict):
     152                    remote_service_base.apply_to_tags(e[k], map)
     153                elif isinstance(e[k], list):
     154                    for ee in e[k]:
     155                        remote_service_base.apply_to_tags(ee, map)
    155156        # Other types end the recursion - they should be leaves
    156157        return e
Note: See TracChangeset for help on using the changeset viewer.