google.appengine.ext.admin package

Summary

Simple datastore view and interactive console, for use in dev_appserver.

Contents

class google.appengine.ext.admin.BackendsPageHandler(*args, **kwargs)source

Bases: google.appengine.ext.admin.BaseRequestHandler

Shows information about an app’s backends.

PATH = '/backends'
get()source

Shows template displaying the app’s backends or a single backend.

get_backend_entry(backend_name)source

Get the BackendEntry for a single backend.

post()source
render_backend_page(backend_name)source

Shows template displaying a single backend.

render_backends_page()source

Shows template displaying all the app’s backends.

class google.appengine.ext.admin.BaseRequestHandlersource

Bases: google.appengine.ext.webapp._webapp25.RequestHandler

Supplies a common template generation function.

When you call generate(), we augment the template variables supplied with the current user in the ‘user’ variable and the current webapp request in the ‘request’ variable.

base_path()source

Returns the base path of this admin app, which is chosen by the user.

The user specifies which paths map to this application in their app.cfg. You can get that base path with this method. Combine with the constant paths specified by the classes to construct URLs.

filter_url(args)source

Filters the current URL to only have the given list of arguments.

For example, if your URL is /search?q=foo&num=100&start=10, then

self.filter_url([‘start’, ‘num’]) => /search?num=100&start=10 self.filter_url([‘q’]) => /search?q=10 self.filter_url([‘random’]) => /search?

generate(template_name, template_values={})source
in_production()source

Detects if app is running in production.

Returns a boolean.

interactive_console_enabled()source
class google.appengine.ext.admin.BlobKeyTypesource

Bases: google.appengine.ext.admin.StringType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.BlobTypesource

Bases: google.appengine.ext.admin.StringType

format(value)source
input_field(name, value, sample_values)source
name()source
python_type()source
class google.appengine.ext.admin.BoolTypesource

Bases: google.appengine.ext.admin.DataType

input_field(name, value, sample_values)source
name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.ByteStringTypesource

Bases: google.appengine.ext.admin.StringType

format(value)source
name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.CategoryTypesource

Bases: google.appengine.ext.admin.StringType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.CronPageHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Shows information about configured cron jobs in this application.

PATH = '/cron'
get(now=None)source

Shows template displaying the configured cron jobs.

class google.appengine.ext.admin.DataTypesource

Bases: object

A DataType represents a data type in the datastore.

Each DataType subtype defines four methods:

format: returns a formatted string for a datastore value input_field: returns a string HTML <input> element for this DataType name: the friendly string name of this DataType parse: parses the formatted string representation of this DataType python_type: the canonical Python type for this datastore type

We use DataType instances to display formatted values in our result lists, and we uses input_field/format/parse to generate forms and parse the results from those forms to allow editing of entities.

additional_short_value_html(unused_value)source
format(value)source
static get(value)source
static get_by_name(name)source
input_field(name, value, sample_values)source
input_field_size()source
short_format(value)source
class google.appengine.ext.admin.DatastoreAdminHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Loads the Datastore Admin handler in an iframe.

PATH = '/datastore_admin'
get()source
class google.appengine.ext.admin.DatastoreBatchEditHandlersource

Bases: google.appengine.ext.admin.DatastoreRequestHandler

Request handler for a batch operation on entities.

Supports deleting multiple entities by key, then redirecting to another url.

PATH = '/datastore/batchedit'
post()source
class google.appengine.ext.admin.DatastoreEditHandlersource

Bases: google.appengine.ext.admin.DatastoreRequestHandler

Request handler for the entity create/edit form.

We determine how to generate a form to edit an entity by doing a query on the entity kind and looking at the set of keys and their types in the result set. We use the DataType subclasses for those introspected types to generate the form and parse the form results.

PATH = '/datastore/edit'
get()source
post()source
class google.appengine.ext.admin.DatastoreGetIndexesHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Our main request handler that displays indexes

PATH = '/datastore_indexes'
get()source
class google.appengine.ext.admin.DatastoreQueryHandlersource

Bases: google.appengine.ext.admin.DatastoreRequestHandler

Our main request handler that executes queries and lists entities.

We use execute_query() in our base request handler to parse URL arguments and execute the datastore query.

PATH = '/datastore'
get()source

Formats the results from execute_query() for datastore.html.

The only complex part of that process is calculating the pager variables to generate the Gooooogle pager at the bottom of the page.

get_kinds(namespace)source

Get sorted list of kind names the datastore knows about.

This should only be called in the development environment as metadata queries are expensive and no caching is done.

Parameters

namespace – The namespace to fetch the schema for e.g. ‘google.com’. It is an error to pass in None.

Returns

A sorted list of kinds e.g. [‘Book’, ‘Guest’, Post’] (encoded in utf-8).

