2009/02/10


これは朗報。
Google App Engine Blog: SDK version 1.1.9 Released
  • You can now use the Python standard libraries urllib, urllib2 or httplib to make HTTP requests. This has been a frequent request on our issue tracker.
  • We've been working on a set of tools that will make the process of uploading and downloading data from App Engine applications easier. Today we're excited to announce an early release of our new bulk uploading client. You can try it out here. Let us know what you think in our Google Group!
  • Several updates to our datastore, including the automatic generation of single property indexes and the addition of IN and != operators to db.Query. See the Datastore API docs for more details.
  • A bunch of additional bugfixes and enhancements, listed in our Release Notes.
http://googleappengine.blogspot.com/2009/02/sdk-version-119-released.html
試しに以下の様なコードを書いて import urllib2

f = urllib2.urlopen('http://www.google.com/')
print "Content-Type: text/plain;"
print
print f.read()

実行させてみた。

おー動いてる。これで今までGoogle App Engineのurlfetch API様にパッチを当ててきた物が要らなくなる。
Posted at by



2009/02/09


livedoor 製品で mod_access_token というのが出たみたいです。
livedoor ラボ「EDGE」 開発日誌 : 「mod_access_token」の配布開始と「EDGE src」公開のお知らせ - livedoor Blog(ブログ)

ウェブサイト上の画像やファイルに有効期限を指定して、ユーザーに一時的なダウンロードを許可する、ライブドアで独自開発したApacheモジュールです。このモジュールをApache Webサーバに組み込むことにより、画像やファイルをウェブ上で公開するときに有効期限をつけることができるようになり、Webアプリケーションと組み合わせる事で公開範囲の制御を行なう事が可能になります。

http://blog.livedoor.jp/edge_labs/archives/717201.html
modaccesstoken - Google Code

mod_access_token provides access token based secure downloading.

http://code.google.com/p/modaccesstoken/
ソースコード見たら依存が浅かったのでWindowsでビルドしてみた。
Makefile.w32
APACHE_ROOT=C:\Program Files\Apache Software Foundation\Apache2.2
CFLAGS=/I"$(APACHE_ROOT)\include" /DWIN32 /nologo
LDFLAGS=/LIBPATH:"$(APACHE_ROOT)\lib"
LIBS= libapr-1.lib libaprutil-1.lib libhttpd.lib

all : mod_access_token.so

mod_access_token.so : mod_access_token.obj
    link /nologo /DLL /OUT:$@ /EXPORT:access_token_module mod_access_token.obj $(LDFLAGS) $(LIBS)

mod_access_token.obj : mod_access_token.c
    cl -c $(CFLAGS) mod_access_token.c
なぜかmingw32では実行時にエラーが出たのであきらめました。VC6では可変長マクロが使えないので最終的にはVC8でしか試せませんでした。

ビルドしたモジュールを C:\Program Files\Apache Software Foundation\Apache2.2\modules\ に置き、httpd.confへLoadModuleを追加。対象のフォルダに以下の様に設定(.htaccess)します。
.htaccess
AccessTokenCheck On
AccessTokenAccessKey foo
AccessTokenSecret bar
このAccessTokenAccessKey(foo)が公開鍵、AccessTokenSecret(bar)が秘密鍵になります。
認証はREADMEに書かれている通り
download.pl
use strict;
use URI;
use Digest::HMAC_SHA1;

my $access_key = 'foo';
my $secret = shift || die('specify secret key!');
my $exp = time + 300; # 5minutes
my $url = 'http://localhost:8080/access_token/example.jpg';
my $uri = URI->new( $url );
my $plain = sprintf '%s%s%s%s', 'GET', $uri->path, $exp, $access_key;
my $hmac = Digest::HMAC_SHA1->new( $secret );
$hmac->add( $plain );
my $sig = $hmac->b64digest;
$uri->query_form({
    Signature => $sig,
    AccessKey => $access_key,
    Expires => $exp,
});
printf "%s\n", $uri->as_string;
といった感じ。キーが間違ってるとDECLINED(Forbidden)になります。
内部はSHA1による認証処理になってます。

誰ですか!「WindowsなんてマイナーなOSのことは知りません」とか言ってるの!(謎)

追記
パッチを当てないと動かなかったのを忘れてました。
Index: mod_access_token.c
===================================================================
--- mod_access_token.c  (revision 3)
+++ mod_access_token.c  (working copy)
@@ -2,10 +2,12 @@
 #include "httpd.h"
 #include "http_config.h"
 #include "http_protocol.h"
+#include "http_request.h"
 #include "http_log.h"
 #include "ap_config.h"
 #include "apr_sha1.h"
 #include "apr_strings.h"
+#include "apr_base64.h"
 #include "apr_lib.h"
 
 #define ACCESS_KEY_NAME "AccessKey"
Posted at by



2009/01/21


このサイトでは、jQuery Lightbox Plugin は"balupton edition"を入れているのですが、jQueryのバージョンを1.3に上げた途端、エラーが出る様になってしまいました。
調べた所、jQuery1.3ではSizzleという新しいセレクタが採用されており、以下の様な属性フィルタが動かない事が分かりました。
$('[@rel*=foo]')
さらに調べた所、どうやら"@"を付けている事自体が間違っているらしく"@"を取って $('[rel*=foo]')
としてやれば動く様になりました。なぜオリジナルの"@"付きのまま動いていたのかは分かりませんが...
本体への反映は以下
--- jquery.lightbox.js.orig 2008-09-12 02:46:50.000000000 +0900
+++ jquery.lightbox.js  2009-01-21 21:15:37.312500000 +0900
@@ -827,7 +827,7 @@
            var groups_n = 0;
            var orig_rel = this.rel;
            // Create the groups
-           $.each($('[@rel*='+orig_rel+']'), function(index, obj){
+           $.each($('[rel*='+orig_rel+']'), function(index, obj){
                // Get the group
                var rel = $(obj).attr('rel');
                // Are we really a group
ま、balupton edition使ってる人少ないかも知れませんが...
Posted at by