Python 2.7 telah mencapai akhir dukungan
dan akan dihentikan penggunaannya
pada 31 Januari 2026. Setelah penghentian penggunaan, Anda tidak akan dapat men-deploy aplikasi Python 2.7, meskipun organisasi Anda sebelumnya menggunakan kebijakan organisasi untuk mengaktifkan kembali deployment runtime lama. Aplikasi Python 2.7 yang ada akan terus berjalan dan menerima traffic setelah
tanggal penghentiannya. Sebaiknya Anda bermigrasi ke versi Python terbaru yang didukung.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dengan Capabilities API, aplikasi Anda dapat mendeteksi pemadaman layanan dan periode nonaktif terjadwal untuk kemampuan API tertentu. Anda dapat menggunakan API ini untuk mengurangi periode nonaktif di aplikasi dengan mendeteksi kapan kemampuan tidak tersedia, lalu mengabaikannya. .
Misalnya, jika menggunakan Images API untuk mengubah ukuran gambar, Anda dapat menggunakan
Capabilities API untuk mendeteksi saat Images API tidak tersedia dan melewati
perubahan ukuran:
fromgoogle.appengine.apiimportcapabilitiesdefStoreUploadedProfileImage(self):uploaded_image=self.request.get('img')# If the images API is unavailable, we'll just skip the resize.ifcapabilities.CapabilitySet('images').is_enabled():uploaded_image=images.resize(uploaded_image,64,64)store(uploaded_image)
Datastore API menyediakan wrapper praktis untuk kemampuan baca dan tulis Datastore. Meskipun Anda dapat menguji kemampuan hanya dengan memberikan
nama kemampuan sebagai argumen untuk CapabilitySet(), dalam hal ini Anda juga dapat
menggunakan db.READ_CAPABILITY dan db.WRITE_CAPABILITY objek
CapabilitySet yang praktis. Contoh berikut menunjukkan cara mendeteksi ketersediaan penulisan Datastore menggunakan wrapper praktis dan, selama periode nonaktif, memberikan pesan kepada pengguna:
fromgoogle.appengine.extimportdbdefRenderHTMLForm(self):ifnotdb.WRITE_CAPABILITY.is_enabled():# Datastore is in read-only mode.
Menggunakan Capabilities API di Python 2
Class
CapabilitySet
menentukan semua
metode yang tersedia untuk API ini. Anda dapat memberi nama kemampuan secara eksplisit atau
menyimpulkannya dari metode yang disediakan oleh class ini. Lihat di bawah untuk
daftar layanan yang saat ini diaktifkan di API ini.
Kemampuan yang didukung
API tersebut saat ini mendukung kemampuan berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[[["\u003cp\u003eThe Capabilities API allows applications to detect outages and scheduled downtime for specific API capabilities, helping to reduce application downtime by bypassing unavailable features.\u003c/p\u003e\n"],["\u003cp\u003eThis API supports first-generation runtimes and can be utilized when upgrading to corresponding second-generation runtimes, with specific migration guidance for the App Engine Python 3 runtime.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003eis_enabled\u003c/code\u003e generally returns \u003ccode\u003etrue\u003c/code\u003e, the "Datastore writes" capability returns \u003ccode\u003efalse\u003c/code\u003e if Datastore is in read-only mode.\u003c/p\u003e\n"],["\u003cp\u003eThe API can be used by explicitly naming capabilities or by inferring them from the \u003ccode\u003eCapabilitySet\u003c/code\u003e class methods.\u003c/p\u003e\n"],["\u003cp\u003eThe API currently supports capabilities like blobstore, Datastore reads and writes, Images, Mail, Memcache, Task Queue, and URL Fetch services.\u003c/p\u003e\n"]]],[],null,["# Capabilities API for legacy bundled services\n\nWith the Capabilities API, your application can detect outages and scheduled\ndowntime for specific [API capabilities](#Supported_capabilities). You can use\nthis API to reduce downtime in your application by detecting when a capability\nis unavailable and then bypassing it. .\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| python3\n|\n| /services/access). 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| Every `is_enabled` request to this API always returns\n| `true` except for the \"Datastore writes\" capability, which\n| returns `false` if Datastore is in read-only\n| mode for your app.\n\nFor example, if you use the Images API to resize images, you can use the\nCapabilities API to detect when the Images API is unavailable and skip the\nresize: \n\n from google.appengine.api import capabilities\n\n def StoreUploadedProfileImage(self):\n uploaded_image = self.request.get('img')\n # If the images API is unavailable, we'll just skip the resize.\n if capabilities.CapabilitySet('images').is_enabled():\n uploaded_image = images.resize(uploaded_image, 64, 64)\n store(uploaded_image)\n\nThe Datastore API provides a convenience wrapper for the Datastore read and\nwrite capabilities. While you can test capabilities simply by supplying the\ncapability name as an argument to `CapabilitySet()`, in this case you can also\nuse the `db.READ_CAPABILITY` and `db.WRITE_CAPABILITY` convenience\n`CapabilitySet` objects. The following sample shows how to detect the\navailability of Datastore writes using a convenience wrapper and, during\ndowntime, provide a message to users: \n\n from google.appengine.ext import db\n\n def RenderHTMLForm(self):\n if not db.WRITE_CAPABILITY.is_enabled():\n # Datastore is in read-only mode.\n\nUsing the Capabilities API in Python 2\n--------------------------------------\n\nThe\n[CapabilitySet](/appengine/docs/legacy/standard/python/refdocs/google.appengine.api.capabilities#google.appengine.api.capabilities.CapabilitySet)\nclass defines all of the\navailable methods for this API. You can either name capabilities explicitly or\ninfer them from the methods provided by this class. See below for the\n[list of services](#Supported_capabilities) currently enabled in this API.\n\nSupported capabilities\n----------------------\n\nThe API currently supports the following capabilities:"]]