Matthew Thorley wrote:
Steve Holden wrote:


I think that since each Datapoint appears to be unique, the simplest
thing to do is to include a reference to the parent object as an
attribute of the datapoint. Presumably when you create the Datapoint you
already know which Device and Mib it's going to be stored in, so why
make work for yourself when you can trade a little storage and make the
whole thing easy?



I'll give that a shot and see how it goes. It makes sense, the parent
objects create the child objects, so they could very easily set the
apropriate parameter.

Indeed, they will probably just need to pass "self" as an argument to the child object's creator (it will become an argument to the __init__() method). This will be pretty cheap, since the additional attribute will be bound to an already-existing value.

On the other hand, the introspecitve stuff is cool! When you say "make
more work for yourself" are you talking about 400 lines of code or 50.
Further, is there much processing required to do the magic? When python
do introspective magic, is it memory intensive? by that I mean does it
have to make copies of the objects to do the look-ups?

Frankly I am not sure I see the advantage. You seem to be saying that rather than provide each child object with a reference to its parent you would rather provide it with a reference to the collection of parent objects and let it work out which one it wants. Where's the benefit?

I don't mind copying the info like you suggest, but if the extra work
won't take more than a day or two, (or maybe even a week if its fun) I'd
like to do the introspection so that 1: I know how, 2: I can say that I
did ;)

Basically you'd have to iterate over the list of parent objects, checking whether the child object's self appeared as a key in its dictionary of children, so there's nothing really magical about it.

The *real* magic comes about when you are looking for arbitrary references to an object, and you have to iterate over the locals() from each stack frame, and various other magical bits and pieces.

There have been posts in the past detailing such magic, so Google will find them for you if you are keen to bend your brain.

Is there any kind of documentaion, (refference, article, blog-post,
tutorial), that explains introspection in useful detail, or at least
enough to get me started?

Whole swathes of stuff already posted n c.l.py, not to mention Patrick O'Brien's

  http://www-106.ibm.com/developerworks/library/l-pyint.html

which has been highly spoken of.

You might also be interested to know that the Python Software Foundation
funded the development of a Python package to support SNMP as a part of
its first round of grant funding last year, so there's at least one
other person working on this stuff!


I did see that and I was quite pleased! :) I am currently using the authors 'old' pysnmp which gets me by, but I am very excited to try out the new version when it is ready.


Thanks again, for the reply and for the grant to pysnmp!

-Matthew

Happy to help, but I can't take credit for the grant, since all I did as a PSF director was vote affirmatively on the recommendations of Martin von Lowis' extremely hard-working grants committee.


regards
 Steve
--
Steve Holden        +1 703 861 4237  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to