Message11634

Author lucabrasi
Recipients lucabrasi
Date 2017-10-28.05:47:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1509169676.07.0.213398074469.issue2636@psf.upfronthosting.co.za>
In-reply-to
Content
Below is the Jython traceback:

File "/data/naas/ServicePackages/servicemodel/controller/devices/device/vrfs/vrf/__init__.py", line 67, in __init__
    self.__router_eigrp = YANGDynClass(base=router_eigrp.router_eigrp, is_container='container', yang_name="router-eigrp", module_name="l3features", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://anutanetworks.com/l3features', defining_module='l3features', yang_type='container', is_config=True)
  File "/data/naas/ServicePackages/pyangbind/lib/yangtypes.py", line 1167, in YANGDynClass
    return YANGBaseClass(*args, **kwargs)
  File "/data/naas/ServicePackages/pyangbind/lib/yangtypes.py", line 997, in __init__
    self._yang_name = yang_name
TypeError: readonly attribute


One workaround is to change the __slots__ from pyangbind to use a different name (Eg: self._yang_myname in this case). But this requires a lot of side changes in pyanglib:

class YANGBaseClass(base_type):
    # we only create slots for things that are restricted
    # in adding attributes to them - this means containing
    # data nodes. This means that we can allow
    # leaf._someattr to be used by consuming code - it
    # also fixes an issue whereby we could set __slots__
    # and try and inherit a variable-length inbuilt such
    # as long, which is not allowed.
    if yang_type in ["container", "list"] or is_container == "container":
      __slots__ = tuple(clsslots)

    _pybind_base_class = re.sub("<(type|class) '(?P<class>.*)'>", "\g<class>",
                                  str(base_type))

    def __new__(self, *args, **kwargs):
      obj = base_type.__new__(self, *args, **kwargs)
      return obj

    def __init__(self, *args, **kwargs):
      self._default = False
      self._mchanged = False
      self._yang_myname = yang_name
      self._mymodule_name = module_name
      self._parent = parent_instance
      self._choice = choice_member
      self._path_helper = path_helper
      self._supplied_register_path = supplied_register_path
      self._base_type = base_type
      self._is_leaf = is_leaf
      self._is_container = is_container
      self._is_config = is_config
      self._extensionsd = extensions
      self._extmethods = extmethods
      self._is_keyval = is_keyval
      self._register_paths = register_paths
      self._mynamespace = namespace
      self._yang_type = yang_type
      self._defining_module = defining_module
      self._metadata = {}
      self._empty_tag = False


clsslots = ['_default', '_mchanged', '_yang_myname', '_mymodule_name', '_choice', '_parent',
                 '_supplied_register_path', '_path_helper', '_base_type',
                 '_is_leaf', '_is_container', '_extensionsd',
                 '_pybind_base_class', '_extmethods', '_is_keyval',
                 '_register_paths', '_mynamespace', '_yang_type',
                 '_defining_module', '_metadata', '_is_config', '_empty_tag']
History
Date User Action Args
2017-10-28 05:47:56lucabrasisetmessageid: <1509169676.07.0.213398074469.issue2636@psf.upfronthosting.co.za>
2017-10-28 05:47:56lucabrasisetrecipients: + lucabrasi
2017-10-28 05:47:56lucabrasilinkissue2636 messages
2017-10-28 05:47:55lucabrasicreate