/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/postgisdb.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/postgisdb.py

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

revision 1605 by bh, Tue Aug 19 11:00:40 2003 UTC revision 1631 by bh, Fri Aug 22 16:01:14 2003 UTC
# Line 20  import wellknowntext Line 20  import wellknowntext
20    
21  from data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT, RAW_WKT  from data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT, RAW_WKT
22    
23    def has_postgis_support():
24        """Return whether this Thuban instance supports PostGIS connections
25    
26        Having PostGIS support means that the psycopg module can be
27        imported.
28        """
29        return psycopg is not None
30    
31    def psycopg_version():
32        return psycopg.__version__
33    
34  if psycopg is not None:  if psycopg is not None:
35      type_map = [(psycopg.STRING, table.FIELDTYPE_STRING),      type_map = [(psycopg.STRING, table.FIELDTYPE_STRING),
# Line 48  class PostGISConnection: Line 58  class PostGISConnection:
58          self.user = user          self.user = user
59          self.password = password          self.password = password
60          self.dbtype = dbtype          self.dbtype = dbtype
61            self.connect()
62    
63        def connect(self):
64            """Internal: Establish the database connection"""
65          params = []          params = []
66          for name in ("host", "port", "dbname", "user", "password"):          for name in ("host", "port", "dbname", "user", "password"):
67              val = getattr(self, name)              val = getattr(self, name)
# Line 67  class PostGISConnection: Line 81  class PostGISConnection:
81          else:          else:
82              raise ValueError("Can't determine postgres type of geometries")              raise ValueError("Can't determine postgres type of geometries")
83    
84        def BriefDescription(self):
85            """Return a brief, one-line description of the connection
86    
87            The return value is suitable for a list box of all database
88            connections.
89            """
90            return ("postgis://%(user)s@%(host)s:%(port)s/%(dbname)s"
91                    % self.__dict__)
92    
93      def Close(self):      def Close(self):
94          """Close the database connection"""          """Close the database connection"""
95          self.connection.close()          self.connection.close()

Legend:
Removed from v.1605  
changed lines
  Added in v.1631

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26