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

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

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

revision 1016 by bh, Fri May 23 11:05:59 2003 UTC revision 1124 by bh, Mon Jun 2 14:14:25 2003 UTC
# Line 15  import weakref Line 15  import weakref
15  from messages import MAPS_CHANGED, EXTENSIONS_CHANGED, FILENAME_CHANGED, \  from messages import MAPS_CHANGED, EXTENSIONS_CHANGED, FILENAME_CHANGED, \
16       MAP_LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \       MAP_LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \
17       LAYER_CHANGED, LAYER_PROJECTION_CHANGED, LAYER_VISIBILITY_CHANGED,\       LAYER_CHANGED, LAYER_PROJECTION_CHANGED, LAYER_VISIBILITY_CHANGED,\
18       EXTENSION_CHANGED, EXTENSION_OBJECTS_CHANGED, CHANGED       EXTENSION_CHANGED, EXTENSION_OBJECTS_CHANGED, CHANGED, \
19         TABLE_REMOVED
20    
21  from Thuban import _  from Thuban import _
22    
23  from base import TitledObject, Modifiable  from base import TitledObject, Modifiable
24  from map import Map  from map import Map
25  from data import ShapefileStore  from data import ShapefileStore
26    from table import DBFTable
27    
28  from transientdb import TransientDatabase, AutoTransientTable  from transientdb import TransientDatabase, AutoTransientTable
29    
# Line 201  class Session(TitledObject, Modifiable): Line 203  class Session(TitledObject, Modifiable):
203          """          """
204          return self.tables + [store.Table() for store in self.ShapeStores()]          return self.tables + [store.Table() for store in self.ShapeStores()]
205    
206        def UnreferencedTables(self):
207            """Return the tables that are not referenced by other data sources"""
208            known = {}
209            for table in self.tables:
210                known[id(table)] = 0
211            for table in self.tables + self.ShapeStores():
212                for dep in table.Dependencies():
213                    known[id(dep)] = 1
214            return [table for table in self.tables if known[id(table)] == 0]
215    
216      def AddTable(self, table):      def AddTable(self, table):
217          """Add the table to the session          """Add the table to the session
218    
# Line 225  class Session(TitledObject, Modifiable): Line 237  class Session(TitledObject, Modifiable):
237          else:          else:
238              transient_table = table              transient_table = table
239          self.tables.append(transient_table)          self.tables.append(transient_table)
240            self.changed()
241          return transient_table          return transient_table
242    
243      def RemoveTable(self, table):      def RemoveTable(self, table):
# Line 233  class Session(TitledObject, Modifiable): Line 246  class Session(TitledObject, Modifiable):
246          The table object must be a table object previously returned by          The table object must be a table object previously returned by
247          the AddTable method. If the table is not part of the session          the AddTable method. If the table is not part of the session
248          raise a ValueError.          raise a ValueError.
249    
250            Issue a TABLE_REMOVED message after the table has been removed.
251            The message has the removed table as the single parameter.
252          """          """
253          tables = [t for t in self.tables if t is not table]          tables = [t for t in self.tables if t is not table]
254          if len(tables) == len(self.tables):          if len(tables) == len(self.tables):
255              raise ValueError              raise ValueError
256          self.tables = tables          self.tables = tables
257            self.changed(TABLE_REMOVED, table)
258    
259        def OpenTableFile(self, filename):
260            """Open the table file filename and return the table object.
261    
262            The filename argument must be the name of a DBF file.
263            """
264            return self.AddTable(DBFTable(filename))
265    
266      def temp_directory(self):      def temp_directory(self):
267          """          """

Legend:
Removed from v.1016  
changed lines
  Added in v.1124

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26