git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8f69aef
)
Generic function to modify rows if write policy permits it
author
Sapan Bhatia
<sapanbhatia@boring3.CS.Princeton.EDU>
Tue, 27 Jul 2010 18:58:13 +0000
(14:58 -0400)
committer
Sapan Bhatia
<sapanbhatia@boring3.CS.Princeton.EDU>
Tue, 27 Jul 2010 18:58:13 +0000
(14:58 -0400)
PLC/Table.py
patch
|
blob
|
history
diff --git
a/PLC/Table.py
b/PLC/Table.py
index
b811c62
..
86f60cb
100644
(file)
--- a/
PLC/Table.py
+++ b/
PLC/Table.py
@@
-436,3
+436,16
@@
class Table(list):
key_field = self.classobj.primary_key
return dict([(obj[key_field], obj) for obj in self])
+
+ def update_rows(self, update_spec):
+ """
+ Dispatch requested change to individual rows, if write policy permits it
+ """
+ if (self.modify_ok(values)):
+ for row in self:
+ for update in update_spec:
+ key = update['key']
+ type = update['type']
+ value = update['value']
+ add_fn = row.add_object(type, key)
+ add_fn(value)