Make組ブログ

Python、Webアプリや製品・サービス開発についてhirokikyが書きます。

2013-01-01から1年間の記事一覧

New year's python meme 2013

New year’s python meme 2013 Today is the final day of 2013, time to write New year’s python meme. This is the last year’s one: http://blog.hirokiky.org/2012/12/31/new_years_python_meme_2012.html 1. What’s the coolest Python application, fr…

Pythonでバウンドインナークラスを使う (Python Advent Calendar 2013 最終日)

Pythonでバウンドインナークラスを使う (Python Advent Calendar 2013 最終日) Python Advent Calendar 2013 25日目のブログ記事です。 Python Advent Calendarでは例年最終日にはゲストをお迎えして記事を書いてもらっています。今年は Python 3.4 のリリース…

Think about expression of blocks as 1 byte

Think about expression of blocks as 1 byte This blog post for my unimportant memo. I am creating genaa, a ASCII Art generator. Now, It can rendering text box like this: ┌────────────────────┐ │Shut the f**k up and│ │write some code! │ └───…

Using .raw method of Django's QuerySet

Using .raw method of Django’s QuerySet Today, I show you to use .raw method of Django’s QuerySet. The method is powerful and it can manipurate data in DB even if a column is not appear in Model’s field. Of cause you can choice to use execu…

Python3.4のSingle-dispatchで遊んでみた - Python Advent Calendar 2013

Python3.4のSingle-dispatchで遊んでみた - Python Advent Calendar 2013 Python Advent Calendar 2013 の 1 日目を担当します、 @hirokiky です。 昨年 に引き続きPythonAdventCalendarを主催しています。 ちなみに今年は現時点であと 4 人参加者が足りません…

何かを作り続けるのはどうすればいいのだろう

何かを作り続けるのはどうすればいいのだろう ものを作るって、ただ一発何かを作るだけじゃないと最近よく思う。 何か作ったらそれをより良くするため作りつづけたり、多くの人に 使ってもらうために広めたりする必要があると思う。 私が今、頭で考えて言っている…

Getting the definition order of class attributes in python

Getting the definition order of class attributes in python Same question was in StackOverFllow, but the answer was not so soft on me. http://stackoverflow.com/questions/4220747/how-do-i-get-the-definition-order-of-class-attributes-in-pytho…

アウトプットとはなんだったのか

アウトプットとはなんだったのか よくある言葉に「インプットすればアウトプットしろ」という啓蒙がある。 感じるのは、言われているアウトプットとはブログ記事として出力されたものを 意味する場合が多いということ。 加えてカンファレンスや勉強会での発表で…

PasteScript空騒ぎ

PasteScript空騒ぎ PasteScript の話。 PasteScriptって? アプリケーションに必要なコマンドを作る地盤を提供してくれるものです。 PasteScript 自身が提供するものでは、テンプレートからアプリケーションを作成する コマンドがあります: paster create テンプ…

Pythonにおける「許されざる悪事」を避けるために

Pythonにおける「許されざる悪事」を避けるために 許されざる悪事というものが存在する 許されざる悪事 モジュールを import するだけでグローバルな値が設定されるというもの。 「import の順番に依存した処理ほど不愉快なものはない。こういった依存性を持…

WSGI向け認証フレームワーク、repoze.whoを使ってみた

WSGI向け認証フレームワーク、repoze.whoを使ってみた repozewwho というWSGI用の認証フレームワークがあります。 Webアプリケーションを書くうえでユーザー認証はほぼほぼ必須となりますが、 それを提供してくれる素晴らしいものです。 なかなかよくできたやつ…

matcha0.1リリースのお知らせとその背景

matcha0.1リリースのお知らせとその背景 matcha という WSGI dispatcher をリリースしました。 WSGIのライブラリ/ミドルウェアで、PATH_INFOを考慮した WSGIアプリケーションの呼び出しを主目的にしています。 matcha (PyPI) この記事では matcha の紹介を軽く…

Introducing django-websettings

Introducing django-websettings I released new package named django-websettings. This is django’s third party application to provide a web interface to set a yet another django’s settings. If you are similar to read English, please read the…

Tips: for Initial arg of Django's Form fields

Tips: for Initial arg of Django’s Form fields Django’s Form fields take a initial argument to specify the initial value for that Field. For more detail about initial, check out the doc Form fields #initial Basically… As written there, if y…

Search view with long long parameters

Search view with long long parameters At most of web application have the so-called search view. The view get some request parameters and display some search results by using these parameters. A search view does not cause any side effects,…

Don't format strings before logging in python

