Google App Engine ã«ã¤ãã¦ããªããå¤åç¥ããªã10ã®ãã¨ï¼
Google App Engineのブログããï¼ãªããã¹ã¿ã¼ã¨ãããã ããã®ã§ï¼ããå°ãä¸å¯§ã«è¨³ãã¦ã¿ãï¼
Google App Engine ã«ã¤ãã¦ããªããå¤åç¥ããªã10ã®ãã¨ï¼
1. ã¢ããªã±ã¼ã·ã§ã³ã®ãã¼ã¸ã§ã³ã¯æ°åã§ã¯ãªãæååã§ããï¼
app.yamlãappengine-webã®ã»ã¨ãã©ã®ä¾ã§ã¯ï¼versionãã£ã¼ã«ãã«æ°åããããã¦ãããï¼ããã¯åãªãæ £ç¿ã«ãããªãï¼ãã¼ã¸ã§ã³ã«ã¯URLã§è¨±ããã¦ãããã®ã§ããã°ï¼ä»»æã®æååã使ç¨ã§ããï¼ãã¨ãã°ï¼"live" ã "dev" ããã¼ã¸ã§ã³ã«ä½¿ãã¨ï¼ã¢ããªã±ã¼ã·ã§ã³ã¯ï¼"live.latest.yourapp.appspot.com" ã"dev.latest.yourapp.appspot.com" ã§ã¢ã¯ã»ã¹ã§ããï¼
2. è¤æ°ã®ãã¼ã¸ã§ã³ã®ã¢ããªã±ã¼ã·ã§ã³ãåæã«å©ç¨ã§ããã
1ã§è¿°ã¹ãããã«ï¼App Engineã¯è¤æ°ã®ãã¼ã¸ã§ã³ã®ã¢ããªã±ã¼ã·ã§ã³ãåæã«å®è¡ãããã¨ã許ãã¦ããï¼ãã¹ã¦ã®ãã¼ã¸ã§ã³ã¯ï¼ãã¼ã¿ã¹ãã¢ã¨memcacheãå
±æãããï¼ç°ãªãã¤ã³ã¹ã¿ã³ã¹ä¸ã§å®è¡ããï¼ç°ãªãURLãæã¤ï¼ããã©ã«ãã®ãã¼ã¸ã§ã³ã®URLã¯ã¯ï¼yourapp.appspot.com ã¨ãªããï¼ãã¹ã¦ã®ãã¼ã¸ã§ã³ã¯ï¼ version.latest.yourapp.appspot.com ã§ã¢ã¯ã»ã¹ã§ããï¼è¤æ°ã®ãã¼ã¸ã§ã³ãå©ç¨ã§ããæ©æ§ã¯ï¼æ°ãããã¼ã¸ã§ã³ããªãªã¼ã¹ããåã«ï¼å®ãã¼ã¿ã§å®ç°å¢ã§ãã¹ãããéã«ç¹ã«å½¹ã«ç«ã¤ï¼
ããã«ãã¾ãç¥ããã¦ããªãäºå®ãããï¼ããã¯ï¼ä¸ã¤ã®ã¢ããªã®ãã¹ã¦ã®ãã¼ã¸ã§ã³ãåãã©ã³ã¿ã¤ã ã使ãå¿
è¦ã¯ãªãï¼ã¨ãããã¨ã§ããï¼ãããã¼ã¸ã§ã³ã§Javaã使ãï¼å¥ã®ãã¼ã¸ã§ã³ã§Pythonã使ã£ã¦ãã¦ãã¾ã£ããåé¡ãªãï¼
3. Javaã©ã³ã¿ã¤ã ã§ã¯Javaãã¤ãã³ã¼ãã«ãªããã®ã§ããã°ä»»æã®è¨èªã使ç¨ã§ããï¼
ãJavaã©ã³ã¿ã¤ã ãã¨ã¯å¼ã°ãã¦ãããï¼JVMãã¤ãã³ã¼ãã«ã³ã³ãã¤ã«ãããè¨èªã§ããã°ï¼ã©ããªãã®ã§ãå®è¡ãããã¨ãã§ããï¼å®éï¼JRuby, Groovy, Scala, Rhinoï¼Quercusï¼ããã«ã¯Jython(!)
ãApp Engineã§åããã¦ãã人ãããï¼Javaã©ã³ã¿ã¤ã ä¸ã§ï¼ä½ãåãã¦ä½ãåããªãããã³ãã¥ããã£ãã¾ã¨ãããã®ãï¼
ãã®wikiã«ããï¼
4.'IN'ï¼'!=' æ¼ç®åãç¨ãããã¥ã¨ãªã¯ï¼å é¨çã«è¤æ°ã®ãã¥ã¨ãªã«å±éããã
'!=' 㯠'<' 㨠'>' ã«å±éããï¼çµæãåæãããï¼
name IN ('Bob', 'Jane')
ã¯ä¸ã®äºã¤ã«å±éããï¼çµæãåæãããï¼
name == 'Bob' name == 'Jane'
5. ãã¼ã¿ã¹ãã¢ã«å¯¾ãããªã¯ã¨ã¹ãã¯ãããã§è¡ããã¨ãã§ããï¼
ãªã¯ã¨ã¹ãã®å¦çã«ã¯ãªã¼ããããããããï¼ãããã§è¡ããã¨ã§ãã®ãªã¼ãããããç縮ãããã¨ãã§ããï¼
次ã®ä¾ã¯ï¼MyModelã®éåããcolorãold_favoriteã®ãã®ã100åã¨ãã ãï¼new_favoriteã«ç½®ãæãããã®ï¼
for entity in MyModel.all().filter("color =", old_favorite).fetch(100): entity.color = new_favorite entity.put()
ãããä¸ã®ããã«æ¸ãæããã¨ãã£ã¨éããªãï¼
updated = [] for entity in MyModel.all().filter("color =", old_favorite).fetch(100): entity.color = new_favorite updated.append(entity) db.put(updated)
6.ãã¼ã¿ã¹ãã¢ã®æ§è½ã¯ï¼ä¸ã«åããã¨ã³ãã£ãã£ã®æ°ã¨é¢ä¿ãªã
1ã¤ã®App Engineã®ã¢ããªã±ã¼ã·ã§ã³ã®ã¨ã³ãã£ãã£ã¯ï¼1ã¤ã®BigTableã®tableã«ç½®ããã¦ããï¼queryã®å®è¡ã«ãããæéã¯ï¼(3ã§ã®ã¹ããããªå ´åãé¤ãã°)åºæ¬çã«ï¼çµæã®æ°ã«æ¯ä¾ããï¼
7. ã¤ã³ããã¯ã¹ãä½ãã®ã«ãããæéã¯ï¼ãµã¤ãºã«ã ãä¾åãã訳ã§ã¯ãªãï¼
ã¤ã³ããã¯ã¹ã®ä½æã¯ãã¥ã¼ã¤ã³ã°ããã¦ï¼ä¸å¤®ã®ã·ã¹ãã ãä¸æ¬ãã¦è¡ãçºï¼ä½ææéã«ã¯å¾ ã¡æéããµãã¾ããï¼
8.管çã³ã³ã½ã¼ã«ã®'Stored Data'ã§åç §ã§ããå¤ã¯1æ¥ã«ä¸åº¦ããæ´æ°ããªãï¼
9.app.yamlãappengine-web.xmlã«æ¸ãé çªã«ã¯æå³ãããï¼
ããããé¢åãªééãã«ï¼ã¢ããªã±ã¼ã·ã§ã³è¨å®ãã¡ã¤ã«ãæ¸ãéã«ï¼ãã®ãã¡ã¤ã«ãä¸ããé çªã«å¦çããããã¨ãå¿ãã¦ãã¾ãï¼ã¨ãããã®ãããï¼ãã¨ãã°ï¼remote_apiãã¤ã³ã¹ãã¼ã«ããéã«ï¼ããæ¸ãã¦ãã¾ããã¨ãããããï¼
handlers: - url: /.* script: request.py - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py login: admin
ä¸è¦åé¡ãªãããã ãï¼ãã³ãã©ã¯é çªã«è©ä¾¡ãããã®ã§ï¼ ãã¹ã¦ã®ãªã¯ã¨ã¹ãã«å¯¾ãã¦(remote_api ã«å¯¾ãã¦ã!) request.py ãå ã«ããããã¦ãã¾ãï¼request.pyãå¦çãã¦ãã¾ãï¼request.pyã¯remote_apiãç¥ããªãã®ã§ï¼404 Not Found errorããªã¿ã¼ã³ããããã¨ã«ãªãï¼ãã¹ã¦ã«ããããããã³ãã©ã¯ä¸çªæå¾ã«æ¥ãããã«ããªããã°ãªããªãï¼
Java ã©ã³ã¿ã¤ã ã§ãããã¯åãã ãï¼ããã«ï¼appengine-web.xmlã«æ¸ãããstatic ãã¡ã¤ã«ãã³ãã©ãï¼web.xmlã«ããããåçãã³ãã©ãããå
ã«å¦çããããã¨ã«æ³¨æããå¿
è¦ãããï¼
10. GQLæååã¯æ¯åçµã¿ç«ã¦ãå¿ è¦ã¯ç¡ãï¼
æååãç´æ¥åãè¾¼ã¾ãã«ãã©ã¡ã¼ã¿åã§ç½®æããããã«æ¸ããã¨ãã§ããï¼
q = db.GqlQuery("SELECT * FROM People " "WHERE first_name = :first_name " "AND last_name = :last_name", first_name=first_name, last_name=last_name)
ããã«ãã¥ã¨ãªã«å¯¾ãã¦ãã©ã¡ã¼ã¿ãä½åº¦ããã¤ã³ããããã¨ãã§
ããï¼
q = db.GqlQuery("SELECT * FROM People " "WHERE first_name = :first_name " "AND last_name = :last_name") for first, last in people: q.bind(first, last) person = q.get() print person