/[gnue]/gnue-common/src/datasources/GIntrospection.py
ViewVC logotype

Diff of /gnue-common/src/datasources/GIntrospection.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jcater, Fri Oct 10 01:21:09 2003 UTC revision 1.2 by jcater, Tue Nov 25 17:01:29 2003 UTC
# Line 0  Line 1 
1    #
2    # This file is part of GNU Enterprise.
3    #
4    # GNU Enterprise is free software; you can redistribute it
5    # and/or modify it under the terms of the GNU General Public
6    # License as published by the Free Software Foundation; either
7    # version 2, or (at your option) any later version.
8    #
9    # GNU Enterprise is distributed in the hope that it will be
10    # useful, but WITHOUT ANY WARRANTY; without even the implied
11    # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12    # PURPOSE. See the GNU General Public License for more details.
13    #
14    # You should have received a copy of the GNU General Public
15    # License along with program; see the file COPYING. If not,
16    # write to the Free Software Foundation, Inc., 59 Temple Place
17    # - Suite 330, Boston, MA 02111-1307, USA.
18    #
19    # Copyright 2000-2003 Free Software Foundation
20    #
21    # FILE:
22    # GConnection.py
23    #
24    # DESCRIPTION:
25    #
26    # NOTES:
27    #   Old methods in GDataObjects and their new counterparts:
28    #     * getSchemaTypes()       -->  types
29    #     * getSchemaList()        -->  find(type='...')
30    #     * getSchemaByName()      -->  find(name='...')
31    #     * writeSchema()          -->  write()
32    #
33    #  Preferred way to access these discovery routines is:
34    #    connection.schema.<function>
35    #
36    
37    import string
38    
39    
40    #
41    # Schema (metadata) functions
42    #
43    class Introspection:
44    
45      def __init__(self, connection):
46        self._connection = connection
47    
48      # Return a list of the types of Schema objects this driver provides
49      # Contains tuples of (key, description, dataSource??)
50      # dataSource?? is true if this schema type can be a datasource
51      types = []
52    
53    
54      # Return a list of Schema objects
55      def find(self, name=None, type=None):
56        return []
57    
58    
59      def findfirst(self, *args, **parms):
60        return self.find(*args, **parms)[0]
61    
62    
63      # write Schema to Database
64      def write(self,obj,overwrite=0):
65        tmsg = _("This database adapter doesn't have 'schema writing' support")
66        raise NoWriteSchemaSupport, tmsg
67    
68    
69    
70    # Used by the introspection classes
71    class Schema:
72      def __init__(self, attrs={}, getChildSchema=None):
73        self.name = ''
74        self.type = ''
75        self.__dict__.update(attrs)
76        if getChildSchema != None:
77          self.getChildSchema = getChildSchema
78    
79      def __cmp__(self, other):
80        if not isinstance(other, Schema):
81          return 1
82        elif id(other) == id(self):
83          return 0
84        else:
85          return cmp(string.lower(self.name), string.lower(other.name)) or 1
86    
87      def getChildSchema(self, parent):
88        return ()
89    
90    
91    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26