class google.appengine.ext.admin.DatastoreRequestHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

The base request handler for our datastore admin pages.

We provide utility functions for querying the datastore and inferring the types of entity properties.

execute_query(start=0, num=0, no_order=False)source

Parses the URL arguments and executes the query.

Parameters
  • start – How many entities from the beginning of the result list should be skipped from the query.

  • num – How many entities should be returned, if 0 (default) then a reasonable default will be chosen.

Returns

A tuple (list of entities, total entity count). If inappropriate URL arguments are given, we return an empty set of results and 0 for the entity count.

get_key_values(entities)source

Returns the union of key names used by the given list of entities.

We return the union as a dictionary mapping the key names to a sample value from one of the entities for the key name.

num()source

Returns the sanitized “num” argument from the URL.

redirect_with_message(message)source

Redirect to the ‘next’ url with message added as the msg parameter.

start()source

Returns the santized “start” argument from the URL.

class google.appengine.ext.admin.DatastoreStatsHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Allows computation of datastore stats.

PATH = '/datastore_stats'
generate_stats(_app=None)source

Generate datastore stats.

get()source

Shows Datastore Stats generator button.

post()source
class google.appengine.ext.admin.DefaultPageHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Redirects to the Datastore application by default.

PATH = '/'
get()source
class google.appengine.ext.admin.Document(doc_id)source

Bases: object

Simple representation of document.

class google.appengine.ext.admin.EmailTypesource

Bases: google.appengine.ext.admin.StringType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.EmbeddedEntityTypesource

Bases: google.appengine.ext.admin.BlobType

name()source
python_type()source
class google.appengine.ext.admin.FloatTypesource

Bases: google.appengine.ext.admin.NumberType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.GeoPtTypesource

Bases: google.appengine.ext.admin.DataType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.ImTypesource

Bases: google.appengine.ext.admin.DataType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.ImageHandlersource

Bases: google.appengine.ext.webapp._webapp25.RequestHandler

Serves a static image.

This exists because we don’t want to burden the user with specifying a static file handler for the image resources used by the admin tool.

PATH = '/images/.*'
get()source
class google.appengine.ext.admin.InboundMailPageHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Tests Mail requests.

PATH = '/inboundmail'
get()source

Shows template displaying the Inbound Mail form.

class google.appengine.ext.admin.IntTypesource

Bases: google.appengine.ext.admin.NumberType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.InteractiveExecuteHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Executes the Python code submitted in a POST within this context.

For obvious reasons, this should only be available to administrators of the applications.

PATH = '/interactive/execute'
post()source
class google.appengine.ext.admin.InteractivePageHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Shows our interactive console HTML.

PATH = '/interactive'
get()source
class google.appengine.ext.admin.LinkTypesource

Bases: google.appengine.ext.admin.StringType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.ListTypesource

Bases: google.appengine.ext.admin.DataType

format(value)source
input_field(name, value, sample_values)source
name()source
python_type()source
short_format(value)source
short_format_orig(value)source
utf8_short_format(value)source
class google.appengine.ext.admin.LongTypesource

Bases: google.appengine.ext.admin.NumberType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.MemcachePageHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Shows stats about memcache and query form to get values.

DEFAULT_TYPESTR_FOR_NEW = 'String'
PATH = '/memcache'
TYPES = ((<type 'str'>, <type 'str'>, 'String'), (<type 'unicode'>, <type 'unicode'>, 'Unicode String'), (<type 'bool'>, <function <lambda>>, 'Boolean'), (<type 'int'>, <type 'int'>, 'Integer'), (<type 'long'>, <type 'long'>, 'Long Integer'), (<type 'float'>, <type 'float'>, 'Float'))
get()source

Show template and prepare stats and/or key+value to display/edit.

post()source
class google.appengine.ext.admin.NoneTypesource

Bases: google.appengine.ext.admin.DataType

format(value)source
name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.NumberTypesource

Bases: google.appengine.ext.admin.DataType

input_field_size()source
class google.appengine.ext.admin.PhoneNumberTypesource

Bases: google.appengine.ext.admin.StringType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.PostalAddressTypesource

Bases: google.appengine.ext.admin.StringType

name()source
parse(value)source
python_type()source
google.appengine.ext.admin.PseudoBreadcrumbs(key)source

Return a string that looks like the breadcrumbs (for key properties).

Parameters

key – A datastore_types.Key object.

Returns

A string looking like breadcrumbs.

class google.appengine.ext.admin.QueueBatch(title, run_manually, rate_limited, contents)source

Bases: object

Collection of push queues or pull queues.

class google.appengine.ext.admin.QueuesPageHandler(*args, **kwargs)source

Bases: google.appengine.ext.admin.BaseRequestHandler

Shows information about configured (and default) task queues.

PATH = '/queues'
get()source

