Python 2.7 ha raggiunto la fine del supporto
e verrà ritirato
il 31 gennaio 2026. Dopo il ritiro, non potrai eseguire il deployment di applicazioni Python 2.7, anche se la tua organizzazione ha utilizzato in precedenza un criterio dell'organizzazione per riattivare i deployment di runtime legacy. Le tue applicazioni Python 2.7 esistenti continueranno a essere eseguite e a ricevere traffico dopo la
data di ritiro. Ti consigliamo di eseguire la migrazione all'ultima versione supportata di Python.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Un'applicazione può verificare se l'utente che ha eseguito l'accesso è un amministratore registrato per l'applicazione. Un amministratore è un utente con il ruolo di base Visualizzatore, Editor o Proprietario oppure il ruolo predefinito Amministratore app App Engine.
La funzione users.is_current_user_admin
restituisce True se l'utente corrente è un amministratore dell'applicazione.
classAdminPage(webapp2.RequestHandler):defget(self):user=users.get_current_user()ifuser:ifusers.is_current_user_admin():self.response.write('You are an administrator.')else:self.response.write('You are not an administrator.')else:self.response.write('You are not logged in.')
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThe application can verify if the logged-in user is an administrator, which includes users with Viewer, Editor, Owner basic roles, or the App Engine App Admin predefined role.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eusers.is_current_user_admin\u003c/code\u003e function determines if the current user is an administrator, returning \u003ccode\u003eTrue\u003c/code\u003e if they are and can only be ran in first-generation runtimes in the App Engine standard environment.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code example demonstrates how to use the \u003ccode\u003eusers.is_current_user_admin\u003c/code\u003e function within a web application to determine if a user has administrator privileges.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003elogin: admin\u003c/code\u003e setting in the configuration file can be utilized to easily restrict access to specific parts of the app to administrators only.\u003c/p\u003e\n"]]],[],null,["# Admin Users\n\nAn application can test whether the currently signed-in user is a registered administrator for\nthe application. An administrator is a user who has the Viewer, Editor, or Owner basic\nrole, or the App Engine App Admin predefined role.\n| This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment. If you are updating to the App Engine Python 3 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/python-differences) to learn about your migration options for legacy bundled services.\n\nThe function [users.is_current_user_admin](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/users#is_current_user_admin)\nreturns `True` if the current user is an administrator for the application. \n\n class AdminPage(webapp2.RequestHandler):\n def get(self):\n user = users.get_current_user()\n if user:\n if users.is_current_user_admin():\n self.response.write('You are an administrator.')\n else:\n self.response.write('You are not an administrator.')\n else:\n self.response.write('You are not logged in.')\n\n| **Tip:** An easy way to restrict access to a part of your application to administrators is to use the `login: admin` configuration element for the URL handler. See [Configuring an App](/appengine/docs/legacy/standard/python/config/appref#handlers_login)"]]