Package Pyblio :: Package External
[hide private]
[frames] | no frames]

Source Code for Package Pyblio.External

 1  # This file is part of pybliographer 
 2  #  
 3  # Copyright (C) 1998-2006 Frederic GOBRY 
 4  # Email : gobry@pybliographer.org 
 5  #           
 6  # This program is free software; you can redistribute it and/or 
 7  # modify it under the terms of the GNU General Public License 
 8  # as published by the Free Software Foundation; either version 2  
 9  # of the License, or (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  """Support for queries on external services.""" 
21   
22  from gettext import gettext as _ 
23   
24 -class IExternal(object):
25 """Interface for querying external databases. 26 27 This queries uses Twisted's deferred mechanism to handle 28 asynchronous results. At most one query can run on a given 29 IExternal object at a time. 30 """ 31 32 schema = '' # schema of the database this IExternal can parse into 33
34 - def __init__(self, db):
35 """Create a new external query interface. 36 37 Args: 38 db: Pyblio.Store.Database 39 """ 40 assert db.schema.id == self.schema, \ 41 _('invalid schema: %r instead of %r' % ( 42 db.schema.id, self.schema))
43
44 - def count(self, query):
45 """Return the number of matches for the specified query. 46 47 Args: 48 query: string 49 Return: 50 twisted.internet.defer.Deferred() -> int 51 """
52
53 - def search(self, query, maxhits=100):
54 """Return the number of matches for the specified query and a 55 ResultSet() with the records that have been retrieved (at most 56 maxhits). 57 58 Args: 59 query: string 60 maxhit: integer 61 Return: 62 (twisted.internet.defer.Deferred() -> int, 63 Pyblio.Store.ResultSet) 64 """
65
66 - def cancel(self):
67 """Cancel a pending query."""
68