On Thu, Feb 12, 2009 at 10:36:39AM +0100, Gabriele Messineo wrote:
> Hi,
> 
> There's a lot of space for improvements in Net-Snmp Python bindings. A change 
> in Python APIs making it more similar to Perl's one would provide new 
> features like asynchronous calls support.
Yeah.

> However, actually the code and its API are quite stable and I think you can 
> find a way to improve them without rewrite them all or break backward 
> compatibility.
Yes, backward compatibility is planned.

> About the session pointer, I think it can be maintained in the Python object, 
> to avoid the addition of static structures in memory (and the complexity to 
> keep a reference between them and the python object), however the best would 
> be to declare it as a private member. I don't think we can reach a 
> significant gain in rewriting the Session class in C. But probably we can 
> improve the communication between the two languages.
However, actually the code doen't work on 64-bit system. I have a patch to
fix it:
diff --git a/net-snmp/python/netsnmp/client_intf.c
b/net-snmp/python/netsnmp/client_intf.c
index bf0e7fe..bbc0721 100644
--- a/net-snmp/python/netsnmp/client_intf.c
+++ b/net-snmp/python/netsnmp/client_intf.c
@@ -1100,10 +1100,10 @@ py_netsnmp_attr_string(PyObject *obj, char *
attr_name)
   return val;
 }

-static long
+static long long
 py_netsnmp_attr_long(PyObject *obj, char * attr_name)
 {
-  long val = -1;
+  long long val = -1;

   if (obj && attr_name  && PyObject_HasAttrString(obj, attr_name)) {
     PyObject *attr = PyObject_GetAttrString(obj, attr_name);
@@ -1199,7 +1199,7 @@ netsnmp_create_session(PyObject *self, PyObject *args)
       printf("error:snmp_new_session: Couldn't open SNMP session");
   }
  end:
-  return Py_BuildValue("i", (int)ss);
+  return Py_BuildValue("L", (long long)ss);
 }

 static PyObject *
@@ -1344,7 +1344,7 @@ netsnmp_create_session_v3(PyObject *self, PyObject
*args)
   free (session.securityEngineID);
   free (session.contextEngineID);

-  return Py_BuildValue("i", (int)ss);
+  return Py_BuildValue("L", (long long)ss);
 }

 static PyObject *


But, I think this is bad way.

Session class in C allow to rid if unnecessary translation PyObjects from/to
C. In general, it would be more efficient and compact.

> If you need some help in reviewing/refactoring/improve actual code I'm 
> interested in giving my support.
Thanks.

My development git tree: git://git.sgu.ru/net-snmp.git, branch: dev.
Also accessible via gitweb:
http://git.sgu.ru/?p=net-snmp.git;a=shortlog;h=refs/heads/dev

-- 
John A. Khvatov

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to