Pass _updateField the entity_properties dict instead of just the value
This enables _updateField to change the value in entity_properties if
desired.
Patch by: Sverre Rabbelier
--- a/app/soc/logic/models/base.py Thu Feb 26 16:51:35 2009 +0000
+++ b/app/soc/logic/models/base.py Thu Feb 26 16:52:29 2009 +0000
@@ -358,7 +358,8 @@
if name in self._skip_properties or (name not in entity_properties):
continue
- if self._updateField(entity, name, value):
+ if self._updateField(entity, entity_properties, name):
+ value = entity_properties[name]
prop.__set__(entity, value)
entity.put()
@@ -418,7 +419,7 @@
# entity has been deleted call _onDelete
self._onDelete(entity)
- def _updateField(self, entity, name, value):
+ def _updateField(self, entity, entity_properties, name):
"""Hook called when a field is updated.
Base classes should override if any special actions need to be
--- a/app/soc/logic/models/document.py Thu Feb 26 16:51:35 2009 +0000
+++ b/app/soc/logic/models/document.py Thu Feb 26 16:52:29 2009 +0000
@@ -61,10 +61,12 @@
return ['prefix', 'scope_path', 'link_id']
- def _updateField(self, entity, name, value):
+ def _updateField(self, entity, entity_properties, name):
"""Special logic for role. If state changes to active we flush the sidebar.
"""
+ value = entity_properties[name]
+
if (name == 'is_featured') and (entity.is_featured != value):
sidebar.flush()
--- a/app/soc/logic/models/notification.py Thu Feb 26 16:51:35 2009 +0000
+++ b/app/soc/logic/models/notification.py Thu Feb 26 16:52:29 2009 +0000
@@ -60,10 +60,12 @@
super(Logic, self)._onCreate(entity)
- def _updateField(self, entity, name, value):
+ def _updateField(self, entity, entity_properties, name):
"""If unread changes we flush the sidebar cache.
"""
+ value = entity_properties[name]
+
if (name == 'unread') and (entity.unread != value):
# in case that the unread value changes we flush the sidebar.
sidebar.flush(entity.scope.account)
--- a/app/soc/logic/models/role.py Thu Feb 26 16:51:35 2009 +0000
+++ b/app/soc/logic/models/role.py Thu Feb 26 16:52:29 2009 +0000
@@ -63,10 +63,12 @@
return group
- def _updateField(self, entity, name, value):
+ def _updateField(self, entity, entity_properties, name):
"""Special logic for role. If status changes to active we flush the sidebar.
"""
+ value = entity_properties[name]
+
if (name == 'status') and (entity.status != value) and value == 'active':
# in case the status of the role changes to active we flush the sidebar
# cache. Other changes will be visible after the retention time expires.
--- a/app/soc/logic/models/user.py Thu Feb 26 16:51:35 2009 +0000
+++ b/app/soc/logic/models/user.py Thu Feb 26 16:52:29 2009 +0000
@@ -129,7 +129,7 @@
return ['link_id']
- def _updateField(self, entity, name, value):
+ def _updateField(self, entity, entity_properties, name):
"""Special case logic for account.
When the account is changed, the former_accounts field should be appended
@@ -139,6 +139,8 @@
Make sure once the user agreed ToS, the ToS fields can't be changed.
"""
+ value = entity_properties[name]
+
# iff the agreed_to_tos is True and we want to set it to False
if (name == 'agreed_to_tos') and (not value) and entity.agreed_to_tos:
return False