logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: [psycopg] #105: extras.DictCursor not implementing __iter__: msg#00042

Subject: Re: [psycopg] #105: extras.DictCursor not implementing __iter__
#105: extras.DictCursor not implementing __iter__
----------------------+-----------------------------------------------------
 Reporter:  sduran    |        Owner:  fog        
     Type:  defect    |       Status:  closed     
 Priority:  normal    |    Milestone:  PSYCOPG 2.0
Component:  psycopg2  |      Version:  2.0beta    
 Severity:  normal    |   Resolution:  invalid    
 Keywords:            |  
----------------------+-----------------------------------------------------
Changes (by fog):

  * resolution:  => invalid
  * status:  assigned => closed

Old description:

> psycopg2.extras.DictCursor doesn't implement __iter__, so iterating a
> DictCursor doesn't assign the index variables thus leaving an incomplete
> DictCursor.
>
> I wrote this simple __iter__ function:
> {{{
>    def __iter__(self):
>       while True:
>         row = self.fetchone()
>         if not row:
>           break
>         yield row
> }}}

New description:

 psycopg2.extras.!DictCursor doesn't implement !__iter!__, so iterating a
 !DictCursor doesn't assign the index variables thus leaving an incomplete
 !DictCursor.

 I wrote this simple !__iter!__ function:
 {{{
    def __iter__(self):
       while True:
         row = self.fetchone()
         if not row:
           break
         yield row
 }}}

Comment:

 After a little investigation: !DictCursor does not need to implement
 !__iter!__ because the !__iter!__ in the base cursor returns itself (as it
 should be). The error was the missing next() method in !DictCursor. This
 was fixed some time ago.

-- 
Ticket URL: <http://initd.org/tracker/psycopg/ticket/105>
psycopg <http://initd.org/>
psycopg
_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/+sw@xxxxxxxxxxxxxxxx
http://lists.initd.org/mailman/listinfo/psycopg
<Prev in Thread] Current Thread [Next in Thread>