Don’t format strings before logging in python You should not provide formatted string to loggers in Python, like this: logger.info('Logged in: %s' % username) You should write like this: logger.info('Logged in: %s', username) logging Why? …

Django's TestCase.multi\_db attribute is mistake

Django’s TestCase.multi_db attribute is mistake Django’s test framework (django.test.TestCase) has a atribute multi_db . It should be set True when testing on multiple databases (False, by default). If you forget this setting, and your tes…

Sentry with django-newauth

Sentry with django-newauth djangonnewauth is a library to add customizable user model (It developed before Django 1.5). And sentry is a platform to collect logs and aggregate these. Sentry can collect errors raised by some django applicati…

Djangoでアップロードしたファイルを非同期に削除する

Djangoでアップロードしたファイルを非同期に削除する Django の FileField を通してアップロードしたファイルを非同期に削除したい。 本質的にはモデルが削除されると同時にファイルも削除したいというものなんだけど、 そこを同期処理しているとやってられ…

Djangoのチケット18481についての雑記

Djangoのチケット18481についての雑記 Django に投げていた パッチが昨夜取り込まれた のでその話。 前に取り込まれた チケット 18558 以来。 チケット 18481 について このチケットは、別のチケット 17277 に由来してる。 17277 は POST の body 読み込み時…

PythonでWebサーバー書きましょう

PythonでWebサーバー書きましょう 「Webサーバー書いたことある?」 と聞かれ、何じゃらホイと尋ねると 「書いたことあれば分かりそうな問題にハマってる事例見てね。みんな書いたことあるわけじゃないのね、と思って」 とのこと。 そういえば私も書いたこと…

Pyramidでzope.interfaceを使う

Pyramidでzope.interfaceを使う Pyramid で zope.interface を使うときの話 zope.interface Pyramid における zope.interface の使い方 お作法 zope.intreface zope.intreface_ が面白いと最近知った。 実装を持たない「インターフェース」だけ定義して、 そ…

新サービスKarmaidをリリースしました

新サービスKarmaidをリリースしました 新規にWebサービス Karmaid をリリースしました。世界中すべてのものに未ログインで評価できるサービスです。 ここでは Karmaid というサービスについてと、リリース後にあった秒間200リクエストの話をします。 Karmaid…

Djangoのテストで設定 (settings) を上書きする

Djangoのテストで設定 (settings) を上書きする Django のユニットテストを書くときに、 設定ファイル (settings.py) を一部変更したいことがある。 そのやり方をメモ。 テストの一部で変えたいとき ドキュメントに書いてあった。 Override Settings django.…

DjangoのORMが実行してるSQLの見方 (とdjango-debug-toolbar のススメ)

DjangoのORMが実行してるSQLの見方 (とdjango-debug-toolbar のススメ) djangoddebugttoolbar 使おう。 以下の様な記事があった。 Djangoの発行する生SQLが見たい ForeignKeyとfilterのメモ - AtAsAtAmAtArA django.db.connection.queries を使うとよいそう…

django-celeryで非同期処理クイックスタートガイド

djangoccelery で非同期処理をやる。 サクッと非同期処理を試せちゃうような、クイックスタートガイド をメモがてら書いていく。 インストール まずはインストールから。 pip を使って Django と djangoccelery をインストールする。 % pip install Django %…

「それZopeだよ」って言われたので作ったもの

「それZopeだよ」って言われたので作ったもの URLディスパッチャーとか飽きたので、もっと他のことがしたかった。 URL(リクエストのPATH INFO)にマッチしたパターンに対応するビューなど言ってないで、 より汎用的な構造はないかと考えていた。 思いついてつ…

SQLAlchemyのSQL表現言語で集計する

SQLAlchemyのSQL表現言語で集計する 前回の Djangoで売上を集計/集約処理する に続いて、また集計します。 今回はDjango(のORM)ではなく SQLAlchemy を使います。バージョンは0.8。 ただしORMとしてではなく、SQLAlchemyのSQL表現言語(SQLExpression)のみ使…

Djangoで売上を集計/集約処理する

Djangoで売上を集計/集約処理する 集計/集約します。 (この記事ではaggregationを「集計」と訳します。集約、よりもヒットしやすそうだったから) Django 1.4 日本語ドキュメント(暫定) ではこちらにあります。 集約(Aggregation) - Django 1.4 documentation…

DjangoのAUTHORSに追加された

DjangoのAUTHORSに追加された 先日、Djangoに送っていたプルリクエストが取り込まれた。 そんで AUTHORS (Djangoに貢献したことがある人が書いてあるテキスト) に追加された。 初めてのことで嬉しいのでブログに書いてます。 あとは Django のコード書く人増…