def _updateField(self, entity, entity_properties, name): """Special case logic for account. When the account is changed, the former_accounts field should be appended with the old account. Also, if either is_developer or agrees_to_tos change, the user's rights have changed, so we need to flush the sidebar. 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 # iff the agreed_to_tos_on has a value and we want to change it if (name == "agreed_to_tos_on") and entity.agreed_to_tos_on and (value != entity.agreed_to_tos_on): return False if (name == "is_developer") and (entity.is_developer != value): sidebar.flush(entity.account) if (name == "agreed_to_tos") and (entity.agreed_to_tos != value): sidebar.flush(entity.account) if name == "account": # normalize all accounts before doing anything with the value value = accounts.normalizeAccount(value) entity_properties[name] = value if entity.account != value: entity.former_accounts.append(entity.account) return True
def testFlush(self): """Test that getting after putting and flushing returns None. """ sidebar.put(42, self.memcache_key) sidebar.flush("id") self.assertEqual((None, self.memcache_key), sidebar.get("id"))
def testFlush(self): """Test that getting after putting and flushing returns None. """ sidebar.put(42, self.memcache_key) sidebar.flush('id') self.assertEqual((None, self.memcache_key), sidebar.get('id'))
def testFlush(self): """Test that getting after putting and flushing returns None. """ sidebar.add(42, self.memcache_key, None) sidebar.flush('id') self.assertEqual((None, self.memcache_key), sidebar.get(None, 'id'))
def _onCreate(self, entity): """Flush the sidebar cache when a new active role entity has been created. """ if entity.status == 'active': sidebar.flush(entity.user.account) super(Logic, self)._onCreate(entity)
def _onCreate(self, entity): """Flush the sidebar cache when a new active role entity has been created. """ if entity.status == "active": sidebar.flush(entity.user.account) super(Logic, self)._onCreate(entity)
def _onCreate(self, entity): """Sends out a message if there is only one unread notification. """ # TODO(srabbelier): check user preference notifications.sendNewNotificationMessage(entity) sidebar.flush(entity.scope.account) super(Logic, self)._onCreate(entity)
def _onCreate(self, entity): """Called when an entity has been created. Classes that override this can use it to do any post-creation operations. """ if not entity: raise NoEntityError sidebar.flush()
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() return True
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) return True
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. sidebar.flush(entity.user.account) return True
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): # 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. sidebar.flush(entity.user.account) return True
def _updateField(self, entity, entity_properties, name): """Special logic for Document. - Flush the sidebar when a document is featured. - Remove the document from the homepage cache when the home_for is updated """ value = entity_properties[name] if (name == 'is_featured') and (entity.is_featured != value): sidebar.flush() home_for = entity.home_for if (name != 'home_for') and home_for: home.flush(home_for) return True
def _onCreate(self, entity): """Sends out a message if there is only one unread notification. """ # create a special query on which we can call count query = db.Query(self._model) query.filter('scope =', entity.scope) query.filter('unread = ', True) # count the number of results with a maximum of two unread_count = query.count(2) if unread_count == 1: # there is only one unread notification so send out an email notifications.sendNewNotificationMessage(entity) sidebar.flush(entity.scope.account) super(Logic, self)._onCreate(entity)
def _updateField(self, entity, entity_properties, name): """Special case logic for account. When the account is changed, the former_accounts field should be appended with the old account. Also, if either is_developer or agrees_to_tos change, the user's rights have changed, so we need to flush the sidebar. 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 # iff the agreed_to_tos_on has a value and we want to change it if (name == 'agreed_to_tos_on') and entity.agreed_to_tos_on and ( value != entity.agreed_to_tos_on): return False if (name == 'is_developer') and (entity.is_developer != value): sidebar.flush(entity.account) if (name == 'agreed_to_tos') and (entity.agreed_to_tos != value): sidebar.flush(entity.account) if (name == 'account'): # normalize all accounts before doing anything with the value value = accounts.normalizeAccount(value) entity_properties[name] = value if entity.account != value: entity.former_accounts.append(entity.account) return True