{"id":1817,"date":"2009-10-29T04:36:11","date_gmt":"2009-10-28T19:36:11","guid":{"rendered":"http:\/\/fukata.org\/?p=1817"},"modified":"2017-08-11T22:59:08","modified_gmt":"2017-08-11T22:59:08","slug":"gae-p-required-column","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/1817\/","title":{"rendered":"[GAE\/P]\u5fc5\u9808\u30ab\u30e9\u30e0\u306e\u767b\u9332\u306b\u3064\u3044\u3066"},"content":{"rendered":"

\u6700\u8fd1\u3001GAE for Python\u3067\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u5fc5\u9808\u30ab\u30e9\u30e0\u306e\u5024\u304c\u3046\u307e\u304f\u767b\u9332\u3067\u304d\u306a\u304b\u3063\u305f\u554f\u984c\u304c\u89e3\u6c7a\u3057\u305f\u306e\u3067\u3001\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u3066\u304a\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

\u25a0A.py<\/p>\n

\r\nclass A(db.Model):\r\n    owner = db.UserProperty(required=True,auto_current_user_add=True)\r\n<\/pre>\n

\u25a0B.py<\/p>\n

\r\nclass B(db.Model):\r\n    a = db.ReferenceProperty(required=True,reference_class=A)\r\n<\/pre>\n

\u25a0main.py<\/p>\n

\r\na_key = [\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3A\u306eKey\u3092\u53d6\u5f97]\r\na = A.get(a_key)\r\n# \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u6307\u5b9a\u3057\u306a\u3044\u3068\u767b\u9332\u6642\u306b\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\r\nb = B(a=a)\r\n# \u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u6307\u5b9a\u3057\u3066\u4ee3\u5165\u3057\u3066\u3082\u30a8\u30e9\u30fc\u3068\u306a\u308b\u3002\r\nb.a = a\r\nb.put()\r\n<\/pre>\n

\u305a\u3063\u3068\u3001\u5f8c\u8005\u306e\u3088\u3046\u306b\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u6307\u5b9a\u3057\u3066\u4ee3\u5165\u3057\u3066\u3044\u305f\u306e\u3067\u3001\u300c\u306a\u3093\u3067\u4ee3\u5165\u3057\u3066\u308b\u306e\u306b\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3093\u3060\uff1f\u300d\u3068\u3044\u3046\u98a8\u306b\u601d\u3063\u3066\u3044\u3066\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u6307\u5b9a\u3059\u308b\u3068\u3044\u3046\u306e\u306b\u6c17\u3065\u304f\u306e\u304c\u304b\u306a\u308a\u9045\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n

\u3068\u308a\u3042\u3048\u305a\u3001\u306a\u3093\u3068\u304b\u767b\u9332\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u3001\u524d\u306b\u9032\u3080\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u4eca\u4f5c\u3063\u3066\u3044\u308b\u30a2\u30d7\u30ea\u306fjs\u3054\u308a\u3054\u308a\u306e\u30a2\u30d7\u30ea\u306a\u306e\u3067\u3001\u30c7\u30d0\u30c3\u30b0\u304c\u3044\u3064\u3082\u306b\u6bd4\u3079\u624b\u9593\u304c\u304b\u304b\u308a\u307e\u3059\uff3e\uff3e\uff1b\u3057\u304b\u3082\u3001Python\u81ea\u4f53\u3082\u307e\u3060\u52c9\u5f37\u3057\u59cb\u3081\u3066\u305d\u3093\u306a\u306b\u6642\u9593\u304c\u7d4c\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3069\u3046\u3044\u3046\u95a2\u6570\u304c\u3042\u308b\u306e\u304b\u3059\u3089\u5206\u304b\u3089\u306a\u3044\u72b6\u614b\u3067\u3001\u5e38\u306b\u30b0\u30b0\u308a\u306a\u304c\u3089\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6700\u8fd1\u3001GAE for Python\u3067\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u5fc5\u9808\u30ab\u30e9\u30e0\u306e\u5024\u304c\u3046\u307e\u304f\u767b\u9332\u3067\u304d\u306a\u304b\u3063\u305f\u554f\u984c\u304c\u89e3\u6c7a\u3057\u305f\u306e\u3067\u3001\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u3066\u304a\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u25a0A.py class A(db.Mod … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[403,404,1086],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/1817"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=1817"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/1817\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=1817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=1817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=1817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}