/[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 765 by bh, Tue Apr 29 12:42:14 2003 UTC revision 851 by bh, Wed May 7 15:11:12 2003 UTC
# Line 129  class Session(TitledObject, Modifiable): Line 129  class Session(TitledObject, Modifiable):
129          self.filename = None          self.filename = None
130          self.maps = []          self.maps = []
131          self.tables = []          self.tables = []
132            self.shapestores = []
133          self.extensions = []          self.extensions = []
134          self.temp_dir = None          self.temp_dir = None
135          self.transient_db = None          self.transient_db = None
# Line 178  class Session(TitledObject, Modifiable): Line 179  class Session(TitledObject, Modifiable):
179              extension.Subscribe(channel, self.forward, channel)              extension.Subscribe(channel, self.forward, channel)
180          self.changed(EXTENSIONS_CHANGED)          self.changed(EXTENSIONS_CHANGED)
181    
182        def ShapeStores(self):
183            """Return a list of all ShapeStore objects open in the session"""
184            return [store() for store in self.shapestores]
185    
186        def _add_shapestore(self, store):
187            """Internal: Add the shapestore to the list of shapestores"""
188            self.shapestores.append(weakref.ref(store,
189                                                self._clean_weak_store_refs))
190    
191        def _clean_weak_store_refs(self, weakref):
192            """Internal: Remove the weakref from the shapestores list"""
193            self.shapestores = [store for store in self.shapestores
194                                      if store is not weakref]
195    
196        def Tables(self):
197            """Return a list of all table objects open in the session"""
198            # Tables are only available from shapestores at the moment, so
199            # we just take them from there
200            return [store.Table() for store in self.ShapeStores()]
201    
202      def temp_directory(self):      def temp_directory(self):
203          """          """
204          Return the name of the directory for session specific temporary files          Return the name of the directory for session specific temporary files
# Line 193  class Session(TitledObject, Modifiable): Line 214  class Session(TitledObject, Modifiable):
214    
215      def OpenShapefile(self, filename):      def OpenShapefile(self, filename):
216          """Return a shapefile store object for the data in the given file"""          """Return a shapefile store object for the data in the given file"""
217          return ShapefileStore(self, filename)          store = ShapefileStore(self, filename)
218            self._add_shapestore(store)
219            return store
220    
221      def TransientDB(self):      def TransientDB(self):
222          if self.transient_db is None:          if self.transient_db is None:
# Line 211  class Session(TitledObject, Modifiable): Line 234  class Session(TitledObject, Modifiable):
234          self.tables = []          self.tables = []
235          Modifiable.Destroy(self)          Modifiable.Destroy(self)
236    
237            # Close the transient DB explicitly so that it removes any
238            # journal files from the temporary directory
239            if self.transient_db is not None:
240                self.transient_db.close()
241    
242      def forward(self, *args):      def forward(self, *args):
243          """Reissue events.          """Reissue events.
244    

Legend:
Removed from v.765  
changed lines
  Added in v.851

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26