- added update_last_updated(). Records when a record was last updated
authorTony Mack <tmack@cs.princeton.edu>
Wed, 22 Aug 2007 19:54:21 +0000 (19:54 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Wed, 22 Aug 2007 19:54:21 +0000 (19:54 +0000)
PLC/Nodes.py
PLC/Persons.py
PLC/Sites.py

index b99aa52..62e2320 100644 (file)
@@ -4,7 +4,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: Nodes.py,v 1.33 2007/06/08 17:59:53 tmack Exp $
+# $Id: Nodes.py,v 1.34 2007/07/12 17:55:02 tmack Exp $
 #
 
 from types import StringTypes
@@ -108,7 +108,19 @@ class Node(Row):
        assert self.table_name
 
        self.api.db.do("UPDATE %s SET last_contact = CURRENT_TIMESTAMP " % (self.table_name) + \
-                      " where node_id = %d" % ( self['node_id']) )
+                      " where node_id = %d" % (self['node_id']) )
+       self.sync(commit)
+
+    def update_last_updated(self, commit = True):
+       """
+       Update last_updated field with current time
+       """
+       
+       assert 'node_id' in self
+       assert self.table_name
+       
+       self.api.db.do("UPDATE %s SET last_updated = CURRENT_TIMESTAMP " % (self.table_name) + \
+                      " where node_id = %d" % (self['node_id']) )
        self.sync(commit)
 
     def delete(self, commit = True):
index 32549cf..94ab402 100644 (file)
@@ -4,7 +4,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: Persons.py,v 1.36 2007/03/29 20:14:46 tmack Exp $
+# $Id: Persons.py,v 1.37 2007/06/14 16:26:01 tmack Exp $
 #
 
 from types import StringTypes
@@ -217,6 +217,18 @@ class Person(Row):
         self['site_ids'].remove(site_id)
         self['site_ids'].insert(0, site_id)
 
+    def update_last_updated(self, commit = True):
+        """
+        Update last_updated field with current time
+        """
+       
+       assert 'person_id' in self
+       assert self.table_name
+       
+       self.api.db.do("UPDATE %s SET last_updated = CURRENT_TIMESTAMP " % (self.table_name) + \
+                       " where person_id = %d" % (self['person_id']) )
+        self.sync(commit)
+
     def delete(self, commit = True):
         """
         Delete existing user.
index 4749f84..4aead29 100644 (file)
@@ -101,6 +101,18 @@ class Site(Row):
     add_address = Row.add_object(Address, 'site_address')
     remove_address = Row.remove_object(Address, 'site_address')
 
+    def update_last_updated(self, commit = True):
+        """
+        Update last_updated field with current time
+        """
+
+        assert 'site_id' in self
+        assert self.table_name
+
+        self.api.db.do("UPDATE %s SET last_updated = CURRENT_TIMESTAMP " % (self.table_name) + \
+                       " where site_id = %d" % (self['site_id']) )
+        self.sync(commit)    
+
     def delete(self, commit = True):
         """
         Delete existing site.