def migrate(request): def clone_entity(e, **extra_args): """Clones an entity, adding or overriding constructor attributes. The cloned entity will have exactly the same property values as the original entity, except where overridden. By default it will have no parent entity or key name, unless supplied. Args: e: The entity to clone extra_args: Keyword arguments to override from the cloned entity and pass to the constructor. Returns: A cloned, possibly modified, copy of entity e. """ klass = e.__class__ props = dict((k, v.__get__(e, klass)) for k, v in klass.properties().iteritems()) props.update(extra_args) return klass(**props) set_namespace('') key_name = os.environ.get('HTTP_HOST') #site=site=models.Eventsite.all().filter('hostnames = ',key_name).get() site = Query(models.Eventsite, namespace='').filter('hostnames = ', key_name).get() if not site: return HttpResponse("Couldn't find a site to migrate") new_namespace = request.environ.get('HTTP_HOST').split(':')[0] old_chimp = site.chimp set_namespace(new_namespace) namespace_registry.register(new_namespace) new_site = clone_entity(site, key_name=new_namespace) new_site.put() namespace_registry.register(new_namespace) if old_chimp: new_chimp = clone_entity(old_chimp, parent=new_site) new_chimp.put() taskqueue.add( url='/admin/migrate-profiles/', params={ 'new_namespace': new_namespace, 'old_site': site.key(), 'new_site': new_site.key(), }, ) set_namespace('') return HttpResponse('Migrated Site')
def migrate(request): def clone_entity(e, **extra_args): """Clones an entity, adding or overriding constructor attributes. The cloned entity will have exactly the same property values as the original entity, except where overridden. By default it will have no parent entity or key name, unless supplied. Args: e: The entity to clone extra_args: Keyword arguments to override from the cloned entity and pass to the constructor. Returns: A cloned, possibly modified, copy of entity e. """ klass = e.__class__ props = dict((k, v.__get__(e, klass)) for k, v in klass.properties().iteritems()) props.update(extra_args) return klass(**props) set_namespace('') key_name = os.environ.get('HTTP_HOST') #site=site=models.Eventsite.all().filter('hostnames = ',key_name).get() site=Query(models.Eventsite, namespace='').filter('hostnames = ',key_name).get() if not site:return HttpResponse("Couldn't find a site to migrate") new_namespace=request.environ.get('HTTP_HOST').split(':')[0] old_chimp=site.chimp set_namespace(new_namespace) namespace_registry.register(new_namespace) new_site=clone_entity(site, key_name=new_namespace) new_site.put() namespace_registry.register(new_namespace) if old_chimp: new_chimp=clone_entity(old_chimp, parent=new_site) new_chimp.put() taskqueue.add(url='/admin/migrate-profiles/', params={'new_namespace':new_namespace, 'old_site':site.key(), 'new_site':new_site.key(), },) set_namespace('') return HttpResponse('Migrated Site')