Package gen :: Package db :: Module cursor
[frames] | no frames]

Source Code for Module gen.db.cursor

 1  # 
 2  # Gramps - a GTK+/GNOME based genealogy program 
 3  # 
 4  # Copyright (C) 2000-2007  Donald N. Allingham 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify 
 7  # it under the terms of the GNU General Public License as published by 
 8  # the Free Software Foundation; either version 2 of the License, or 
 9  # (at your option) any later version. 
10  # 
11  # This program is distributed in the hope that it will be useful,  
12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  # GNU General Public License for more details. 
15  # 
16  # You should have received a copy of the GNU General Public License 
17  # along with this program; if not, write to the Free Software 
18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
19  # 
20   
21 -class GrampsCursor:
22 """ 23 Provide a basic iterator that allows the user to cycle through 24 the elements in a particular map. 25 26 A cursor should never be directly instantiated. Instead, in should be 27 created by the database class. 28 29 A cursor should only be used for a single pass through the 30 database. If multiple passes are needed, multiple cursors 31 should be used. 32 """ 33
34 - def first(self):
35 """ 36 Return the first (index, data) pair in the database. 37 38 This should be called before the first call to next(). Note that the 39 data return is in the format of the serialized format stored in the 40 database, not in the more usable class object. The data should be 41 converted to a class using the class's unserialize method. 42 43 If no data is available, None is returned. 44 """ 45 return None
46
47 - def next(self):
48 """ 49 Return the next (index, data) pair in the database. 50 51 Like the first() method, the data return is in the format of the 52 serialized format stored in the database, not in the more usable class 53 object. The data should be converted to a class using the class's 54 unserialize method. 55 56 None is returned when no more data is available. 57 """ 58 return None
59
60 - def close(self):
61 """ 62 Close the cursor. 63 64 This should be called when the user is finished using the cursor, 65 freeing up the cursor's resources. 66 """ 67 raise NotImplementedError
68
69 - def get_length(self):
70 """ 71 Return the number of records in the table referenced by the cursor. 72 """ 73 raise NotImplementedError
74