hdknr’s posterous

 
Filed under

gae

 

Google App EngineでもXPathが使える!XPathEvaluator Extension for BeautifulSoup(BSXPath)をリリース - 風柳メモ

覚書など

  • いまだにXPathもついでにDOMもよく把握していないので、きっと動作は怪しいと思います(をい)*1
  • 一応、
    http://svn.coderepos.org/share/lang/javascript/javascript-xpath/trunk/test/functional/data/
    を使った試験はしています。
    2009/3/24現在のデータ(0000~0012)において、0002のうちの2つがNG、あとはOKとなっています。
    0002でNGなのは、'.//blockquote/text()'と'.//blockquote/node()'。
    BeautifulSoupの特性なのか、'<...>\n    <...>'のようなHTMLがあった場合、テキストノードとして後ろのタグ前のスペースが無視されてしまう模様。根が深そうなので対応困難っぽいです…。
  • アーカイブファイルには試験用スクリプト(TEST_BSXPath.py)と、まとめて試験する用のWindowsコマンドプロンプト用バッチファイル(testbsx.cmd)(とそのテスト結果)を同梱しています。
    バッチファイルを実行すると".\testbsxresult"フォルダを作ってその中に結果を保存します。
  • BeautifulSoupは3.1.0*よりも3.0.7*の方が、Parseエラーが出にくいようです。
    Currently the 3.0.x series is better at parsing bad HTML than the 3.1 series.
  • 速度的な面は期待しないで下さい。結構遅いかもです。速くする方法があったら教えて下さい。
  • Pythonも初心者なので、かなりおかしな書き方をしていると思われます。こうした方がよいというアドバイスは歓迎です。

PyXMLもlxmlもだめなので、BeautifulSoupですか。

Filed under  //   GAE   XML  

Comments [0]

Issue 1627 - googleappengine - Crypto ImportError in SDK after doing easy_install pycrypto - Google Code

Reported by kumar.mcmillan, May 30, 2009
To use Crypto in the SDK you have to install it globally into
site-packages.  A natural tendency of lazy developers is to run 
easy_install pycrypto.  This installs the Crypto module just fine but the
dev_appserver.py still raises an ImportError which is a bug.

For *users*: here is a temporary workaround:

# delete the egg:
sudo rm -fr
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pycrypto-2.0.1-py2.5-macosx-10.3-i386.egg/

# install it the slightly-less-easy way:
wget
http://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.0.1.tar.gz#md5=277aa00f27cfbb08f21063f4beb6de59
tar -xzf pycrypto-2.0.1.tar.gz 
cd pycrypto-2.0.1
python setup.py build
sudo python setup.py install


If you want to consider fixing this for the SDK, it should be pretty easy
to do.  Here are a few lines of code you can add to dev_appserver.py around
line 819 just before ALLOWED_SITE_PACKAGE_FILES


  try:
      import Crypto as _CryptoTest
      # I.E. pycrypto-2.0.1-py2.5-macosx-10.3-i386.egg/Crypto
      _CryptoBase = os.path.dirname(_CryptoTest.__file__).replace(
            os.path.join(os.path.dirname(os.__file__), 'site-packages'), 
            "")[1:] # removes preceding slash
  except ImportError:
      _CryptoBase = "Crypto"

Then, the subsequent hard-coded strings "Crypto" can be replaced with
_CryptoBase.  I would not recommend using pkg_resources.require('pycrypto')
to find the path since that would introduce setuptools magic.

Filed under  //   GAE   PyCrypto  

Comments [0]

Third-party Python Libraries - Google App Engine - Google Code

PyCrypto

App Engine includes a custom version of the Python Cryptography Toolkit, also known as PyCrypto. The version included with App Engine is based on pycrypto 2.0.1. This is not the latest version, but should be largely compatible with more recent versions.

For reasons both technical and legal, the App Engine version of PyCrypto has the following differences from the original PyCrypto 2.0.1:

  • The RC5 and IDEA ciphers have been removed.

  • The MODE_PGP encryption mode has been removed.

  • All public key cryptography routines are implemented in pure Python code. They do not use any native acceleration (C code).

カスタムバージョンのPyCrypto。
RC5,IDEA秘密鍵はなし。MODE_PGP暗号化はなし。すべてPythonコードでCバインディングを使っていない。

Filed under  //   GAE   PyCrypto  

Comments [0]

Google App Engine Blog: SDK version 1.2.1 released

SDK version 1.2.1 released

