def buildObject(self): """ Updates the dict content with the context structure, with data from the request """ # Update properties from request data if defined in schema # Also create properties with a default value defined ob = {} properties = {} for key, value in self.schema.items(): default = value.get('default', None) if key in self.data: properties[key] = self.data[key] elif default: properties[key] = default ob['urlHash'] = sha1(self.data['url']).hexdigest() # If creating with the twitterUsername, get its Twitter ID if self.data.get('twitterUsername', None): ob['twitterUsernameId'] = getUserIdFromTwitter( self.data['twitterUsername']) ob.update(properties) self.update(ob)
def buildObject(self): """ Updates the dict content with the context structure, with data from the request """ # Update properties from request data if defined in schema # Also create properties with a default value defined ob = {} properties = {} for key, value in self.schema.items(): default = value.get('default', None) if key in self.data: properties[key] = self.data[key] elif default: properties[key] = default ob['urlHash'] = sha1(self.data['url']).hexdigest() # If creating with the twitterUsername, get its Twitter ID if self.data.get('twitterUsername', None): ob['twitterUsernameId'] = getUserIdFromTwitter(self.data['twitterUsername']) ob.update(properties) self.update(ob)
def modifyContext(self, properties): """Update the user object with the given properties""" # If updating the twitterUsername, get its Twitter ID if properties.get('twitterUsername', None): properties['twitterUsernameId'] = getUserIdFromTwitter(properties['twitterUsername']) self.updateFields(properties) if self.get('twitterUsername', None) == None and self.get('twitterUsernameId', None) != None: del self['twitterUsernameId'] self.save()
def modifyContext(self, properties): """Update the user object with the given properties""" # If updating the twitterUsername, get its Twitter ID if properties.get('twitterUsername', None): properties['twitterUsernameId'] = getUserIdFromTwitter( properties['twitterUsername']) self.updateFields(properties) if self.get( 'twitterUsername', None) == None and self.get('twitterUsernameId', None) != None: del self['twitterUsernameId'] self.save()