/[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 1625 by bh, Thu Aug 21 16:02:23 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  if psycopg is not None:  if psycopg is not None:
32      type_map = [(psycopg.STRING, table.FIELDTYPE_STRING),      type_map = [(psycopg.STRING, table.FIELDTYPE_STRING),
# Line 48  class PostGISConnection: Line 55  class PostGISConnection:
55          self.user = user          self.user = user
56          self.password = password          self.password = password
57          self.dbtype = dbtype          self.dbtype = dbtype
58            self.connect()
59    
60        def connect(self):
61            """Internal: Establish the database connection"""
62          params = []          params = []
63          for name in ("host", "port", "dbname", "user", "password"):          for name in ("host", "port", "dbname", "user", "password"):
64              val = getattr(self, name)              val = getattr(self, name)
# Line 67  class PostGISConnection: Line 78  class PostGISConnection:
78          else:          else:
79              raise ValueError("Can't determine postgres type of geometries")              raise ValueError("Can't determine postgres type of geometries")
80    
81        def BriefDescription(self):
82            """Return a brief, one-line description of the connection
83    
84            The return value is suitable for a list box of all database
85            connections.
86            """
87            return ("postgis://%(user)s@%(host)s:%(port)s/%(dbname)s"
88                    % self.__dict__)
89    
90      def Close(self):      def Close(self):
91          """Close the database connection"""          """Close the database connection"""
92          self.connection.close()          self.connection.close()

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26