We've released version 1.2.1 of the SDK for the Python runtime. Here are some highlights from the release notes:

  • Stable, unique IDs for User objects. The Users service now provides a unique user_id for each user that stays the same even if a user changes her email address.
  • The Images API now supports compositing images and calculating a color histogram for an image.
  • New allowed mail attachment types: ics, vcf
  • Urlfetch requests can now set the User-Agent header.
  • An App Engine-specific version of the Python PyCrypto cryptography library is now available. Learn more at http://code.google.com/appengine/docs/python/tools/libraries.html
  • The bulk loader configuration format has changed to allow non-CSV input. This change is not backwards compatible, so if you've written code for the bulk loader, it will need to be updated.
  • An early release of the bulk downloader is also now available in bulkloader.py. Learn more about these changes at: http://code.google.com/appengine/docs/python/tools/uploadingdata.html

For a full list see the SdkReleaseNotes wiki page.

Downloads for Windows, Mac, and Linux are available on the Downloads page. This SDK update was for the Python runtime, so please post your feedback in the Python runtime discussion group.

Posted by Jeff Scudder, App Engine Team

* User.user_id
* Imaging
* ics , vcf のメール添付
* urlfetch with User-Agent
* PyCrypto
* bulk loader 設定ファイルの書式変更
* bulkloader.pyでのダウンロード

Filed under  //   GAE   PyCrypto  

Comments [0]

Google App Engineのtips集 - スティルハウスの書庫

Comments [0]

appengine に関するエントリ(1) | Weboo! Returns.

通常なら OAuth のクライアントライブラリを使って簡単にできそうなものですが、Google App Engine では openssl のライブラリが使えないので、多くのコンテナで採用されている RSA-SHA1 形式の署名を検証するには少し工夫する必要があります。外部サーバの呼び出し » mDCのページに記載されている公開鍵を mixi.cer という名前のテキストファイルに保存します。そして、この公開鍵を16進数表記に変換します。

% openssl x509 -modulus -noout < mixi.cer | sed s/Modulus=/0x/
0xC048F9DD595072FD561EF7D69533FE4F5957520F755BE6E0252B87003F3D3DD55FF548E78BDD
8491B8EA68B0F3038DFE53950B94AFF4E6344E9C6C050557484B150B81EBD2A624DF81B7C270A6
D15BB857AD34A68C5444A7B60EBDF953DEBAFBAAA36F8E6FB75C4D79EF3714DF74973081AF5F5B
901FF6387CDA44135A665FE5

signed_request.py 中の MIXI_CERT がこれに当たります。他のコンテナに対応させる場合も同様に変換すれば OK です。

Filed under  //   GAE   OpenSSL  

Comments [0]

Twitterもどきを作りながらGoogle App Engineの肝データストアを理解する - page3 - builder by ZDNet Japan

# GQLを用いた問い合わせ
messages
= db.GqlQuery("SELECT * FROM Message"
           
" WHERE author = :1"
           
" ORDER BY date DESC LIMIT 20", user)

 まず、google.appengine.ext.db.GqlQuery()クラスのインスタンスをコンストラクタの第一引数が、GQLを表す文字列だ。ほとんどSQLと変わらないのがお分かりだろう。

 GQLは、本質的にリレーショナルとは異なるデータ構造であるデータストアに対して、SQLに「似た」問い合わせを行うことができると言うだけで、SQLと完全に等価なわけではない。GQLの特徴をいくつか挙げておこう。

  • WHERE句に示す条件式の値に、リテラルを指定することができない。そのため、この例のように「:1」と言う位置パラメータを指定しておき、コンストラクタの第二引数以降でパラメータを置換するという方法をとる。
    ※もしくは、以下のように名前付きパラメータを使用することもできる。
    messages = db.GqlQuery("SELECT * FROM Message"
               
    " WHERE author = :author"
               
    " ORDER BY date DESC LIMIT 20", author=user)
  • SELECTの後には「*」以外を指定することはできない。SQLのように、「選択列をしぼって取得」などということはできないわけだ。
  • FROMキーワードの後に来るのはモデルオブジェクトの種別(クラス名)であり、SQLでは通常カラム名を指定する部分にはモデルのプロパティ名を指定する。
  • GQLのキーワードは大文字、小文字を区別しないが、モデルオブジェクトのクラス名やプロパティ名ではその区別がある
  • 「イコールではない」ことを表す演算子(!=、<>など)は、現状提供されていない。将来的にはサポートされるとのこと。
  • イコール以外の条件式(<、>、<=、>=など)は、一種類のプロパティに対してのみ利用できる。例えば、「date >= :1 AND date <= :2」などは可能だが、「date >= :1 AND count >= :2」の用なことはできない。
  • イコール以外の条件式とORDER BYを同時に使用するときには、条件式のプロパティがORDER BYの最初に指定される必要がある。「WHERE date >= :1 ORDER BY date」は正しいが、「WHERE date >= :1 ORDER BY count」はエラーとなる。

 このように、GQLには標準SQLと比べると多くの制限がある。だが、これらの制限は「Googleレベルのスケーラビリティ」を得るためのトレードオフだと考えれば安いものではないか。

GQL

Filed under  //   GAE  

Comments [0]