22 |
from base import TitledObject, Modifiable |
from base import TitledObject, Modifiable |
23 |
from map import Map |
from map import Map |
24 |
from data import ShapefileStore |
from data import ShapefileStore |
25 |
|
from table import DBFTable |
26 |
|
|
27 |
from transientdb import TransientDatabase, AutoTransientTable |
from transientdb import TransientDatabase, AutoTransientTable |
28 |
|
|
228 |
self.tables.append(transient_table) |
self.tables.append(transient_table) |
229 |
return transient_table |
return transient_table |
230 |
|
|
231 |
|
def RemoveTable(self, table): |
232 |
|
"""Remove the table from the session. |
233 |
|
|
234 |
|
The table object must be a table object previously returned by |
235 |
|
the AddTable method. If the table is not part of the session |
236 |
|
raise a ValueError. |
237 |
|
""" |
238 |
|
tables = [t for t in self.tables if t is not table] |
239 |
|
if len(tables) == len(self.tables): |
240 |
|
raise ValueError |
241 |
|
self.tables = tables |
242 |
|
|
243 |
|
def OpenTableFile(self, filename): |
244 |
|
"""Open the table file filename and return the table object. |
245 |
|
|
246 |
|
The filename argument must be the name of a DBF file. |
247 |
|
""" |
248 |
|
return self.AddTable(DBFTable(filename)) |
249 |
|
|
250 |
def temp_directory(self): |
def temp_directory(self): |
251 |
""" |
""" |
252 |
Return the name of the directory for session specific temporary files |
Return the name of the directory for session specific temporary files |
266 |
self._add_shapestore(store) |
self._add_shapestore(store) |
267 |
return store |
return store |
268 |
|
|
269 |
|
def AddShapeStore(self, shapestore): |
270 |
|
"""Add the shapestore to the session. |
271 |
|
|
272 |
|
The session only holds a weak reference to the shapestore, so it |
273 |
|
will automatically be removed from the session when the last |
274 |
|
reference goes away. |
275 |
|
""" |
276 |
|
self._add_shapestore(shapestore) |
277 |
|
return shapestore |
278 |
|
|
279 |
def TransientDB(self): |
def TransientDB(self): |
280 |
if self.transient_db is None: |
if self.transient_db is None: |
281 |
filename = os.path.join(self.temp_directory(), "transientdb") |
filename = os.path.join(self.temp_directory(), "transientdb") |