snmpmodule and making a pretend dictionary object...

anthony baxter (anthony.baxter@aaii.oz.au)
Sun, 07 Aug 1994 11:10:28 +1000

Hi folks,

Well, I've got a partially working SNMP module now - you can do
sess=snmp.open("host","public"), sess.get("system.sysDescr.0"),
getnext and set are also supported the same way.
What I'd like to do now is be able to do sess["system.sysDescr.0"] for
get, and sess["system.sysDescr.0"]="blah" for set - however, while these
two will be the mp_subscript and the mp_ass_sub methods, I'm going to
have to hardcode the mp_length function to just return, say, 1.

First question: is this going to break things (having length returning 1)?
Or should I just set the length function to raise a TypeError?

It's been suggested that it would be nice to be able
to do session.iso.mgmt.mib-2.system.sysDescr.0 (or session.system.sysDescr.0)
to refer to things, from poking around, it looks like I could implement this
by munging on the getattr method for the SnmpSession type.

Second question: is this the right way to do this?

Third question: is having an object that is a dictionary, but also has
these funky methods, going to break things? (I doubt it is, but you never
know :)

Thanks,
Anthony