def Render(cls, handler): """Rendering method that can be called by main.py. Args: handler: the webapp.RequestHandler invoking the method """ namespace = handler.request.get('namespace') kinds = handler.request.get_all('kind') sizes_known, size_total, remainder = utils.ParseKindsAndSizes(kinds) (namespace_str, kind_str) = utils.GetPrintableStrs(namespace, kinds) notreadonly_warning = capabilities.CapabilitySet( 'datastore_v3', capabilities=['write']).is_enabled() blob_warning = bool(blobstore.BlobInfo.all().fetch(1)) datastore_type = datastore._GetConnection().get_datastore_type() high_replication_warning = (datastore_type == datastore_rpc.Connection. HIGH_REPLICATION_DATASTORE) template_params = { 'form_target': DoCopyHandler.SUFFIX, 'kind_list': kinds, 'remainder': remainder, 'sizes_known': sizes_known, 'size_total': size_total, 'app_id': handler.request.get('app_id'), 'datastore_admin_home': utils.GenerateHomeUrl(handler.request), 'kind_str': kind_str, 'namespace_str': namespace_str, 'xsrf_token': utils.CreateXsrfToken(XSRF_ACTION), 'notreadonly_warning': notreadonly_warning, 'blob_warning': blob_warning, 'high_replication_warning': high_replication_warning, } utils.RenderToResponse(handler, 'confirm_copy.html', template_params)
def Render(cls, handler): """Rendering method that can be called by main.py or get. This method executes no action, so the method by which it is accessed is immaterial. Creating a form with get may be a desirable function. That is, if this builtin is turned on, anyone can create a form to delete a kind by simply linking to the ConfirmDeleteHandler like so: <a href="/_ah/datastore_admin/confirm_delete?kind=trash"> Delete all Trash Objects</a> Args: handler: the webapp.RequestHandler invoking the method """ readonly_warning = not capabilities.CapabilitySet( 'datastore_v3', capabilities=['write']).is_enabled() namespace = handler.request.get('namespace') kinds = handler.request.get_all('kind') sizes_known, size_total, remainder = utils.ParseKindsAndSizes(kinds) (namespace_str, kind_str) = utils.GetPrintableStrs(namespace, kinds) template_params = { 'readonly_warning': readonly_warning, 'form_target': DoDeleteHandler.SUFFIX, 'kind_list': kinds, 'remainder': remainder, 'sizes_known': sizes_known, 'size_total': size_total, 'app_id': handler.request.get('app_id'), 'datastore_admin_home': utils.GenerateHomeUrl(handler.request), 'kind_str': kind_str, 'namespace_str': namespace_str, 'xsrf_token': utils.CreateXsrfToken(XSRF_ACTION), } utils.RenderToResponse(handler, 'confirm_delete.html', template_params)
def ListActions(self, error=None): """Handler for get requests to datastore_admin/confirm_delete.""" use_stats_kinds = False kinds = [] more_kinds = False try: kinds, more_kinds = self.GetKinds() if not kinds: use_stats_kinds = True logging.warning( 'Found no kinds. Using datastore stats instead.') except datastore_errors.Error as e: logging.exception(e) use_stats_kinds = True last_stats_update, kind_stats = _GetDatastoreStats( kinds, use_stats_kinds=use_stats_kinds) template_params = { 'run_as_a_service': self.request.get('run_as_a_service'), 'datastore_admin_home': utils.GenerateHomeUrl(None), 'offer_service': (self.request.get('service') and not self.request.get('run_as_a_service')), 'kind_stats': kind_stats, 'more_kinds': more_kinds, 'last_stats_update': last_stats_update, 'app_id': self.request.get('app_id'), 'hosting_app_id': app_identity.get_application_id(), 'has_namespace': self.request.get('namespace', None) is not None, 'namespace': self.request.get('namespace'), 'action_list': sorted(ENTITY_ACTIONS.keys()), 'backup_action_list': sorted(BACKUP_ACTIONS.keys()), 'pending_backup_action_list': sorted(PENDING_BACKUP_ACTIONS.keys()), 'error': error, 'completed_operations': self.GetOperations(active=False), 'active_operations': self.GetOperations(active=True), 'pending_backups': self.GetPendingBackups(), 'backups': self.GetBackups(), 'map_reduce_path': config.MAPREDUCE_PATH + '/detail' } utils.RenderToResponse(self, 'list_actions.html', template_params)