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 |
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 |
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: |