z25 / pyZOCP

Python ZOCP implementation (Z25 Orchestration Control Protocol)
GNU Lesser General Public License v3.0
33 stars 5 forks source link

What does this code do? #49

Open fieldOfView opened 9 years ago

fieldOfView commented 9 years ago

https://github.com/z25/pyZOCP/blob/master/src/zocp.py#L791

if self._cur_obj_keys:
    # the last key in the _cur_obj_keys list equals
    # the first in data so skip the last key
    for key in self._cur_obj_keys[::-1]:
        new_data = {}
        new_data[key] = data
        data = new_data

This code lives in _on_modified since before the feature_subscribe merge. I have no idea what it does.

https://www.youtube.com/watch?v=kfj0sRiEqx4

sphaero commented 9 years ago

It belongs to registering objects. However we haven't used this in a while. You can create objects in ZOCP by issuing register_object(name, type). Attached to those objects you can register ints, bools, floats etc, etc. Now we just register ints floats etc directly onto the node.

sphaero commented 9 years ago

I'm not sure if it is a workaround or not but if you are register params to an object _on_modified will be called with just:

{'myBool': {'subscribers': [], 'typeHint': 'bool', 'value': True, 'access': 'rwe'}}

However that's just a relative path to the parameter. The code than looks what the cur_obj is and constructs the full path of the modification:

{'objects': {'object1': {'myBool': {'subscribers': [], 'typeHint': 'bool', 'value': True, 'access': 'rwe'}}}}