[GRASS-SVN] r51227 - grass/trunk/lib/python/temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Mar 31 16:41:36 EDT 2012
Author: huhabla
Date: 2012-03-31 13:41:35 -0700 (Sat, 31 Mar 2012)
New Revision: 51227
Modified:
grass/trunk/lib/python/temporal/abstract_map_dataset.py
grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
Log:
Documentation update
Modified: grass/trunk/lib/python/temporal/abstract_map_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_map_dataset.py 2012-03-31 17:21:44 UTC (rev 51226)
+++ grass/trunk/lib/python/temporal/abstract_map_dataset.py 2012-03-31 20:41:35 UTC (rev 51227)
@@ -360,6 +360,10 @@
@param dbif: The database interface to be used
@param update: Call for each unregister statement the update from registered maps
of the space time dataset. This can slow down the un-registration process significantly.
+ @param execute: If True the SQL DELETE and DROP table statements will be executed.
+ If False the prepared SQL statements are returned and must be executed by the caller.
+
+ @return The SQL statements if execute == False, else an empty string, None in case of a failure
"""
connect = False
@@ -374,9 +378,9 @@
# SELECT all needed information from the database
self.metadata.select(dbif)
-
+
# First we unregister from all dependent space time datasets
- statement += self.unregister(dbif, update, False)
+ statement += self.unregister(dbif=dbif, update=update, execute=False)
# Remove the strds register table
if self.get_stds_register():
@@ -387,21 +391,12 @@
# Delete yourself from the database, trigger functions will take care of dependencies
statement += self.base.get_delete_statement() + ";\n"
- # Remove the timestamp from the file system
- if self.get_type() == "vect":
- if self.get_layer():
- core.run_command(self.get_timestamp_module_name(), map=self.get_map_id(), layer=self.get_layer(), date="none")
- else:
- core.run_command(self.get_timestamp_module_name(), map=self.get_map_id(), date="none")
- else:
- core.run_command(self.get_timestamp_module_name(), map=self.get_map_id(), date="none")
-
if execute == True:
sql_script = ""
sql_script += "BEGIN TRANSACTION;\n"
sql_script += statement
sql_script += "END TRANSACTION;"
- print sql_script
+ # print sql_script
try:
if dbmi.__name__ == "sqlite3":
dbif.cursor.executescript(statement)
@@ -415,6 +410,15 @@
dbif.connection.commit()
+ # Remove the timestamp from the file system
+ if self.get_type() == "vect":
+ if self.get_layer():
+ core.run_command(self.get_timestamp_module_name(), map=self.get_map_id(), layer=self.get_layer(), date="none")
+ else:
+ core.run_command(self.get_timestamp_module_name(), map=self.get_map_id(), date="none")
+ else:
+ core.run_command(self.get_timestamp_module_name(), map=self.get_map_id(), date="none")
+
self.reset(None)
if connect == True:
@@ -432,6 +436,10 @@
@param dbif: The database interface to be used
@param update: Call for each unregister statement the update from registered maps
of the space time dataset. This can slow down the un-registration process significantly.
+ @param execute: If True the SQL DELETE and DROP table statements will be executed.
+ If False the prepared SQL statements are returned and must be executed by the caller.
+
+ @return The SQL statements if execute == False, else an empty string
"""
if self.get_layer():
@@ -474,7 +482,7 @@
sql_script += "BEGIN TRANSACTION;\n"
sql_script += statement
sql_script += "END TRANSACTION;"
- print sql_script
+ # print sql_script
try:
if dbmi.__name__ == "sqlite3":
dbif.cursor.executescript(statement)
Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2012-03-31 17:21:44 UTC (rev 51226)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2012-03-31 20:41:35 UTC (rev 51227)
@@ -764,9 +764,10 @@
This method removes the space time dataset from the temporal database and drops its map register table
@param dbif: The database interface to be used
- @param execute: If ture the DELETE statements are executed
+ @param execute: If True the SQL DELETE and DROP table statements will be executed.
+ If False the prepared SQL statements are returned and must be executed by the caller.
- @return The DELETE SQL statements
+ @return The SQL statements if execute == False, else an empty string
"""
# First we need to check if maps are registered in this dataset and
# unregister them
@@ -785,6 +786,7 @@
self.metadata.select(dbif)
core.verbose(_("Drop map register table: %s") % (self.get_map_register()))
+
if self.get_map_register():
rows = self.get_registered_maps("id", None, None, dbif)
# Unregister each registered map in the table
@@ -795,7 +797,7 @@
core.percent(count, num_maps, 1)
# Unregister map
map = self.get_new_map_instance(row["id"])
- statement += self.unregister_map(map, dbif, False)
+ statement += self.unregister_map(map=map, dbif=dbif, execute=False)
count += 1
core.percent(1, 1, 1)
# Safe the DROP table statement
@@ -803,6 +805,7 @@
# Remove the primary key, the foreign keys will be removed by trigger
statement += self.base.get_delete_statement() + ";\n"
+
if execute == True:
sql_script = ""
sql_script += "BEGIN TRANSACTION;\n"
@@ -1057,9 +1060,10 @@
@param map: The map object to unregister
@param dbif: The database interface to be used
- @param execute: If ture the DELETE statements are executed
+ @param execute: If True the SQL DELETE and DROP table statements will be executed.
+ If False the prepared SQL statements are returned and must be executed by the caller.
- @return The DELETE SQL statements
+ @return The SQL statements if execute == False, else an empty string, None in case of a failure
"""
statement = ""
More information about the grass-commit
mailing list