Re: LDAP Polling

2008-01-29 Thread Michael Ströder

Yeargan Yancey wrote:


I am trying to use the asynchronous LDAP polling feature and have a 
question about what appears to be a timing issue. When I run the code 
below, I find that I must insert a sleep() before entering the while 
loop or I get a ValueError exception. 
[..]
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 415, 
in result3
rtype, rdata, rmsgid, serverctrls = 
self._ldap_call(self._l.result3,msgid,all,timeout)

ValueError: need more than 3 values to unpack


Hmm, this should never happen. I guess it's caused by _ldap.result3() 
returning NULL for the situation where no result was received at all. I 
will look into it.


In the meantime try if the patch to LDAPObject.py attached solves your 
problem.


Ciao, Michael.
Index: Lib/ldap/ldapobject.py
===
RCS file: /cvsroot/python-ldap/python-ldap/Lib/ldap/ldapobject.py,v
retrieving revision 1.98
diff -u -r1.98 ldapobject.py
--- Lib/ldap/ldapobject.py	5 Jun 2007 09:56:15 -	1.98
+++ Lib/ldap/ldapobject.py	29 Jan 2008 08:47:04 -
@@ -435,8 +435,12 @@
   def result3(self,msgid=_ldap.RES_ANY,all=1,timeout=None):
 if timeout is None:
   timeout = self.timeout
-rtype, rdata, rmsgid, serverctrls = self._ldap_call(self._l.result3,msgid,all,timeout)
-decoded_serverctrls = DecodeControlTuples(serverctrls)
+ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
+if ldap_result is None:
+  rtype, rdata, rmsgid, decoded_serverctrls = (None,None,None,None)
+else:
+  rtype, rdata, rmsgid, serverctrls = ldap_result
+  decoded_serverctrls = DecodeControlTuples(serverctrls)
 return rtype, rdata, rmsgid, decoded_serverctrls
  
   def search_ext(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrsonly=0,serverctrls=None,clientctrls=None,timeout=-1,sizelimit=0):
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: LDAP Polling

2008-01-29 Thread Yeargan Yancey

Hmm. That only moved the exception.

   File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line  
421, in result3
 rtype, rdata, rmsgid, serverctrls = ldap_result
ValueError: need more than 3 values to unpack

I put the statement above into a try..except block and checked the  
value when the exception occurs. This line

ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)

assigns (None,None,None) to ldap_result, a 3-tuple instead of a 4-tuple.

Once data becomes available from the LDAP server, then it returns a 4- 
tuple as expected.

Yancey



On Jan 29, 2008, at 2:48 AM, Michael Ströder wrote:

> Yeargan Yancey wrote:
>>
>> I am trying to use the asynchronous LDAP polling feature and have a
>> question about what appears to be a timing issue. When I run the code
>> below, I find that I must insert a sleep() before entering the while
>> loop or I get a ValueError exception.
>> [..]
>>   File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line  
>> 415,
>> in result3
>> rtype, rdata, rmsgid, serverctrls =
>> self._ldap_call(self._l.result3,msgid,all,timeout)
>> ValueError: need more than 3 values to unpack
>
> Hmm, this should never happen. I guess it's caused by _ldap.result3()
> returning NULL for the situation where no result was received at  
> all. I
> will look into it.
>
> In the meantime try if the patch to LDAPObject.py attached solves your
> problem.
>
> Ciao, Michael.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: LDAP Polling

2008-01-29 Thread Michael Ströder
Yeargan Yancey wrote:
> Hmm. That only moved the exception.
> 
>File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line  
> 421, in result3
>  rtype, rdata, rmsgid, serverctrls = ldap_result
> ValueError: need more than 3 values to unpack
> 
> I put the statement above into a try..except block and checked the  
> value when the exception occurs. This line
> 
> ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
> 
> assigns (None,None,None) to ldap_result, a 3-tuple instead of a 4-tuple.

Hmm, which version of python-ldap is this? Did you install from source?

Looking at function l_ldap_result3() in Modules/LDAPObject.c I can't 
figure out why a 3-tuple is returned. I did not write this code though...

Ciao, Michael.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


RE: LDAP Polling

2008-01-29 Thread Yeargan, Yancey

> Hmm, which version of python-ldap is this? Did you install from source?
>
> Looking at function l_ldap_result3() in Modules/LDAPObject.c I
> can't figure out why a 3-tuple is returned. I did not write this
> code though...
>
> Ciao, Michael.
>


Not from source. This version came
with SuSE Linux Enterprise Server 10.

$Id: ldapobject.py,v 1.92 2005/11/03 09:09:43 stroeder Exp $


To solve my immediate need, I re-coded the function like so:

  def result3(self,msgid=_ldap.RES_ANY,all=1,timeout=None):
if timeout is None:
  timeout = self.timeout
ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
if ldap_result == (None,None,None):
  return (None,None,None,None)
else:
  rtype, rdata, rmsgid, serverctrls = ldap_result
  decoded_serverctrls = DecodeControlTuples(serverctrls)
return rtype, rdata, rmsgid, decoded_serverctrls


Can you point me to code for "self._l.result3"?
I may have time later this week to do more debugging.

Yancey

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: LDAP Polling

2008-01-29 Thread Michael Ströder
Yeargan, Yancey wrote:
> 
> Not from source. This version came
> with SuSE Linux Enterprise Server 10.

What does rpm -q python-ldap say?

Ciao, Michael.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: LDAP Polling

2008-01-29 Thread Michael Ströder
Yeargan, Yancey wrote:
> 
> Can you point me to code for "self._l.result3"?

Grab the source. Best would be from CVS:

http://sourceforge.net/cvs/?group_id=2072

Look at Modules/LDAPObject.c into function l_ldap_result3() (starting at 
line 940).

Ciao, Michael.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: LDAP Polling

2008-01-29 Thread Yeargan Yancey

python-ldap-2.0.11-14.2


On Jan 29, 2008, at 4:59 PM, Michael Ströder wrote:

> Yeargan, Yancey wrote:
>>
>> Not from source. This version came
>> with SuSE Linux Enterprise Server 10.
>
> What does rpm -q python-ldap say?
>
> Ciao, Michael.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev