def put_bundle(new_bundle_name, original_bundle_name=None): """Puts a new ResourceBundle, optionally copying from another bundle.""" new_bundle = ResourceBundle(key_name=new_bundle_name) entities = [new_bundle] if original_bundle_name: original_bundle = ResourceBundle.get_by_key_name(original_bundle_name) original_resources = Resource.all().ancestor(original_bundle) entities += [Resource(parent=new_bundle, key_name=resource.key().name(), cache_seconds=resource.cache_seconds, content=resource.content) for resource in original_resources] db.put(entities)