Shows template displaying the configured task queues.

post()source
class google.appengine.ext.admin.RatingTypesource

Bases: google.appengine.ext.admin.NumberType

name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.ReferenceTypesource

Bases: google.appengine.ext.admin.DataType

additional_short_value_html(value)source
input_field(name, value, sample_values)source
input_field_size()source
name()source
parse(value)source
python_type()source
short_format(value)source
class google.appengine.ext.admin.SearchBatchDeleteHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

FTS batch delete handler.

PATH = '/search_batch_delete'
post()source
class google.appengine.ext.admin.SearchDocumentHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

FTS document information.

PATH = '/search_document'
get()source

Displays FTS document.

class google.appengine.ext.admin.SearchIndexHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

FTS index information.

PATH = '/search_index'
get()source

Displays documents in a FTS index.

class google.appengine.ext.admin.SearchIndexesListHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

FTS main page with list on indexes.

PATH = '/search'
get()source

Displays list of FTS indexes.

class google.appengine.ext.admin.StringTypesource

Bases: google.appengine.ext.admin.DataType

format(value)source
input_field(name, value, sample_values)source
input_field_size()source
name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.TaskQueueHelpersource

Bases: object

Taskqueue rpc wrapper.

delete_task(queue_name, task_name)source

Delete the named task.

Parameters
  • queue_name – The name of the queue.

  • task_name – The name of the task.

get_number_tasks_in_queue(queue_name)source

Returns the number of tasks in the named queue.

Parameters

queue_name – The name of the queue.

Returns

The number of tasks in the queue.

get_queues(now)source

Get a list of queue in the application.

Parameters

now – The current time. A datetime.datetime object with a utc timezone.

Returns

A list of queue dicts corresponding to the tasks for this application.

get_tasks(now, queue_name, start_eta_usec, start_task_name, num_tasks)source

Fetch the specified tasks from taskqueue.

Note: This only searchs by eta.

Parameters
  • now – The current time. This is used to calculate the EtaFromNow. Must be a datetime.datetime in the utc timezone.

  • queue_name – The queue to search for tasks.

  • start_eta_usec – The earliest eta to return.

  • start_task_name – For tasks with the same eta_usec, this is used as a tie breaker.

  • num_tasks – The maximum number of tasks to return.

Returns

A list of task dicts (as returned by

taskqueue_stub.QueryTasksResponseToDict).

purge_queue(queue_name)source

Purge the named queue.

Parameters

queue_name – the name of the queue.

class google.appengine.ext.admin.TasksPageHandler(*args, **kwargs)source

Bases: google.appengine.ext.admin.BaseRequestHandler

Shows information about a queue’s tasks.

MAX_TASKS_TO_FETCH = 1000
MIN_TASKS_TO_FETCH = 200
PAGE_SIZE = 20
PATH = '/tasks'
generate_page_dicts(start_tasks, end_tasks)source

Generate the page dicts from a list of tasks.

Parameters

tasks – A list of task dicts, sorted by eta.

Returns

‘start_name’, ‘start_eta’, ‘number’, ‘has_gap’.

Return type

A list of page dicts containing the following keys

get()source

Shows template displaying the queue’s tasks.

parse_arguments()source

Parse the arguments passed into the request and store them on self.

post()source
redirect_to_tasks(keep_offset=True)source

Perform a redirect to the tasks page.

Parameters

keep_offset – If true, will keep the ‘start_eta’, ‘start_name’ and ‘page_no’ fields.

class google.appengine.ext.admin.TextTypesource

Bases: google.appengine.ext.admin.StringType

input_field(name, value, sample_values)source
name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.TimeTypesource

Bases: google.appengine.ext.admin.DataType

format(value)source
name()source
parse(value)source
python_type()source
google.appengine.ext.admin.TruncateValue(value)source

Truncates potentially very long string to a fixed maximum length.

class google.appengine.ext.admin.UserTypesource

Bases: google.appengine.ext.admin.DataType

input_field_size()source
name()source
parse(value)source
python_type()source
class google.appengine.ext.admin.XMPPPageHandlersource

Bases: google.appengine.ext.admin.BaseRequestHandler

Tests XMPP requests.

PATH = '/xmpp'
get()source

Shows template displaying the XMPP.

google.appengine.ext.admin.get_xsrf_token()source

Return the XSRF token.

This is read from the datastore. If no token is present in the datastore, we create a random token and insert it.

google.appengine.ext.admin.main()source
google.appengine.ext.admin.urepr(value)source

Like repr(), but UTF-8-encodes Unicode inside a list.

google.appengine.ext.admin.ustr(value)source

Like str(), but UTF-8-encodes Unicode instead of failing.

google.appengine.ext.admin.xsrf_required(method)source

Decorator to protect post() handlers against XSRF attacks.