Пример #1
0
    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)
Пример #2
0
    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', None)
        has_namespace = namespace is not None
        kinds = handler.request.get_all('kind')
        sizes_known, size_total, remainder = utils.ParseKindsAndSizes(kinds)
        notreadonly_warning = capabilities.CapabilitySet(
            'datastore_v3', capabilities=['write']).is_enabled()
        blob_warning = bool(blobstore.BlobInfo.all().count(1))
        app_id = handler.request.get('app_id')
        template_params = {
            'form_target': DoBackupHandler.SUFFIX,
            'kind_list': kinds,
            'remainder': remainder,
            'sizes_known': sizes_known,
            'size_total': size_total,
            'app_id': app_id,
            'queues': None,
            'cancel_url': handler.request.get('cancel_url'),
            'has_namespace': has_namespace,
            'namespace': namespace,
            'xsrf_token': utils.CreateXsrfToken(XSRF_ACTION),
            'notreadonly_warning': notreadonly_warning,
            'blob_warning': blob_warning,
            'backup_name': 'datastore_backup_%s' % time.strftime('%Y_%m_%d')
        }
        utils.RenderToResponse(handler, 'confirm_backup.html', template_params)
    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('kind', allow_multiple=True)
        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'),
            'cancel_url': handler.request.get('cancel_url'),
            '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)