Parent Directory
|
Revision Log
Next step of table implementation. Introduce a transient database using SQLite that some of the data is copied to on demand. This allows us to do joins and other operations that require an index for good performance with reasonable efficiency. Thuban now needs SQLite 2.8.0 and pysqlite 0.4.1. Older versions may work but I haven't tested that. * Thuban/Model/transientdb.py: New. Transient database implementation. * test/test_transientdb.py: New. Tests for the transient DB classes. * Thuban/Model/session.py (AutoRemoveFile, AutoRemoveDir): New classes to help automatically remove temporary files and directories. (Session.__init__): New instance variables temp_dir for the temporary directory and transient_db for the SQLite database (Session.temp_directory): New. Create a temporary directory if not yet done and return its name. Use AutoRemoveDir to have it automatically deleted (Session.TransientDB): Instantiate the transient database if not done yet and return it. * Thuban/Model/data.py (ShapefileStore.__init__): Use an AutoTransientTable so that data is copied to the transient DB on demand. (SimpleStore): New class that simply combines a table and a shapefile * Thuban/Model/table.py (Table, DBFTable): Rename Table into DBFTable and update its doc-string to reflect the fact that this is only the table interface to a DBF file. Table is now an alias for DBFTable for temporary backwards compatibility. * Thuban/UI/application.py (ThubanApplication.OnExit): Make sure the last reference to the session goes away so that the temporary files are removed properly. * test/test_load.py (LoadSessionTest.tearDown): Remove the reference to the session to make sure the temporary files are removed.
1 | bh | 723 | # Copyright (C) 2003 by Intevation GmbH |
2 | # Authors: | ||
3 | # Bernhard Herzog <[email protected]> | ||
4 | # | ||
5 | # This program is free software under the GPL (>=v2) | ||
6 | # Read the file COPYING coming with the software for details. | ||
7 | |||
8 | """Data source abstractions""" | ||
9 | |||
10 | __version__ = "$Revision$" | ||
11 | # $Source$ | ||
12 | # $Id$ | ||
13 | |||
14 | import os | ||
15 | |||
16 | import shapelib | ||
17 | import table | ||
18 | bh | 765 | import transientdb |
19 | bh | 723 | |
20 | bh | 765 | |
21 | bh | 723 | class ShapefileStore: |
22 | |||
23 | """Combine a shapefile and the corresponding DBF file into one object""" | ||
24 | |||
25 | def __init__(self, session, filename): | ||
26 | # Make the filename absolute. The filename will be | ||
27 | # interpreted relative to that anyway, but when saving a | ||
28 | # session we need to compare absolute paths and it's usually | ||
29 | # safer to always work with absolute paths. | ||
30 | self.filename = os.path.abspath(filename) | ||
31 | |||
32 | self.shapefile = shapelib.ShapeFile(self.filename) | ||
33 | bh | 765 | self.dbftable = table.DBFTable(filename) |
34 | self.table = transientdb.AutoTransientTable(session.TransientDB(), | ||
35 | self.dbftable) | ||
36 | bh | 723 | |
37 | def Table(self): | ||
38 | return self.table | ||
39 | |||
40 | def Shapefile(self): | ||
41 | return self.shapefile | ||
42 | bh | 765 | |
43 | |||
44 | class SimpleStore: | ||
45 | |||
46 | """Combine a shapefile and a table object""" | ||
47 | |||
48 | def __init__(self, shapefile, table): | ||
49 | self.shapefile = shapefile | ||
50 | self.table = table | ||
51 | self.filename = None | ||
52 | |||
53 | def Table(self): | ||
54 | return self.table | ||
55 | |||
56 | def Shapefile(self): | ||
57 | return self.shapefile |
Name | Value |
---|---|
svn:eol-style | native |
svn:keywords | Author Date Id Revision |
[email protected] | ViewVC Help |
Powered by ViewVC 1.1.26 |