From: Tony Mack Date: Wed, 22 Aug 2007 19:54:21 +0000 (+0000) Subject: - added update_last_updated(). Records when a record was last updated X-Git-Tag: PLCAPI-4.2-0~86 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=2e91958ced6e3af70b12e01d1ac9a01154460723;p=plcapi.git - added update_last_updated(). Records when a record was last updated --- diff --git a/PLC/Nodes.py b/PLC/Nodes.py index b99aa52..62e2320 100644 --- a/PLC/Nodes.py +++ b/PLC/Nodes.py @@ -4,7 +4,7 @@ # Mark Huang # 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): diff --git a/PLC/Persons.py b/PLC/Persons.py index 32549cf..94ab402 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -4,7 +4,7 @@ # Mark Huang # 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. diff --git a/PLC/Sites.py b/PLC/Sites.py index 4749f84..4aead29 100644 --- a/PLC/Sites.py +++ b/PLC/Sites.py @@ -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.