2008/04/21


なるべくdictぽく扱えるように作ってみました。
WedataオブジェクトのコンストラクタにAPIKEYを掘り込んで操作します。
api = Wedata('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
databases = api.databases()
for database in databases:
  print database
  for key in database.keys():
    print " %s=%s" % (key, database[key])
  print
print
また、AutoPagerizeのデータベースであれば以下の様にdataプロパティからの属性参照の様に書く事も出来ます。
database = api.database('AutoPagerize')
print "%s : %s" % (database.name, database.description)
items = database.items()
for item in database.items():
  print " %s" % item.data.pageElement
  print " %s" % item.data.insertBefore
  print
Database.create_databaseの戻り値にはデータベース名(キー名)、Item.create_itemの戻り値にはアイテムIDが戻ります。このIDを使ってDatabase.delete_datebaseおよびItem.dalete_itemを呼び出す事が出来ます。
dbid = api.create_database('my_example_database', 'my_example_database', ['name', 'description'], ['value', 'xpath'], False)
api.delete_database(dbid)
今のところGoogle App Engineには対応していません。Google App Engine上での用途を見付けたら対応するかもしれません。
いつものようにコードはcodereposに置いてあります。
/lang/python/wedata
Posted at by



2008/04/18


世界のナベアツにはてなブックマークで挑戦する - ネットランダム

はてなブックマークのコメントで、1から40まで数えて、3の倍数 と3がつく数字の時だけアホになります。

それではどうぞ!

http://d.hatena.ne.jp/fk_2000/20080418/p2
なんと!ソフトウェアでやるべきネタを人力で!!!

むむむ...こうなればこれをまたソフトウェアで表現するべき!
fk_2000氏と愉快な仲間達がお届けする「世界のナベアツ」

ちなみにコードはこんなの
#!-*- coding:utf-8 -*-
import os
from google.appengine.ext.webapp import template
from google.appengine.api import urlfetch
from BeautifulSoup import BeautifulSoup
import logging

try:
  res = urlfetch.fetch('http://b.hatena.ne.jp/entry/rss/http://d.hatena.ne.jp/fk_2000/20080418/p2')
  print "Content-Type: text/html; charset=UTF-8"
  print ""
  items = []
  for item in BeautifulSoup(res.content)('item'):
    logging.info(item.title)
    logging.info(item.title.string)
    items.insert(0, {
      'title' : item.title.string,
      'description' : item.description.string,
    })
  template_values = {
    'items': items
  }
  path = os.path.join(os.path.dirname(__file__), 'nabeatzz_fk_2000.html')
  print template.render(path, template_values)
except Exception, e:
  print "Status: 400"
  print ""
  print e
Posted at by




reblogぽいですが、私は「We Heart It」の方が好きかな。画像だけに絞っているのがカッコイイ
Minibufferからキー「h i」だけでポスト出来るグリモン書いた。オリジナルのブックマークの動作に従い、250x100以上の画像をポストします。ブックマークレットの場合には「Heart It」のリンクが付きますが、このグリモンではLDRizeのカレントノードに含まれるサイズ250x100以上の画像(PNG/JPG/GIF)をweheartit.comにポストします。
あと、コマンド好きな人は :pinned-or-current-node | weheartit | clear-pin
とかやっとけ!

さっきからtumblr dashboardで使っているのですが便利すぎる!
weheartit.user.js
よかったら、もってけ!

tomblooのコミット権貰ったので気が向いたら...
Posted at by