I’ve got stored data that’s not needed and therefore I want to clean it. I could migrate from datastore to blobstore and therefore at least the field small=db.BlobProperty(default=None) is redundant so I’d like to remove it and also remove it from the entities that are in the datastore since the variable called “full” already has the origianl image and the variable named “small” is a resize that I either can get from the blobstore or if the image is not yet migrated I can resize the property “full” in memory and hence remove duplicate and redundant data.
But how do I remove a property from stored entities? I’d like to keep this class and move the blobproperties to blobstore and then remove the blobproperties so I suppose I must write a python script that iterates over the entities and sets the variable small to None and/or remove the variable named small from all entities. Can you advice how to do it?
class Image(db.Model):#migrate to blobstore
reference=db.ReferenceProperty(A,collection_name='matched_images',verbose_name="Title")
primary_image = blobstore.BlobReferenceProperty()
title=db.StringProperty(multiline=True,verbose_name="Title")
avatar=db.BlobProperty(default=None)
text=db.TextProperty(default=None)
name=db.StringProperty(default=None)
email=db.EmailProperty(indexed=False,verbose_name="Email")
name=db.StringProperty()
desc=db.StringProperty()
owner=db.UserProperty()
secret=db.StringProperty()
full=db.BlobProperty(default=None)
full_ext=db.StringProperty()
small=db.BlobProperty(default=None)
small_ext=db.StringProperty()
Will something like the following work?
# will DELETE the small property use /deletemodels?force=true
class DeleteSmallProperties(webapp.RequestHandler):
def get(self):
def dMsg(msg):
self.response.out.write(msg + '\n')
n = self.request.get('force')
if n:
dMsg('clearing Image.small data....')
for uc in Image.all():
uc.small = None #(?)
uc.save() #or us.put()?
dMsg('.')
How to remove it instead of just setting it to None?
I would go with the Mapreduce api that should be the best tool for the job in this case *:
1 . Register the mapper
2 . Update the entities
* In case the number of entities is not that big, you could simply iterate over each entity with a simple python script