On Friday 13 March 2009 19:21:31 John Khvatov wrote:
> Hi folks,
>
> I'm working to improve python bindings. Already done:
>  * Session rewritten in C (removed a lot of unsafe transfers from python
>    to C and vice versa.
>  * Added exceptions for errors handling
>  * Reviewed/refactored/rewritten half of code
>
>
> Unfortunately, I changed the interface of Session::get*(), Session::set()
> functions. get*() takes as argument python list of Varbinds and returns
> _new_ list of Varbinds with filled values and types. set() returns None.
> All raise exceptions if error has occurred. (Next, also get*() will take
> callback and return None for asynchronous call and a simple Varbind may be
> passed to functions) It's ok?
>
> I remind that in the current code get*() takes VarList  of Varbinds as
> argument, changes the VarList and returns tuple ".val"s of Varbinds.
> VarList - this is wrapper of python list.
> http://git.sgu.ru/?p=net-snmp.git;a=blob;f=net-snmp/python/netsnmp/client.p
>y;h=c7f1ac7e06e00112f19c1286a4876d28885e6477;hb=upstream#l66
>
> My changes makes VarList unnecessary, functions's behavior more transparent
> and clear.
>
> So, I have a few questions about the next work.
>
> Session members. I think, the Session object contains a lot of not
> required members, a change that is no affected (such as, SecName,
> SecSecEngineId, etc.). Also struct netsnmp_session contains part of these
> members in readable form. Maybe leave only the main members, that can be
> obtained from netsnmp_session (such as, .Use*, .DestHost, ports, etc.)?
>
> To simplify the part of C code, Varbind in C needed (also for removing
> a lot of transfers Python <-> C). May I merge tag and iid to simple
> ".name". The snmplib allows me to work with the simple "name" in the
> bindings.
>
> Setting output format. In the current code output format is set at the
> library-wide.
> http://git.sgu.ru/?p=net-snmp.git;a=blob;f=net-snmp/python/netsnmp/client_i
>ntf.c;h=bf0e7fe368b5601fe6fec9b832f1272e7ff4909d;hb=upstream#l1468 Maybe
> using NETSNMP_DS_APPLICATION_ID level and doesn't restore "old_format"?
>
> I want to usе more snmplib, as is done in Net-SNMP "apps". Could you point
> me to where the bindings code, makes what already implemented in snmplib?
>
> Thanks!
>
> P.S. Before implementing the new features, I would like to simplify and fix
> current code.

Hi,

the changes seem fine and the code really clean.

About the topics:

        - I think too that VarList is an added complexity.
                However, your implementation seems to me like a good tradeoff 
to keep 
backward-compatibility and promote new style coding (by declaring the VarList 
class inheriting the list class). You can add a comment or a programming 
guideline in which you can discourage its usage, suggesting the use of simple 
python lists.

        - The Varbind tag <-> iid attributes have ever been a source of 
confusion 
(and unexpected behaviors).
                IMHO I would really remove the iid attribute (I'm actually 
using only 
the 'tag' one only)... I'm not sure if there's an equivalent property in 
other snmplib bindings. It would only be a matter of taste... is there anyone 
using it?
                But I wouldn't introduce a new attribute 'name', can't we reuse 
the 'tag' 
one (or support both 'name' and 'tag' names to access the same information)? 
(if not we are effectively forcing anyone to change its code).

        - the Session object
                if I understood it right you're proposing to give only the 
possibility to 
set but not to get some members like SecName, ... am I right? So when I'm 
creating a new Session object the Python binding pass 'em directly to snmplib 
without keeping track. That's a 'security' question... it's unsafe to keep 
track of too much informations and you're right to be wanting to avoid it. 
The only issue it would be a 'transparent' reuse of snmplib from the binding 
(eg: the binding that reset the library out-of- python code control), that 
would become impratical. Are there situation where this behavior can be 
useful (like asynchronous calls)?

        - the snmplib
                well, I'm not an snmplib coder, so I would skip this question, 
however, for 
the little I saw, actual binding code has a lot of duplicated 
functionalities... I think you can easily find them by comparing the 
following implementations:

                        python/netsnmp/client_intf.c:netsnmp_get()
                        apps/snmpget.c:main()
                        perl/SNMP/SNMP.xs:snmp_get()

                these codes would do in practice the same. it's just right to 
think to share 
some code. Just think at 
[__is_numeric_oid, __is_leaf, __translate_appl_type, __translate_asn_type, 
__snprint_value, __sprint_num_objid, __scan_num_objid, __get_type_str, 
__get_label_iid, ... ] (these are implemented in both python and perl 
bindings, they share the same code, but somehow they differs, probably 
different bug fixes...).
                All of that is already handled in the apps code. I think you 
can find a 
common way to translate the parsing of the input parameters (probably the 
bindings should share a lot of code except for different error reporting / 
return codes and parameters parsing functionalities).

You're really doing a great work improving this binding code.

Make me know if you have any doubt on my suggestions.

Regards,

Gabriele Messineo

PS: tnx for having CCed me!
PPS: I'm sorry if I could have missed something, but I really had a few time 
to review the changes (but they compiled and seems to run fine).

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to