Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ZODBに保存されているすべてのオブジェクトに一意の識別子を設定できるかどうかを知りたいと思いました
ZODBに保存されている各オブジェクトには、オブジェクトが登録された後に_p_oid属性としてアクセスできる一意のIDがあります。
>>> obj._p_oid
主キーに関する通常の注意事項が適用されます。オブジェクトを別のデータベースにエクスポートする必要がある場合でも引き続き使用できる一意の識別子が必要な場合は、自分で管理するuuidを使用することをお勧めします。Pythonには、uuidを生成できるuuidモジュール(Python 2.6以降のstdlib内)があります。